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
|
2022-06-23 05:52:28 +00:00
|
|
|
from .notifications import TicketAppliedToAssigneeMessage, TicketProcessedToApplicantMessage
|
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
|
|
|
|
|
|
|
|
2022-06-23 05:52:28 +00:00
|
|
|
def send_ticket_applied_mail_to_assignees(ticket, assignees):
|
|
|
|
if not assignees:
|
2021-09-14 07:48:22 +00:00
|
|
|
logger.debug(
|
2022-06-23 05:52:28 +00:00
|
|
|
"Not found assignees, ticket: {}({}), assignees: {}".format(
|
|
|
|
ticket, str(ticket.id), assignees
|
|
|
|
)
|
2021-09-14 07:48:22 +00:00
|
|
|
)
|
2019-11-07 10:06:58 +00:00
|
|
|
return
|
2020-07-09 07:41:02 +00:00
|
|
|
|
2022-06-23 05:52:28 +00:00
|
|
|
for user in assignees:
|
|
|
|
instance = TicketAppliedToAssigneeMessage(user, 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
|
|
|
|
2022-06-23 05:52:28 +00:00
|
|
|
instance = TicketProcessedToApplicantMessage(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()
|