Skip to content

Commit

Permalink
fix: 修正获取参数 #7603
Browse files Browse the repository at this point in the history
  • Loading branch information
guohelu committed Nov 19, 2024
1 parent a4229a9 commit 234ed1c
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions gcloud/apigw/views/get_template_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand All @@ -50,17 +50,18 @@ 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:
id_in = label_ids
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:
Expand Down

0 comments on commit 234ed1c

Please sign in to comment.