Skip to content

Commit

Permalink
fix #217
Browse files Browse the repository at this point in the history
  • Loading branch information
hhyo committed May 31, 2019
1 parent 318a040 commit 0bb21c1
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions sql/notify.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,16 @@ def notify_for_audit(audit_id, **kwargs):
if workflow_type == WorkflowDict.workflow_type['query']:
workflow_type_display = WorkflowDict.workflow_type['query_display']
workflow_detail = QueryPrivilegesApply.objects.get(apply_id=workflow_id)
instance = workflow_detail.instance.instance_name
db_name = ''
if workflow_detail.priv_type == 1:
workflow_content = '''\n发起时间:{}\n目标实例:{}\n数据库清单:{}\n授权截止时间:{}\n结果集:{}\n'''.format(
workflow_detail.create_time.strftime('%Y-%m-%d %H:%M:%S'),
workflow_detail.instance,
workflow_content = '''数据库清单:{}\n授权截止时间:{}\n结果集:{}\n'''.format(
workflow_detail.db_list,
datetime.datetime.strftime(workflow_detail.valid_date, '%Y-%m-%d %H:%M:%S'),
workflow_detail.limit_num)
elif workflow_detail.priv_type == 2:
workflow_content = '''\n发起时间:{}\n目标实例:{}\n数据库:{}\n表清单:{}\n授权截止时间:{}\n结果集:{}\n'''.format(
workflow_detail.create_time.strftime('%Y-%m-%d %H:%M:%S'),
workflow_detail.instance,
db_name = workflow_detail.db_list
workflow_content = '''数据库:{}\n表清单:{}\n授权截止时间:{}\n结果集:{}\n'''.format(
workflow_detail.db_list,
workflow_detail.table_list,
datetime.datetime.strftime(workflow_detail.valid_date, '%Y-%m-%d %H:%M:%S'),
Expand All @@ -69,6 +68,8 @@ def notify_for_audit(audit_id, **kwargs):
elif workflow_type == WorkflowDict.workflow_type['sqlreview']:
workflow_type_display = WorkflowDict.workflow_type['sqlreview_display']
workflow_detail = SqlWorkflow.objects.get(pk=workflow_id)
instance = workflow_detail.instance.instance_name
db_name = workflow_detail.db_name
workflow_content = re.sub('[\r\n\f]{2,}', '\n',
workflow_detail.sqlworkflowcontent.sql_content[0:500].replace('\r', ''))
else:
Expand All @@ -85,8 +86,8 @@ def notify_for_audit(audit_id, **kwargs):
workflow_detail.create_time.strftime('%Y-%m-%d %H:%M:%S'),
workflow_from,
group_name,
workflow_detail.instance,
workflow_detail.db_name,
instance,
db_name,
workflow_auditors,
current_workflow_auditors,
workflow_title,
Expand All @@ -101,8 +102,8 @@ def notify_for_audit(audit_id, **kwargs):
workflow_detail.create_time.strftime('%Y-%m-%d %H:%M:%S'),
workflow_from,
group_name,
workflow_detail.instance,
workflow_detail.db_name,
instance,
db_name,
workflow_auditors,
workflow_title,
workflow_url,
Expand All @@ -114,8 +115,8 @@ def notify_for_audit(audit_id, **kwargs):
# 消息内容
msg_content = '''发起时间:{}\n目标实例:{}\n数据库:{}\n工单名称:{}\n工单地址:{}\n驳回原因:{}\n提醒:此工单被审核不通过,请按照驳回原因进行修改!'''.format(
workflow_detail.create_time.strftime('%Y-%m-%d %H:%M:%S'),
workflow_detail.instance,
workflow_detail.db_name,
instance,
db_name,
workflow_title,
workflow_url,
workflow_audit_remark)
Expand All @@ -126,14 +127,15 @@ def notify_for_audit(audit_id, **kwargs):
audit_detail.audit_auth_groups.split(',')]
msg_to = auth_group_users(auth_group_names, audit_detail.group_id)
# 消息内容
msg_content = '''发起时间:{}\n发起人:{}\n组:{}\n目标实例:{}\n数据库:{}\n工单名称:{}\n工单地址:{}\n提醒:提交人主动终止流程'''.format(
msg_content = '''发起时间:{}\n发起人:{}\n组:{}\n目标实例:{}\n数据库:{}\n工单名称:{}\n工单地址:{}\n终止原因:{}'''.format(
workflow_detail.create_time.strftime('%Y-%m-%d %H:%M:%S'),
workflow_from,
group_name,
workflow_detail.instance,
workflow_detail.db_name,
instance,
db_name,
workflow_title,
workflow_url)
workflow_url,
workflow_audit_remark)
else:
raise Exception('工单状态不正确')

Expand Down

0 comments on commit 0bb21c1

Please sign in to comment.