2019-11-07 10:06:58 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
#
|
|
|
|
from django.conf import settings
|
|
|
|
|
2020-07-09 07:41:02 +00:00
|
|
|
from common.utils import get_logger
|
2021-09-13 10:50:29 +00:00
|
|
|
from .notifications import TicketAppliedToAssignee, TicketProcessedToApplicant
|
2019-11-07 10:06:58 +00:00
|
|
|
|
2020-12-29 16:19:59 +00:00
|
|
|
logger = get_logger(__file__)
|
2019-11-07 10:06:58 +00:00
|
|
|
|
|
|
|
|
2021-01-18 09:11:30 +00:00
|
|
|
def send_ticket_applied_mail_to_assignees(ticket):
|
2021-09-14 07:48:22 +00:00
|
|
|
ticket_assignees = ticket.current_node.first().ticket_assignees.all()
|
|
|
|
if not ticket_assignees:
|
|
|
|
logger.debug(
|
|
|
|
"Not found assignees, ticket: {}({}), assignees: {}".format(ticket, str(ticket.id), ticket_assignees)
|
|
|
|
)
|
2019-11-07 10:06:58 +00:00
|
|
|
return
|
2020-07-09 07:41:02 +00:00
|
|
|
|
2021-09-14 07:48:22 +00:00
|
|
|
for ticket_assignee in ticket_assignees:
|
|
|
|
instance = TicketAppliedToAssignee(ticket_assignee.assignee, ticket)
|
2021-09-13 10:50:29 +00:00
|
|
|
if settings.DEBUG:
|
|
|
|
logger.debug(instance)
|
|
|
|
instance.publish_async()
|
2019-11-07 10:06:58 +00:00
|
|
|
|
|
|
|
|
2021-08-25 11:02:50 +00:00
|
|
|
def send_ticket_processed_mail_to_applicant(ticket, processor):
|
2020-12-29 16:19:59 +00:00
|
|
|
if not ticket.applicant:
|
|
|
|
logger.error("Not found applicant: {}({})".format(ticket.title, ticket.id))
|
2019-11-07 10:06:58 +00:00
|
|
|
return
|
2021-09-13 10:50:29 +00:00
|
|
|
|
|
|
|
instance = TicketProcessedToApplicant(ticket.applicant, ticket, processor)
|
2020-12-29 16:19:59 +00:00
|
|
|
if settings.DEBUG:
|
2021-09-13 10:50:29 +00:00
|
|
|
logger.debug(instance)
|
|
|
|
instance.publish_async()
|