feat: 优化工单模块 (#5365)

* feat: 优化工单模块

* feat: 优化工单模块2

Co-authored-by: Bai <bugatti_it@163.com>
pull/5369/head
fit2bot 4 years ago committed by GitHub
parent 1a9a5c28f5
commit 167734ca5d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -106,6 +106,8 @@ class CreatePermissionMixin:
class CreateCommentMixin:
def create_comment(self, comment_body):
# 页面展示需要取消缩进
comment_body = textwrap.dedent(comment_body)
comment_data = {
'body': comment_body,
'user': self.processor,
@ -113,14 +115,20 @@ class CreateCommentMixin:
}
return self.comments.create(**comment_data)
def create_applied_comment(self):
comment_body = self.construct_applied_body()
self.create_comment(comment_body)
def create_approved_comment(self):
comment_body = self.construct_approved_body()
# 页面展示需要取消缩进
comment_body = textwrap.dedent(comment_body)
self.create_comment(comment_body)
def create_action_comment(self):
if self.has_applied:
user_display = self.applicant_display
if self.has_processed:
user_display = self.processor_display
comment_body = __(
'User {} {} the ticket'.format(self.processor_display, self.get_action_display())
'User {} {} the ticket'.format(user_display, self.get_action_display())
)
self.create_comment(comment_body)

@ -23,14 +23,19 @@ def on_ticket_pre_save(sender, instance=None, **kwargs):
@receiver(post_save, sender=Ticket)
def on_ticket_processed(sender, instance=None, **kwargs):
if not instance.has_processed:
return
logger.debug('Ticket is processed, send mail: {}'.format(instance.id))
def on_ticket_post_save(sender, instance=None, **kwargs):
instance.create_action_comment()
if instance.action_open:
instance.create_applied_comment()
return
if instance.action_approve:
instance.create_permission()
instance.create_approved_comment()
logger.debug(
'Ticket () has processed, send mail to applicant: {}'.format(
instance.title, instance.applicant_display
)
)
send_ticket_processed_mail_to_applicant(instance)

Loading…
Cancel
Save