Skip to content

Commit

Permalink
feature: 支持项目下插件自由选择业务配置项
Browse files Browse the repository at this point in the history
  • Loading branch information
normal-wls committed Dec 4, 2023
1 parent 6f87d09 commit d98b10d
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
9 changes: 8 additions & 1 deletion gcloud/core/apis/drf/serilaziers/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Original file line number Diff line number Diff line change
@@ -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="支持模板插件中选择业务"),
),
]
1 change: 1 addition & 0 deletions gcloud/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down

0 comments on commit d98b10d

Please sign in to comment.