Skip to content

Commit

Permalink
fix: 添加复制模板最大数量限制 --story=121224121
Browse files Browse the repository at this point in the history
  • Loading branch information
guohelu committed Jan 2, 2025
1 parent 5354ee4 commit 2ccad5d
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions gcloud/apigw/views/copy_template_across_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
from gcloud.iam_auth.view_interceptors.apigw import CopyTemplateInterceptor
from gcloud.apigw.validators.copy_template_across_project import CopyTemplateAcrossProjectValidator

TEMPLATE_COPY_MAX_NUMBER = 10


@login_exempt
@csrf_exempt
Expand All @@ -55,6 +57,12 @@ def copy_template_across_project(request, project_id):

try:
export_data = TaskTemplate.objects.export_templates(template_ids, is_full=False, project_id=request.project.id)
if len(export_data["template"]) > TEMPLATE_COPY_MAX_NUMBER:
return {
"result": False,
"message": "only {} templates can be copied once.".format(TEMPLATE_COPY_MAX_NUMBER),
"code": err_code.INVALID_OPERATION.code,
}
import_result = TaskTemplate.objects.import_templates(
template_data=export_data,
override=False,
Expand Down

0 comments on commit 2ccad5d

Please sign in to comment.