Skip to content

Commit

Permalink
feat(backend): 单据协助设置开发 #8036
Browse files Browse the repository at this point in the history
# Reviewed, transaction id: 24730
  • Loading branch information
ygcyao authored and iSecloud committed Nov 28, 2024
1 parent 6b51161 commit eeb744f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
2 changes: 2 additions & 0 deletions dbm-ui/backend/configuration/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ class BizSettingsEnum(str, StructuredEnum):
# TODO: 后续待删除
SKIP_GRAMMAR_CHECK = EnumField("SKIP_GRAMMAR_CHECK", _("是否跳过语义检查"))
SQL_IMPORT_FORCE_ITSM = EnumField("SQL_IMPORT_FORCE_ITSM", _("是否变更SQL强制需要审批流"))
BIZ_ASSISTANCE_VARS = EnumField("BIZ_ASSISTANCE_VARS", _("业务协助人员变量"))
BIZ_ASSISTANCE_SWITCH = EnumField("BIZ_ASSISTANCE_SWITCH", _("业务协助开关"))


DEFAULT_DB_ADMINISTRATORS = ["admin"]
Expand Down
18 changes: 18 additions & 0 deletions dbm-ui/backend/ticket/models/todo.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
from backend import env
from backend.bk_web.constants import LEN_MIDDLE, LEN_SHORT
from backend.bk_web.models import AuditedModel
from backend.configuration.constants import BizSettingsEnum
from backend.configuration.models import BizSettings
from backend.ticket.constants import FlowMsgStatus, FlowMsgType, TicketFlowStatus, TodoStatus, TodoType
from backend.ticket.tasks.ticket_tasks import send_msg_for_flow

Expand All @@ -28,6 +30,22 @@ def exist_unfinished(self):
return self.filter(status__in=[TodoStatus.TODO, TodoStatus.RUNNING]).exists()

def create(self, **kwargs):
assistance_flag = (
BizSettings.get_setting_value(kwargs["ticket"].bk_biz_id, BizSettingsEnum.BIZ_ASSISTANCE_SWITCH) or False
)
if assistance_flag:
# 获取业务协助人列表
biz_facilitators: list = (
BizSettings.get_setting_value(
bk_biz_id=kwargs["ticket"].bk_biz_id, key=BizSettingsEnum.BIZ_ASSISTANCE_VARS
)
or []
)
operators = kwargs.get("operators", [])
# 过滤掉已经在 operators 中的协助人
unique_biz_facilitators = [facilitator for facilitator in biz_facilitators if facilitator not in operators]
# 按顺序合并
kwargs["operators"] = operators + unique_biz_facilitators
todo = super().create(**kwargs)
send_msg_for_flow.apply_async(
kwargs={
Expand Down

0 comments on commit eeb744f

Please sign in to comment.