From d98b10da53869df8c2e5594ae96dfe0ed7bf0d0c Mon Sep 17 00:00:00 2001 From: waylon <1158341873@qq.com> Date: Mon, 4 Dec 2023 19:54:05 +0800 Subject: [PATCH] =?UTF-8?q?feature:=20=E6=94=AF=E6=8C=81=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E4=B8=8B=E6=8F=92=E4=BB=B6=E8=87=AA=E7=94=B1=E9=80=89=E6=8B=A9?= =?UTF-8?q?=E4=B8=9A=E5=8A=A1=E9=85=8D=E7=BD=AE=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gcloud/core/apis/drf/serilaziers/project.py | 9 ++++++++- ...026_projectconfig_allow_plugin_cross_biz.py | 18 ++++++++++++++++++ gcloud/core/models.py | 1 + 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 gcloud/core/migrations/0026_projectconfig_allow_plugin_cross_biz.py diff --git a/gcloud/core/apis/drf/serilaziers/project.py b/gcloud/core/apis/drf/serilaziers/project.py index 710fca1904..96ea8dc373 100644 --- a/gcloud/core/apis/drf/serilaziers/project.py +++ b/gcloud/core/apis/drf/serilaziers/project.py @@ -12,11 +12,12 @@ """ from rest_framework import serializers -from gcloud.core.models import Project +from gcloud.core.models import Project, ProjectConfig class ProjectSerializer(serializers.ModelSerializer): create_at = serializers.DateTimeField(format="%Y-%m-%d %H:%M:%S %z", read_only=True) + allow_plugin_cross_biz = serializers.SerializerMethodField() class Meta: model = Project @@ -28,4 +29,10 @@ class Meta: "from_cmdb", "bk_biz_id", "relate_business", + "allow_plugin_cross_biz", ] + + def get_allow_plugin_cross_biz(self, obj): + project_id = obj.id + project_config = ProjectConfig.objects.filter(project_id=project_id).first() + return getattr(project_config, "allow_plugin_cross_biz", False) diff --git a/gcloud/core/migrations/0026_projectconfig_allow_plugin_cross_biz.py b/gcloud/core/migrations/0026_projectconfig_allow_plugin_cross_biz.py new file mode 100644 index 0000000000..347c49ce8e --- /dev/null +++ b/gcloud/core/migrations/0026_projectconfig_allow_plugin_cross_biz.py @@ -0,0 +1,18 @@ +# Generated by Django 3.2.15 on 2023-12-04 11:41 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("core", "0025_auto_20230609_2101"), + ] + + operations = [ + migrations.AddField( + model_name="projectconfig", + name="allow_plugin_cross_biz", + field=models.BooleanField(default=False, verbose_name="支持模板插件中选择业务"), + ), + ] diff --git a/gcloud/core/models.py b/gcloud/core/models.py index 660b7ecb6c..7970e18fd4 100644 --- a/gcloud/core/models.py +++ b/gcloud/core/models.py @@ -424,6 +424,7 @@ class ProjectConfig(models.Model): executor_proxy = models.CharField(_("任务执行人代理"), max_length=255, default="", blank=True) executor_proxy_exempts = models.TextField(_("不使用执行人代理的用户列表"), default="", blank=True) max_periodic_task_num = models.IntegerField(_("项目下最大周期任务数"), default=-1, blank=True) + allow_plugin_cross_biz = models.BooleanField("支持模板插件中选择业务", default=False) objects = ProjectConfigManager()