mirror of https://github.com/jumpserver/jumpserver
feat: 优化工单模块 (#5365)
* feat: 优化工单模块 * feat: 优化工单模块2 Co-authored-by: Bai <bugatti_it@163.com>pull/5369/head
parent
1a9a5c28f5
commit
167734ca5d
|
@ -106,6 +106,8 @@ class CreatePermissionMixin:
|
||||||
|
|
||||||
class CreateCommentMixin:
|
class CreateCommentMixin:
|
||||||
def create_comment(self, comment_body):
|
def create_comment(self, comment_body):
|
||||||
|
# 页面展示需要取消缩进
|
||||||
|
comment_body = textwrap.dedent(comment_body)
|
||||||
comment_data = {
|
comment_data = {
|
||||||
'body': comment_body,
|
'body': comment_body,
|
||||||
'user': self.processor,
|
'user': self.processor,
|
||||||
|
@ -113,14 +115,20 @@ class CreateCommentMixin:
|
||||||
}
|
}
|
||||||
return self.comments.create(**comment_data)
|
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):
|
def create_approved_comment(self):
|
||||||
comment_body = self.construct_approved_body()
|
comment_body = self.construct_approved_body()
|
||||||
# 页面展示需要取消缩进
|
|
||||||
comment_body = textwrap.dedent(comment_body)
|
|
||||||
self.create_comment(comment_body)
|
self.create_comment(comment_body)
|
||||||
|
|
||||||
def create_action_comment(self):
|
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 = __(
|
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)
|
self.create_comment(comment_body)
|
||||||
|
|
|
@ -23,14 +23,19 @@ def on_ticket_pre_save(sender, instance=None, **kwargs):
|
||||||
|
|
||||||
|
|
||||||
@receiver(post_save, sender=Ticket)
|
@receiver(post_save, sender=Ticket)
|
||||||
def on_ticket_processed(sender, instance=None, **kwargs):
|
def on_ticket_post_save(sender, instance=None, **kwargs):
|
||||||
if not instance.has_processed:
|
|
||||||
return
|
|
||||||
logger.debug('Ticket is processed, send mail: {}'.format(instance.id))
|
|
||||||
instance.create_action_comment()
|
instance.create_action_comment()
|
||||||
|
if instance.action_open:
|
||||||
|
instance.create_applied_comment()
|
||||||
|
return
|
||||||
if instance.action_approve:
|
if instance.action_approve:
|
||||||
instance.create_permission()
|
instance.create_permission()
|
||||||
instance.create_approved_comment()
|
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)
|
send_ticket_processed_mail_to_applicant(instance)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue