From 234ed1c9c10df65bc66e85f2d1197c5225a3c1d9 Mon Sep 17 00:00:00 2001 From: guohelu <19503896967@163.com> Date: Tue, 19 Nov 2024 09:33:34 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E6=AD=A3=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E5=8F=82=E6=95=B0=20#7603?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gcloud/apigw/views/get_template_list.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/gcloud/apigw/views/get_template_list.py b/gcloud/apigw/views/get_template_list.py index 63f7bdf02..648385fc0 100644 --- a/gcloud/apigw/views/get_template_list.py +++ b/gcloud/apigw/views/get_template_list.py @@ -26,7 +26,7 @@ from gcloud.iam_auth.utils import get_flow_allowed_actions_for_user from gcloud.iam_auth.view_interceptors.apigw import ProjectViewInterceptor from apigw_manager.apigw.decorators import apigw_require -from gcloud.label.models import TemplateLabelRelation +from gcloud.label.models import TemplateLabelRelation, Label @login_exempt @@ -41,7 +41,7 @@ def get_template_list(request, project_id): template_source = request.GET.get("template_source", PROJECT) id_in = request.GET.get("id_in", None) name_keyword = request.GET.get("name_keyword", None) - label_ids = request.GET.get("label_ids", None) + label_names = request.GET.get("label_names", None) if id_in: try: @@ -50,9 +50,10 @@ def get_template_list(request, project_id): id_in = None logger.exception("[API] id_in[{}] resolve fail, ignore.".format(id_in)) - if label_ids: + if label_names: try: - label_ids = label_ids.split(",") + label_names = label_names.split(",") + label_ids = Label.objects.filter(name__in=label_names).values_list("id", flat=True) label_template_ids = TemplateLabelRelation.objects.fetch_template_ids_using_labels(label_ids) label_ids = list(map(str, label_template_ids)) if id_in is None: @@ -60,7 +61,7 @@ def get_template_list(request, project_id): else: id_in = list(set(id_in + label_ids)) except Exception: - logger.exception("[API] label_ids[{}] resolve fail, ignore.".format(label_ids)) + logger.exception("[API] label_names[{}] resolve fail, ignore.".format(label_names)) filter_kwargs = dict(is_deleted=False) if id_in: