From 88d4c522a5a0bd87cfe55ecd5c82bde2ea9bd26a Mon Sep 17 00:00:00 2001 From: guohelu <19503896967@163.com> Date: Thu, 5 Dec 2024 15:50:00 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=BA=94=E7=94=A8=E7=BB=93=E6=9E=84?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=20#7626?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/default.py | 4 +- config/urls_custom.py | 2 +- env.py | 2 +- .../__init__.py | 0 .../admin.py | 8 +- .../{templatemaker => template_maker}/apps.py | 2 +- .../template_maker/migrations/0001_initial.py | 28 ++++ .../migrations}/__init__.py | 0 .../models.py | 11 +- .../serializers.py} | 28 ++-- .../{templatemaker => template_maker}/urls.py | 11 +- gcloud/contrib/template_maker/viewsets.py | 129 ++++++++++++++++++ .../templatemaker/apis/django/__init__.py | 0 .../contrib/templatemaker/apis/django/api.py | 98 ------------- .../templatemaker/apis/drf/__init__.py | 0 .../apis/drf/viewsets/__init__.py | 14 -- .../apis/drf/viewsets/template_marker.py | 57 -------- .../templatemaker/migrations/0001_initial.py | 37 ----- .../templatemaker/migrations/__init__.py | 0 19 files changed, 189 insertions(+), 242 deletions(-) rename gcloud/contrib/{templatemaker => template_maker}/__init__.py (100%) rename gcloud/contrib/{templatemaker => template_maker}/admin.py (76%) rename gcloud/contrib/{templatemaker => template_maker}/apps.py (75%) create mode 100644 gcloud/contrib/template_maker/migrations/0001_initial.py rename gcloud/contrib/{templatemaker/apis => template_maker/migrations}/__init__.py (100%) rename gcloud/contrib/{templatemaker => template_maker}/models.py (69%) rename gcloud/contrib/{templatemaker/apis/django/validators.py => template_maker/serializers.py} (51%) rename gcloud/contrib/{templatemaker => template_maker}/urls.py (68%) create mode 100644 gcloud/contrib/template_maker/viewsets.py delete mode 100644 gcloud/contrib/templatemaker/apis/django/__init__.py delete mode 100644 gcloud/contrib/templatemaker/apis/django/api.py delete mode 100644 gcloud/contrib/templatemaker/apis/drf/__init__.py delete mode 100644 gcloud/contrib/templatemaker/apis/drf/viewsets/__init__.py delete mode 100644 gcloud/contrib/templatemaker/apis/drf/viewsets/template_marker.py delete mode 100644 gcloud/contrib/templatemaker/migrations/0001_initial.py delete mode 100644 gcloud/contrib/templatemaker/migrations/__init__.py diff --git a/config/default.py b/config/default.py index ad04ebe8dc..d51f86bb6c 100644 --- a/config/default.py +++ b/config/default.py @@ -67,7 +67,7 @@ "gcloud.contrib.develop", "gcloud.contrib.collection", "gcloud.contrib.operate_record", - "gcloud.contrib.templatemaker", + "gcloud.contrib.template_maker", "gcloud.apigw", "gcloud.common_template", "gcloud.label", @@ -887,6 +887,6 @@ def check_engine_admin_permission(request, *args, **kwargs): # 共享模板开关 -ENABLE_FLOW_MARKET = env.ENABLE_FLOW_MARKET +ENABLE_TEMPLATE_MARKET = env.ENABLE_TEMPLATE_MARKET # SRE 商店路由 FLOW_MARKET_API_URL = env.FLOW_MARKET_API_URL diff --git a/config/urls_custom.py b/config/urls_custom.py index 8efd65a41f..05d82a7308 100644 --- a/config/urls_custom.py +++ b/config/urls_custom.py @@ -40,7 +40,7 @@ url(r"^plugin_service/", include("plugin_service.urls")), url(r"^mako_operations/", include("gcloud.mako_template_helper.urls")), url(r"^engine_admin/", include("pipeline.contrib.engine_admin.urls")), - url(r"^template_maker/", include("gcloud.contrib.templatemaker.urls")), + url(r"^template_maker/", include("gcloud.contrib.template_maker.urls")), ] schema_view = get_schema_view( diff --git a/env.py b/env.py index 2cd154eeae..bd4a6d622b 100644 --- a/env.py +++ b/env.py @@ -155,6 +155,6 @@ BK_AUDIT_DATA_TOKEN = os.getenv("BK_AUDIT_DATA_TOKEN", None) # 共享模板开关 -ENABLE_FLOW_MARKET = False if os.getenv("BKAPP_ENABLE_FLOW_MARKET") is None else True +ENABLE_TEMPLATE_MARKET = False if os.getenv("ENABLE_TEMPLATE_MARKET") is None else True # SRE 商店路由 FLOW_MARKET_API_URL = os.getenv("FLOW_MARKET_API_URL", "") diff --git a/gcloud/contrib/templatemaker/__init__.py b/gcloud/contrib/template_maker/__init__.py similarity index 100% rename from gcloud/contrib/templatemaker/__init__.py rename to gcloud/contrib/template_maker/__init__.py diff --git a/gcloud/contrib/templatemaker/admin.py b/gcloud/contrib/template_maker/admin.py similarity index 76% rename from gcloud/contrib/templatemaker/admin.py rename to gcloud/contrib/template_maker/admin.py index d9c3dc45a2..4aebf98ecc 100644 --- a/gcloud/contrib/templatemaker/admin.py +++ b/gcloud/contrib/template_maker/admin.py @@ -13,11 +13,11 @@ from django.contrib import admin -from gcloud.contrib.templatemaker import models +from gcloud.contrib.template_maker import models @admin.register(models.TemplateSharedRecord) class AppMakerAdmin(admin.ModelAdmin): - list_display = ["project_id", "template_id", "template_source", "create", "create_time"] - list_filter = ["project_id", "template_source", "create", "create_time"] - search_fields = ["project_id", "create"] + list_display = ["project_id", "template_id", "creator", "create_at", "extra_info"] + list_filter = ["project_id", "template_id", "creator", "create_at"] + search_fields = ["project_id", "creator"] diff --git a/gcloud/contrib/templatemaker/apps.py b/gcloud/contrib/template_maker/apps.py similarity index 75% rename from gcloud/contrib/templatemaker/apps.py rename to gcloud/contrib/template_maker/apps.py index a5fcdbd722..a05e9b11aa 100644 --- a/gcloud/contrib/templatemaker/apps.py +++ b/gcloud/contrib/template_maker/apps.py @@ -3,4 +3,4 @@ class TemplatemakerConfig(AppConfig): default_auto_field = "django.db.models.BigAutoField" - name = "gcloud.contrib.templatemaker" + name = "gcloud.contrib.template_maker" diff --git a/gcloud/contrib/template_maker/migrations/0001_initial.py b/gcloud/contrib/template_maker/migrations/0001_initial.py new file mode 100644 index 0000000000..06b521f4a7 --- /dev/null +++ b/gcloud/contrib/template_maker/migrations/0001_initial.py @@ -0,0 +1,28 @@ +# Generated by Django 3.2.15 on 2024-12-05 07:07 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [] + + operations = [ + migrations.CreateModel( + name="TemplateSharedRecord", + fields=[ + ("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")), + ("project_id", models.IntegerField(default=-1, help_text="项目 ID", verbose_name="项目 ID")), + ("template_id", models.IntegerField(db_index=True, help_text="模版 ID", verbose_name="模版 ID")), + ("creator", models.CharField(help_text="执行者", max_length=128, verbose_name="执行者")), + ("create_at", models.DateTimeField(auto_now_add=True, verbose_name="创建时间")), + ("extra_info", models.TextField(blank=True, null=True, verbose_name="额外信息")), + ], + options={ + "verbose_name": "模板共享记录 TemplateSharedRecord", + "verbose_name_plural": "模板共享记录 TemplateSharedRecord", + }, + ), + ] diff --git a/gcloud/contrib/templatemaker/apis/__init__.py b/gcloud/contrib/template_maker/migrations/__init__.py similarity index 100% rename from gcloud/contrib/templatemaker/apis/__init__.py rename to gcloud/contrib/template_maker/migrations/__init__.py diff --git a/gcloud/contrib/templatemaker/models.py b/gcloud/contrib/template_maker/models.py similarity index 69% rename from gcloud/contrib/templatemaker/models.py rename to gcloud/contrib/template_maker/models.py index f32dd63fc2..a91e528b3b 100644 --- a/gcloud/contrib/templatemaker/models.py +++ b/gcloud/contrib/template_maker/models.py @@ -15,17 +15,14 @@ from django.db import models from django.utils.translation import ugettext_lazy as _ -from gcloud.constants import TEMPLATE_SOURCE, PROJECT - class TemplateSharedRecord(models.Model): project_id = models.IntegerField(_("项目 ID"), default=-1, help_text="项目 ID") - template_id = models.IntegerField(_("模版ID"), db_index=True) - template_source = models.CharField(_("流程模板来源"), max_length=32, choices=TEMPLATE_SOURCE, default=PROJECT) - create = models.CharField(_("执行者"), max_length=128, help_text="执行者") - create_time = models.DateTimeField(_("执行时间"), auto_now_add=True, help_text="执行时间") + template_id = models.IntegerField(_("模版 ID"), db_index=True, help_text="模版 ID") + creator = models.CharField(_("执行者"), max_length=128, help_text="执行者") + create_at = models.DateTimeField(_("创建时间"), auto_now_add=True) + extra_info = models.TextField(_("额外信息"), blank=True, null=True) class Meta: verbose_name = _("模板共享记录 TemplateSharedRecord") verbose_name_plural = _("模板共享记录 TemplateSharedRecord") - unique_together = ("project_id", "template_id") diff --git a/gcloud/contrib/templatemaker/apis/django/validators.py b/gcloud/contrib/template_maker/serializers.py similarity index 51% rename from gcloud/contrib/templatemaker/apis/django/validators.py rename to gcloud/contrib/template_maker/serializers.py index af43e70e54..30dafd36fa 100644 --- a/gcloud/contrib/templatemaker/apis/django/validators.py +++ b/gcloud/contrib/template_maker/serializers.py @@ -11,23 +11,23 @@ specific language governing permissions and limitations under the License. """ -import logging -import ujson as json +from rest_framework import serializers +from gcloud.contrib.template_maker.models import TemplateSharedRecord -from django.utils.translation import ugettext_lazy as _ -from gcloud.utils.validate import RequestValidator +class TemplateSharedRecordSerializer(serializers.ModelSerializer): + class Meta: + model = TemplateSharedRecord + fields = "__all__" -logger = logging.getLogger("root") + def validate(self, attrs): + project_id = attrs.get("project_id") + template_id = attrs.get("template_id") + if not project_id or not template_id: + raise serializers.ValidationError("Project ID and Template ID cannot be empty.") -class JsonValidator(RequestValidator): - def validate(self, request, *args, **kwargs): - try: - json.loads(request.body) - except Exception: - message = _("非法请求: 数据错误, 请求不是合法的Json格式 | validate") - logger.error(message) - return False, message + if TemplateSharedRecord.objects.filter(project_id=project_id, template_id=template_id).exists(): + raise serializers.ValidationError("The template has been shared") - return True, "" + return attrs diff --git a/gcloud/contrib/templatemaker/urls.py b/gcloud/contrib/template_maker/urls.py similarity index 68% rename from gcloud/contrib/templatemaker/urls.py rename to gcloud/contrib/template_maker/urls.py index 28bcb0d984..b9aefd91b1 100644 --- a/gcloud/contrib/templatemaker/urls.py +++ b/gcloud/contrib/template_maker/urls.py @@ -13,14 +13,13 @@ from django.conf.urls import include, url from rest_framework.routers import DefaultRouter -from gcloud.contrib.templatemaker.apis.drf.viewsets import TemplateMakerViewSet -from gcloud.contrib.templatemaker.apis.django import api +from gcloud.contrib.template_maker.viewsets import TemplateMarketViewSet, SharedTemplateViewSet + drf_api = DefaultRouter() -drf_api.register(r"template", TemplateMakerViewSet) +drf_api.register(r"template", TemplateMarketViewSet) +drf_api.register(r"shared", SharedTemplateViewSet) urlpatterns = [ - url(r"^api/maker/", include(drf_api.urls)), - url(r"^api/process_maker/(?P\d+)/", api.maker_template), - url(r"^api/template_detail/(?P\d+)/", api.get_template_market_details), + url(r"^api/", include(drf_api.urls)), ] diff --git a/gcloud/contrib/template_maker/viewsets.py b/gcloud/contrib/template_maker/viewsets.py new file mode 100644 index 0000000000..f3fd002e15 --- /dev/null +++ b/gcloud/contrib/template_maker/viewsets.py @@ -0,0 +1,129 @@ +# -*- coding: utf-8 -*- +""" +Tencent is pleased to support the open source community by making 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community +Edition) available. +Copyright (C) 2017 THL A29 Limited, a Tencent company. All rights reserved. +Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License. +You may obtain a copy of the License at +http://opensource.org/licenses/MIT +Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on +an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the +specific language governing permissions and limitations under the License. +""" + +import logging +import requests + +from rest_framework import viewsets +from rest_framework.response import Response +from rest_framework import permissions + +from gcloud.conf import settings +from gcloud import err_code +from gcloud.contrib.template_maker.serializers import TemplateSharedRecordSerializer +from gcloud.contrib.template_maker.models import TemplateSharedRecord +from gcloud.core.apis.drf.serilaziers.task_template import TaskTemplateSerializer, TaskTemplateListSerializer +from gcloud.taskflow3.models import TaskTemplate +from gcloud.core.apis.drf.viewsets.base import GcloudModelViewSet + + +class TemplateMarkerPermission(permissions.BasePermission): + def has_permission(self, request, view): + template_id = view.kwargs.get("pk") + project_id = request.GET.get("project_id") + + if not template_id or not project_id: + logging.warning("template_id is required.") + return False + try: + TemplateSharedRecord.objects.get(template_id=template_id, project_id=project_id) + except Exception: + logging.warning("template_id {} does not exist.".format(template_id)) + return False + return True + + +class SharedTemplatePermission(permissions.BasePermission): + def has_permission(self, request, view): + if not settings.ENABLE_TEMPLATE_MARKET: + return False + return True + + +class TemplateMarketViewSet(GcloudModelViewSet): + queryset = TaskTemplate.objects.filter(pipeline_template__isnull=False, is_deleted=False) + permission_classes = [permissions.IsAuthenticated, TemplateMarkerPermission] + + def get_serializer_class(self): + if self.action == "list": + return TaskTemplateListSerializer + return TaskTemplateSerializer + + def retrieve(self, request, *args, **kwargs): + instance = self.get_object() + serializer = self.get_serializer(instance) + + return Response(serializer.data) + + +class SharedTemplateViewSet(viewsets.ModelViewSet): + queryset = TemplateSharedRecord.objects.all() + serializer_class = TemplateSharedRecordSerializer + permission_classes = [permissions.IsAuthenticated, SharedTemplatePermission] + + def _get_market_routing(self, market_url): + return f"{settings.FLOW_MARKET_API_URL}/{market_url}" + + def retrieve(self, request, *args, **kwargs): + project_id = kwargs.get("pk") + template_id = request.GET.get("template_id") + + url = self._get_market_routing("market/details/") + data = {"project_id": project_id, "template_id": template_id} + + # 根据业务id和模板id从第三方接口获取模板详情 + result = requests.post(url, data=data) + + if not result or result.status_code != 200: + logging.exception("Get market template details from third party fails") + return Response( + { + "result": False, + "message": "Get market template details from third party fails", + "code": err_code.OPERATION_FAIL.code, + } + ) + + return Response(result.json()) + + def create(self, request, *args, **kwargs): + serializer = self.get_serializer(data=request.data) + serializer.is_valid(raise_exception=True) + + project_id = serializer.validated_data.get("project_id") + template_id = serializer.validated_data.get("template_id") + + try: + TaskTemplate.objects.get(project_id=project_id, id=template_id) + except TaskTemplate.DoesNotExist: + logging.warning(f"Template with project_id {project_id} and template_id {template_id} not found.") + return Response({"result": False, "message": "Template not found", "code": err_code.OPERATION_FAIL.code}) + + # 执行第三方接口调用 + url = self._get_market_routing("prod/api/") + data = {} + headers = None + result = requests.post(url, headers=headers, data=data) + if not result: + logging.exception("Sharing template to SRE store fails") + return Response( + { + "result": False, + "message": "Sharing template to SRE store fails", + "code": err_code.OPERATION_FAIL.code, + }, + ) + + self.perform_create(serializer) + + return Response({"result": True, "message": "Share template successfully", "code": err_code.SUCCESS.code}) diff --git a/gcloud/contrib/templatemaker/apis/django/__init__.py b/gcloud/contrib/templatemaker/apis/django/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/gcloud/contrib/templatemaker/apis/django/api.py b/gcloud/contrib/templatemaker/apis/django/api.py deleted file mode 100644 index 0f6f687d6a..0000000000 --- a/gcloud/contrib/templatemaker/apis/django/api.py +++ /dev/null @@ -1,98 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Tencent is pleased to support the open source community by making 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community -Edition) available. -Copyright (C) 2017 THL A29 Limited, a Tencent company. All rights reserved. -Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License. -You may obtain a copy of the License at -http://opensource.org/licenses/MIT -Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on -an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the -specific language governing permissions and limitations under the License. -""" -import json -import requests -import logging - -from rest_framework.response import Response -from django.views.decorators.http import require_POST, require_GET -from django.http import JsonResponse - -from gcloud.conf import settings -from gcloud import err_code -from gcloud.contrib.templatemaker.models import TemplateSharedRecord -from gcloud.tasktmpl3.models import TaskTemplate -from gcloud.utils.decorators import request_validate -from gcloud.contrib.templatemaker.apis.django.validators import JsonValidator - - -def _get_market_routing(market_url): - return "{}/{}".format(settings.FLOW_MARKET_API_URL, market_url) - - -@require_GET -def get_template_market_details(request, template_id): - project_id = json.loads(request.body).get("project_id") - - url = _get_market_routing("market/details/") - - kwargs = { - "project_id": project_id, - } - - # 根据业务id和模板id从第三方接口获取模板详情 - result = requests.post(url, data=kwargs) - - if not result: - logging.exception("get market template details from third party fails") - return Response( - { - "result": False, - "message": "get market template details from third party fails", - "code": err_code.OPERATION_FAIL.code, - } - ) - - return True - - -@require_POST -@request_validate(JsonValidator) -def maker_template(request, template_id): - if not settings.ENABLE_FLOW_MARKET: - return False - - params = json.loads(request.body) - project_id = params.get("project_id") - try: - TaskTemplate.objects.filter(id=template_id, project__id=project_id).first() - except Exception as e: - logging.exception(e) - return Response( - {"result": False, "message": "template_id does not exist", "code": err_code.OPERATION_FAIL.code} - ) - - url = _get_market_routing("prod/api/") - - kwargs = None - - headers = None - - # 调用第三方接口 - result = requests.post(url, headers=headers, data=kwargs) - - if not result: - logging.exception("Sharing template to SRE store fails") - return JsonResponse( - {"result": False, "message": "Sharing template to SRE store fails", "code": err_code.OPERATION_FAIL.code} - ) - - record, created = TemplateSharedRecord.objects.get_or_create( - project_id=params["project_id"], - template_id=template_id, - defaults={"template_source": params["template_source"], "create": request.user.username}, - ) - if not created: - return JsonResponse({"result": False, "message": "Record already exists", "code": err_code.OPERATION_FAIL.code}) - - return JsonResponse({"result": True, "message": "shared success", "code": err_code.SUCCESS.code}) diff --git a/gcloud/contrib/templatemaker/apis/drf/__init__.py b/gcloud/contrib/templatemaker/apis/drf/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/gcloud/contrib/templatemaker/apis/drf/viewsets/__init__.py b/gcloud/contrib/templatemaker/apis/drf/viewsets/__init__.py deleted file mode 100644 index ea4177dd98..0000000000 --- a/gcloud/contrib/templatemaker/apis/drf/viewsets/__init__.py +++ /dev/null @@ -1,14 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Tencent is pleased to support the open source community by making 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community -Edition) available. -Copyright (C) 2017 THL A29 Limited, a Tencent company. All rights reserved. -Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License. -You may obtain a copy of the License at -http://opensource.org/licenses/MIT -Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on -an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the -specific language governing permissions and limitations under the License. -""" - -from gcloud.contrib.templatemaker.apis.drf.viewsets.template_marker import TemplateMakerViewSet # noqa diff --git a/gcloud/contrib/templatemaker/apis/drf/viewsets/template_marker.py b/gcloud/contrib/templatemaker/apis/drf/viewsets/template_marker.py deleted file mode 100644 index 6570b03130..0000000000 --- a/gcloud/contrib/templatemaker/apis/drf/viewsets/template_marker.py +++ /dev/null @@ -1,57 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Tencent is pleased to support the open source community by making 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community -Edition) available. -Copyright (C) 2017 THL A29 Limited, a Tencent company. All rights reserved. -Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License. -You may obtain a copy of the License at -http://opensource.org/licenses/MIT -Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on -an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the -specific language governing permissions and limitations under the License. -""" - -import logging - -from rest_framework.response import Response -from rest_framework import permissions - -from gcloud.contrib.templatemaker.models import TemplateSharedRecord -from gcloud.core.apis.drf.serilaziers.task_template import TaskTemplateSerializer, TaskTemplateListSerializer -from gcloud.taskflow3.models import TaskTemplate -from gcloud.label.models import TemplateLabelRelation -from gcloud.core.apis.drf.viewsets.base import GcloudModelViewSet - - -class HasValidTemplateID(permissions.BasePermission): - def has_permission(self, request, view): - template_id = view.kwargs.get("pk") - - if not template_id: - logging.warning("template_id is required.") - return False - try: - TemplateSharedRecord.objects.get(template_id=template_id) - except Exception: - logging.warning("template_id {} does not exist.".format(template_id)) - return False - return True - - -class TemplateMakerViewSet(GcloudModelViewSet): - queryset = TaskTemplate.objects.filter(pipeline_template__isnull=False, is_deleted=False) - permission_classes = [permissions.IsAuthenticated, HasValidTemplateID] - - def get_serializer_class(self): - if self.action == "list": - return TaskTemplateListSerializer - return TaskTemplateSerializer - - def retrieve(self, request, *args, **kwargs): - instance = self.get_object() - serializer = self.get_serializer(instance) - data = serializer.data - labels = TemplateLabelRelation.objects.fetch_templates_labels([instance.id]).get(instance.id, []) - data["template_labels"] = [label["label_id"] for label in labels] - - return Response(data) diff --git a/gcloud/contrib/templatemaker/migrations/0001_initial.py b/gcloud/contrib/templatemaker/migrations/0001_initial.py deleted file mode 100644 index 9643d92d63..0000000000 --- a/gcloud/contrib/templatemaker/migrations/0001_initial.py +++ /dev/null @@ -1,37 +0,0 @@ -# Generated by Django 3.2.15 on 2024-12-04 10:14 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - initial = True - - dependencies = [] - - operations = [ - migrations.CreateModel( - name="TemplateSharedRecord", - fields=[ - ("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")), - ("project_id", models.IntegerField(default=-1, help_text="项目 ID", verbose_name="项目 ID")), - ("template_id", models.IntegerField(db_index=True, verbose_name="模版ID")), - ( - "template_source", - models.CharField( - choices=[("project", "项目流程"), ("common", "公共流程"), ("onetime", "一次性任务")], - default="project", - max_length=32, - verbose_name="流程模板来源", - ), - ), - ("create", models.CharField(help_text="执行者", max_length=128, verbose_name="执行者")), - ("create_time", models.DateTimeField(auto_now_add=True, help_text="执行时间", verbose_name="执行时间")), - ], - options={ - "verbose_name": "模板共享记录 TemplateSharedRecord", - "verbose_name_plural": "模板共享记录 TemplateSharedRecord", - "unique_together": {("project_id", "template_id")}, - }, - ), - ] diff --git a/gcloud/contrib/templatemaker/migrations/__init__.py b/gcloud/contrib/templatemaker/migrations/__init__.py deleted file mode 100644 index e69de29bb2..0000000000