From 0bd5bd3fffaa33743bf2ef827af02eb3146e5898 Mon Sep 17 00:00:00 2001 From: guohelu <19503896967@163.com> Date: Fri, 13 Dec 2024 14:10:27 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E5=90=8D=E7=A7=B0=20#7626?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gcloud/contrib/template_market/clients.py | 11 +++++------ gcloud/contrib/template_market/viewsets.py | 8 ++++---- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/gcloud/contrib/template_market/clients.py b/gcloud/contrib/template_market/clients.py index f1da852d9..8b448e327 100644 --- a/gcloud/contrib/template_market/clients.py +++ b/gcloud/contrib/template_market/clients.py @@ -23,23 +23,22 @@ def __init__(self): def _get_url(self, endpoint): return f"{self.base_url}{endpoint}" - def get_template_detail(self, market_record_id): + def get_shared_detail(self, market_record_id): url = self._get_url(f"/sre_scene/flow_template_scene/{market_record_id}/") - cookies = {"bk_ticket": "5IT20mfD9mI_uTitTrUuDKTp9GIif7ZaBivi9E6k5qw"} - response = requests.get(url, cookies=cookies) + response = requests.get(url) return response.json() - def get_market_template_list(self): + def get_shared_list(self): url = self._get_url("/sre_scene/flow_template_scene/?is_all=true") response = requests.get(url) return response.json() - def create_market_template_record(self, data): + def create_shared_record(self, data): url = self._get_url("/sre_scene/flow_template_scene/") response = requests.post(url, json=data) return response.json() - def patch_market_template_record(self, data, market_record_id): + def patch_shared_record(self, data, market_record_id): url = self._get_url(f"/sre_scene/flow_template_scene/{market_record_id}/") response = requests.patch(url, json=data) return response.json() diff --git a/gcloud/contrib/template_market/viewsets.py b/gcloud/contrib/template_market/viewsets.py index 9ec4849e2..b536ef555 100644 --- a/gcloud/contrib/template_market/viewsets.py +++ b/gcloud/contrib/template_market/viewsets.py @@ -78,7 +78,7 @@ def _build_template_data(self, serializer, **kwargs): return data def list(self, request, *args, **kwargs): - response_data = self.market_client.get_market_template_list() + response_data = self.market_client.get_shared_list() if not response_data["result"]: logging.exception("Failed to obtain the market template list") @@ -97,7 +97,7 @@ def create(self, request, *args, **kwargs): serializer.is_valid(raise_exception=True) data = self._build_template_data(serializer) - response_data = self.market_client.create_market_template_record(data) + response_data = self.market_client.create_shared_record(data) if not response_data.get("result"): return Response( { @@ -119,10 +119,10 @@ def partial_update(self, request, *args, **kwargs): market_record_id = kwargs["pk"] serializer = self.serializer_class(data=request.data, partial=True) serializer.is_valid(raise_exception=True) - existing_records = self.market_client.get_template_detail(market_record_id) + existing_records = self.market_client.get_shared_detail(market_record_id) existing_template_ids = set([template["id"] for template in json.loads(existing_records["data"]["templates"])]) data = self._build_template_data(serializer, market_record_id=market_record_id) - response_data = self.market_client.patch_market_template_record(data, market_record_id) + response_data = self.market_client.patch_shared_record(data, market_record_id) if not response_data.get("result"): return Response( {