jumpserver/apps/tickets/utils.py

36 lines
1.0 KiB
Python
Raw Normal View History

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
from .notifications import TicketAppliedToAssigneeMessage, TicketProcessedToApplicantMessage
2019-11-07 10:06:58 +00:00
logger = get_logger(__file__)
2019-11-07 10:06:58 +00:00
def send_ticket_applied_mail_to_assignees(ticket, assignees):
if not assignees:
2021-09-14 07:48:22 +00:00
logger.debug(
"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
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
def send_ticket_processed_mail_to_applicant(ticket, processor):
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 = TicketProcessedToApplicantMessage(ticket.applicant, ticket, processor)
if settings.DEBUG:
2021-09-13 10:50:29 +00:00
logger.debug(instance)
instance.publish_async()