Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 模板市场导入业务优化 --story=121432122 #7662

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fix: 添加复制模板最大数量限制 --story=121224121
  • Loading branch information
guohelu committed Jan 2, 2025
commit 2ccad5d59addcf55aa35e60f149001377d107fae
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
Loading