Skip to content

Commit

Permalink
Merge pull request jly8866#7 from Thy0108/master
Browse files Browse the repository at this point in the history
Add  Refused to execute the list of mail and part of the message content
  • Loading branch information
Mr.July authored Apr 18, 2017
2 parents 2eb9ade + e8ac66b commit 9e885e8
Showing 1 changed file with 31 additions and 6 deletions.
37 changes: 31 additions & 6 deletions sql/views.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# -*- coding: UTF-8 -*-


import re
import json
import time
Expand Down Expand Up @@ -211,17 +212,17 @@ def autoreview(request):

#自动审核通过了,才发邮件
if workflowStatus == Const.workflowStatus['manreviewing']:
#如果进入等待人工审核状态了,则根据settings.py里的配置决定是否给审核人和发起人发一封邮件提醒.
#如果进入等待人工审核状态了,则根据settings.py里的配置决定是否给审核人发一封邮件提醒.
if hasattr(settings, 'MAIL_ON_OFF') == True:
if getattr(settings, 'MAIL_ON_OFF') == "on":
url = _getDetailUrl(request) + str(workflowId) + '/'

#发一封邮件
strTitle = "新的SQL上线工单提醒"
strContent = "发起人:" + engineer + "\n审核人:" + reviewMan + "\n工单地址:" + url
strContent = "发起人:" + engineer + "\n审核人:" + reviewMan + "\n工单地址:" + url + "\n工单名称: " + workflowName + "\n具体SQL:" + sqlContent
objEngineer = users.objects.get(username=engineer)
objReviewMan = users.objects.get(username=reviewMan)
mailSender.sendEmail(strTitle, strContent, [objEngineer.email, objReviewMan.email])
mailSender.sendEmail(strTitle, strContent, [objReviewMan.email])
else:
#不发邮件
pass
Expand Down Expand Up @@ -278,17 +279,21 @@ def execute(request):
workflowDetail.status = finalStatus
workflowDetail.save()

#如果执行完毕了,则根据settings.py里的配置决定是否给DBA一封邮件提醒.
#如果执行完毕了,则根据settings.py里的配置决定是否给提交者和DBA一封邮件提醒.DBA需要知晓审核并执行过的单子
if hasattr(settings, 'MAIL_ON_OFF') == True:
if getattr(settings, 'MAIL_ON_OFF') == "on":
url = _getDetailUrl(request) + str(workflowId) + '/'

#发一封邮件
engineer = workflowDetail.engineer
reviewMan = workflowDetail.review_man
workflowStatus = workflowDetail.status
workflowName = workflowDetail.workflow_name
objEngineer = users.objects.get(username=engineer)
objReviewMan = users.objects.get(username=reviewMan)
strTitle = "SQL上线工单执行完毕"
strContent = "发起人:" + engineer + "\n审核人:" + reviewMan + "\n工单地址:" + url

strContent = "发起人:" + engineer + "\n审核人:" + reviewMan + "\n工单地址:" + url + "\n工单名称: " + workflowName +"\n执行结果:" + workflowStatus
mailSender.sendEmail(strTitle, strContent, [objEngineer.email])
mailSender.sendEmail(strTitle, strContent, getattr(settings, 'MAIL_REVIEW_DBA_ADDR'))
else:
#不发邮件
Expand Down Expand Up @@ -318,6 +323,26 @@ def cancel(request):

workflowDetail.status = Const.workflowStatus['abort']
workflowDetail.save()

#如果人工终止了,则根据settings.py里的配置决定是否给提交者一封邮件提醒,并附带说明此单子被拒绝掉了,需要重新修改.
if hasattr(settings, 'MAIL_ON_OFF') == True:
#判断setting内容和当前登陆用户,如果为提交者自己终止的时候是不需要发邮件的
if getattr(settings, 'MAIL_ON_OFF') == "on" and loginUser != workflowDetail.engineer:
url = _getDetailUrl(request) + str(workflowId) + '/'

#发一封邮件
engineer = workflowDetail.engineer
reviewMan = workflowDetail.review_man
workflowStatus = workflowDetail.status
workflowName = workflowDetail.workflow_name
objEngineer = users.objects.get(username=engineer)
objReviewMan = users.objects.get(username=reviewMan)
strTitle = "SQL上线工单被拒绝执行"
strContent = "发起人:" + engineer + "\n审核人:" + reviewMan + "\n工单地址:" + url + "\n工单名称: " + workflowName +"\n执行结果:" + workflowStatus +"\n提醒:此工单被拒绝执行,请登陆重新提交"
mailSender.sendEmail(strTitle, strContent, [objEngineer.email])
else:
#不发邮件
pass

return HttpResponseRedirect('/detail/' + str(workflowId) + '/')

Expand Down

0 comments on commit 9e885e8

Please sign in to comment.