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()