perf: 优化工单body html显示格式及翻译信息

This commit is contained in:
Bai
2021-01-18 17:11:30 +08:00
committed by Jiangjie.Bai
parent 230ef2f662
commit 243eedc4f9
8 changed files with 231 additions and 167 deletions

View File

@@ -1,11 +1,9 @@
# -*- coding: utf-8 -*-
#
from django.dispatch import receiver
from django.db.models.signals import m2m_changed
from common.utils import get_logger
from tickets.models import Ticket
from tickets.utils import send_ticket_applied_mail_to_assignees
from ..signals import post_change_ticket_action
@@ -15,19 +13,3 @@ logger = get_logger(__name__)
@receiver(post_change_ticket_action, sender=Ticket)
def on_post_change_ticket_action(sender, ticket, action, **kwargs):
ticket.handler.dispatch(action)
@receiver(m2m_changed, sender=Ticket.assignees.through)
def on_ticket_assignees_changed(sender, instance, action, reverse, model, pk_set, **kwargs):
if reverse:
return
if action != 'post_add':
return
logger.debug('Receives ticket and assignees changed signal, ticket: {}'.format(instance.title))
instance.assignees_display = [str(assignee) for assignee in instance.assignees.all()]
instance.save()
assignees = model.objects.filter(pk__in=pk_set)
assignees_display = [str(assignee) for assignee in assignees]
logger.debug('Send applied email to assignees: {}'.format(assignees_display))
send_ticket_applied_mail_to_assignees(instance, assignees)