mirror of https://github.com/jumpserver/jumpserver
perf: 优化工单body html显示格式及翻译信息
parent
230ef2f662
commit
243eedc4f9
Binary file not shown.
|
@ -8,7 +8,7 @@ msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: JumpServer 0.3.3\n"
|
"Project-Id-Version: JumpServer 0.3.3\n"
|
||||||
"Report-Msgid-Bugs-To: \n"
|
"Report-Msgid-Bugs-To: \n"
|
||||||
"POT-Creation-Date: 2021-01-18 14:52+0800\n"
|
"POT-Creation-Date: 2021-01-18 16:42+0800\n"
|
||||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||||
"Last-Translator: ibuler <ibuler@qq.com>\n"
|
"Last-Translator: ibuler <ibuler@qq.com>\n"
|
||||||
"Language-Team: JumpServer team<ibuler@qq.com>\n"
|
"Language-Team: JumpServer team<ibuler@qq.com>\n"
|
||||||
|
@ -2839,6 +2839,137 @@ msgstr "拒绝"
|
||||||
msgid "Closed"
|
msgid "Closed"
|
||||||
msgstr "关闭"
|
msgstr "关闭"
|
||||||
|
|
||||||
|
#: tickets/handler/apply_application.py:55
|
||||||
|
msgid "Applied category"
|
||||||
|
msgstr "申请的种类"
|
||||||
|
|
||||||
|
#: tickets/handler/apply_application.py:56
|
||||||
|
msgid "Applied type"
|
||||||
|
msgstr "申请的类型"
|
||||||
|
|
||||||
|
#: tickets/handler/apply_application.py:57
|
||||||
|
msgid "Applied application group"
|
||||||
|
msgstr "申请的应用组"
|
||||||
|
|
||||||
|
#: tickets/handler/apply_application.py:58 tickets/handler/apply_asset.py:59
|
||||||
|
msgid "Applied system user group"
|
||||||
|
msgstr "申请的系统用户组"
|
||||||
|
|
||||||
|
#: tickets/handler/apply_application.py:59 tickets/handler/apply_asset.py:61
|
||||||
|
msgid "Applied date start"
|
||||||
|
msgstr "申请的开始日期"
|
||||||
|
|
||||||
|
#: tickets/handler/apply_application.py:60 tickets/handler/apply_asset.py:62
|
||||||
|
msgid "Applied date expired"
|
||||||
|
msgstr "申请的失效日期"
|
||||||
|
|
||||||
|
#: tickets/handler/apply_application.py:75
|
||||||
|
msgid "Approved applications"
|
||||||
|
msgstr "批准的应用"
|
||||||
|
|
||||||
|
#: tickets/handler/apply_application.py:76 tickets/handler/apply_asset.py:79
|
||||||
|
msgid "Approved system users"
|
||||||
|
msgstr "批准的系统用户"
|
||||||
|
|
||||||
|
#: tickets/handler/apply_application.py:77 tickets/handler/apply_asset.py:81
|
||||||
|
msgid "Approved date start"
|
||||||
|
msgstr "批准的开始日期"
|
||||||
|
|
||||||
|
#: tickets/handler/apply_application.py:78 tickets/handler/apply_asset.py:82
|
||||||
|
msgid "Approved date expired"
|
||||||
|
msgstr "批准的失效日期"
|
||||||
|
|
||||||
|
#: tickets/handler/apply_application.py:95 tickets/handler/apply_asset.py:98
|
||||||
|
msgid "Created by ticket ({}) ({})"
|
||||||
|
msgstr "通过工单创建 ({}) ({})"
|
||||||
|
|
||||||
|
#: tickets/handler/apply_application.py:99 tickets/handler/apply_asset.py:102
|
||||||
|
msgid ""
|
||||||
|
"Created by the ticket, ticket title: {}, ticket applicant: {}, ticket "
|
||||||
|
"processor: {}, ticket ID: {}"
|
||||||
|
msgstr ""
|
||||||
|
"通过工单创建, 工单标题: {}, 工单申请人: {}, 工单处理人: {}, 工单 ID: {}"
|
||||||
|
|
||||||
|
#: tickets/handler/apply_asset.py:57
|
||||||
|
msgid "Applied IP group"
|
||||||
|
msgstr "申请的IP组"
|
||||||
|
|
||||||
|
#: tickets/handler/apply_asset.py:58
|
||||||
|
msgid "Applied hostname group"
|
||||||
|
msgstr "申请的主机名组"
|
||||||
|
|
||||||
|
#: tickets/handler/apply_asset.py:60
|
||||||
|
msgid "Applied actions"
|
||||||
|
msgstr "申请的动作"
|
||||||
|
|
||||||
|
#: tickets/handler/apply_asset.py:78
|
||||||
|
msgid "Approved assets"
|
||||||
|
msgstr "批准的资产"
|
||||||
|
|
||||||
|
#: tickets/handler/apply_asset.py:80
|
||||||
|
msgid "Approved actions"
|
||||||
|
msgstr "批准的动作"
|
||||||
|
|
||||||
|
#: tickets/handler/base.py:62
|
||||||
|
msgid "User {} {} the ticket"
|
||||||
|
msgstr "用户 {} {} 这个工单"
|
||||||
|
|
||||||
|
#: tickets/handler/base.py:89
|
||||||
|
msgid "Ticket basic info"
|
||||||
|
msgstr "工单基本信息"
|
||||||
|
|
||||||
|
#: tickets/handler/base.py:90
|
||||||
|
msgid "Ticket title"
|
||||||
|
msgstr "工单标题"
|
||||||
|
|
||||||
|
#: tickets/handler/base.py:91
|
||||||
|
msgid "Ticket type"
|
||||||
|
msgstr "工单类型"
|
||||||
|
|
||||||
|
#: tickets/handler/base.py:92
|
||||||
|
msgid "Ticket applicant"
|
||||||
|
msgstr "工单申请人"
|
||||||
|
|
||||||
|
#: tickets/handler/base.py:93
|
||||||
|
msgid "Ticket assignees"
|
||||||
|
msgstr "工单受理人"
|
||||||
|
|
||||||
|
#: tickets/handler/base.py:94
|
||||||
|
msgid "Ticket processor"
|
||||||
|
msgstr "工单处理人"
|
||||||
|
|
||||||
|
#: tickets/handler/base.py:94
|
||||||
|
msgid "No"
|
||||||
|
msgstr "无"
|
||||||
|
|
||||||
|
#: tickets/handler/base.py:95
|
||||||
|
msgid "Ticket action"
|
||||||
|
msgstr "工单动作"
|
||||||
|
|
||||||
|
#: tickets/handler/base.py:96
|
||||||
|
msgid "Ticket status"
|
||||||
|
msgstr "工单状态"
|
||||||
|
|
||||||
|
#: tickets/handler/base.py:114
|
||||||
|
msgid "Ticket applied info"
|
||||||
|
msgstr "工单申请信息"
|
||||||
|
|
||||||
|
#: tickets/handler/base.py:124
|
||||||
|
msgid "Ticket approved info"
|
||||||
|
msgstr "工单批准信息"
|
||||||
|
|
||||||
|
#: tickets/handler/login_confirm.py:16
|
||||||
|
msgid "Applied login IP"
|
||||||
|
msgstr "申请的登录IP"
|
||||||
|
|
||||||
|
#: tickets/handler/login_confirm.py:17
|
||||||
|
msgid "Applied login city"
|
||||||
|
msgstr "申请的登录城市"
|
||||||
|
|
||||||
|
#: tickets/handler/login_confirm.py:18
|
||||||
|
msgid "Applied login datetime"
|
||||||
|
msgstr "申请的登录日期"
|
||||||
|
|
||||||
#: tickets/models/comment.py:19
|
#: tickets/models/comment.py:19
|
||||||
msgid "User display name"
|
msgid "User display name"
|
||||||
msgstr "用户显示名称"
|
msgstr "用户显示名称"
|
||||||
|
@ -2974,65 +3105,23 @@ msgstr "所有受理人都不属于组织 `{}` 下的管理员"
|
||||||
|
|
||||||
#: tickets/utils.py:21
|
#: tickets/utils.py:21
|
||||||
msgid "New Ticket: {} ({})"
|
msgid "New Ticket: {} ({})"
|
||||||
msgstr "新建工单: {} ({})"
|
msgstr "新工单: {} ({})"
|
||||||
|
|
||||||
#: tickets/utils.py:26
|
#: tickets/utils.py:33
|
||||||
#, python-brace-format
|
msgid "Your has a new ticket, from applicant - {}"
|
||||||
msgid ""
|
msgstr "你有一个新的工单, 来自申请人 - {}"
|
||||||
"<div>\n"
|
|
||||||
" <p>Your has a new ticket</p>\n"
|
|
||||||
" <div>\n"
|
|
||||||
" <b>Ticket:</b> \n"
|
|
||||||
" <br/>\n"
|
|
||||||
" {body}\n"
|
|
||||||
" <br/>\n"
|
|
||||||
" <a href={ticket_detail_url}>click here to review</a> \n"
|
|
||||||
" </div>\n"
|
|
||||||
" </div>\n"
|
|
||||||
" "
|
|
||||||
msgstr ""
|
|
||||||
"<div>\n"
|
|
||||||
" <p>你有一个新工单</p>\n"
|
|
||||||
" <div>\n"
|
|
||||||
" <b>工单:</b> \n"
|
|
||||||
" <br/>\n"
|
|
||||||
" {body}\n"
|
|
||||||
" <br/>\n"
|
|
||||||
" <a href={ticket_detail_url}>点击查看</a> \n"
|
|
||||||
" </div>\n"
|
|
||||||
" </div>\n"
|
|
||||||
" "
|
|
||||||
|
|
||||||
#: tickets/utils.py:51
|
#: tickets/utils.py:35
|
||||||
|
msgid "click here to review"
|
||||||
|
msgstr "点击查看"
|
||||||
|
|
||||||
|
#: tickets/utils.py:48
|
||||||
msgid "Ticket has processed: {} ({})"
|
msgid "Ticket has processed: {} ({})"
|
||||||
msgstr "工单已处理: {} ({})"
|
msgstr "工单已处理: {} ({})"
|
||||||
|
|
||||||
#: tickets/utils.py:53
|
#: tickets/utils.py:57
|
||||||
#, python-brace-format
|
msgid "Your ticket has been ({}) processed"
|
||||||
msgid ""
|
msgstr "你的工单已被 ({}) 处理"
|
||||||
"\n"
|
|
||||||
" <div>\n"
|
|
||||||
" <p>Your ticket has been processed</p>\n"
|
|
||||||
" <div>\n"
|
|
||||||
" <b>Ticket:</b> \n"
|
|
||||||
" <br/>\n"
|
|
||||||
" {body}\n"
|
|
||||||
" <br/>\n"
|
|
||||||
" </div>\n"
|
|
||||||
" </div>\n"
|
|
||||||
" "
|
|
||||||
msgstr ""
|
|
||||||
"\n"
|
|
||||||
" <div>\n"
|
|
||||||
" <p>你的工单已被处理</p>\n"
|
|
||||||
" <div>\n"
|
|
||||||
" <b>工单:</b> \n"
|
|
||||||
" <br/>\n"
|
|
||||||
" {body}\n"
|
|
||||||
" <br/>\n"
|
|
||||||
" </div>\n"
|
|
||||||
" </div>\n"
|
|
||||||
" "
|
|
||||||
|
|
||||||
#: users/api/user.py:199
|
#: users/api/user.py:199
|
||||||
msgid "Could not reset self otp, use profile reset instead"
|
msgid "Could not reset self otp, use profile reset instead"
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from django.utils.translation import ugettext as __
|
from django.utils.translation import ugettext as _
|
||||||
from orgs.utils import tmp_to_org, tmp_to_root_org
|
from orgs.utils import tmp_to_org, tmp_to_root_org
|
||||||
from applications.models import Application
|
from applications.models import Application
|
||||||
from applications.const import ApplicationCategoryChoices, ApplicationTypeChoices
|
from applications.const import ApplicationCategoryChoices, ApplicationTypeChoices
|
||||||
|
@ -52,12 +52,12 @@ class Handler(BaseHandler):
|
||||||
{}: {},
|
{}: {},
|
||||||
{}: {},
|
{}: {},
|
||||||
'''.format(
|
'''.format(
|
||||||
__('Applied category'), apply_category_display,
|
_('Applied category'), apply_category_display,
|
||||||
__('Applied type'), apply_type_display,
|
_('Applied type'), apply_type_display,
|
||||||
__('Applied application group'), apply_application_group,
|
_('Applied application group'), apply_application_group,
|
||||||
__('Applied system user group'), apply_system_user_group,
|
_('Applied system user group'), apply_system_user_group,
|
||||||
__('Applied date start'), apply_date_start,
|
_('Applied date start'), apply_date_start,
|
||||||
__('Applied date expired'), apply_date_expired,
|
_('Applied date expired'), apply_date_expired,
|
||||||
)
|
)
|
||||||
return applied_body
|
return applied_body
|
||||||
|
|
||||||
|
@ -72,10 +72,10 @@ class Handler(BaseHandler):
|
||||||
{}: {},
|
{}: {},
|
||||||
{}: {},
|
{}: {},
|
||||||
'''.format(
|
'''.format(
|
||||||
__('Approved applications'), approve_applications_display,
|
_('Approved applications'), approve_applications_display,
|
||||||
__('Approved system users'), approve_system_users_display,
|
_('Approved system users'), approve_system_users_display,
|
||||||
__('Approved date start'), approve_date_start,
|
_('Approved date start'), approve_date_start,
|
||||||
__('Approved date expired'), approve_date_expired
|
_('Approved date expired'), approve_date_expired
|
||||||
)
|
)
|
||||||
return approved_body
|
return approved_body
|
||||||
|
|
||||||
|
@ -92,10 +92,10 @@ class Handler(BaseHandler):
|
||||||
approve_system_users_id = self.ticket.meta.get('approve_system_users', [])
|
approve_system_users_id = self.ticket.meta.get('approve_system_users', [])
|
||||||
approve_date_start = self.ticket.meta.get('approve_date_start')
|
approve_date_start = self.ticket.meta.get('approve_date_start')
|
||||||
approve_date_expired = self.ticket.meta.get('approve_date_expired')
|
approve_date_expired = self.ticket.meta.get('approve_date_expired')
|
||||||
permission_name = '{}({})'.format(
|
permission_name = _('Created by ticket ({}) ({})'.format(
|
||||||
__('Created by ticket ({})'.format(self.ticket.title)), str(self.ticket.id)[:4]
|
self.ticket.title, str(self.ticket.id)[:4])
|
||||||
)
|
)
|
||||||
permission_comment = __(
|
permission_comment = _(
|
||||||
'Created by the ticket, '
|
'Created by the ticket, '
|
||||||
'ticket title: {}, '
|
'ticket title: {}, '
|
||||||
'ticket applicant: {}, '
|
'ticket applicant: {}, '
|
||||||
|
@ -108,10 +108,10 @@ class Handler(BaseHandler):
|
||||||
)
|
)
|
||||||
permissions_data = {
|
permissions_data = {
|
||||||
'id': self.ticket.id,
|
'id': self.ticket.id,
|
||||||
'name': permission_name,
|
'name': str(permission_name),
|
||||||
'category': apply_category,
|
'category': apply_category,
|
||||||
'type': apply_type,
|
'type': apply_type,
|
||||||
'comment': permission_comment,
|
'comment': str(permission_comment),
|
||||||
'created_by': '{}:{}'.format(str(self.__class__.__name__), str(self.ticket.id)),
|
'created_by': '{}:{}'.format(str(self.__class__.__name__), str(self.ticket.id)),
|
||||||
'date_start': approve_date_start,
|
'date_start': approve_date_start,
|
||||||
'date_expired': approve_date_expired,
|
'date_expired': approve_date_expired,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
from .base import BaseHandler
|
from .base import BaseHandler
|
||||||
from django.utils.translation import ugettext as __
|
from django.utils.translation import ugettext as _
|
||||||
|
|
||||||
from perms.models import AssetPermission, Action
|
from perms.models import AssetPermission, Action
|
||||||
from assets.models import Asset, SystemUser
|
from assets.models import Asset, SystemUser
|
||||||
|
@ -54,12 +54,12 @@ class Handler(BaseHandler):
|
||||||
{}: {},
|
{}: {},
|
||||||
{}: {}
|
{}: {}
|
||||||
'''.format(
|
'''.format(
|
||||||
__('Applied IP group'), apply_ip_group,
|
_('Applied IP group'), apply_ip_group,
|
||||||
__("Applied hostname group"), apply_hostname_group,
|
_("Applied hostname group"), apply_hostname_group,
|
||||||
__("Applied system user group"), apply_system_user_group,
|
_("Applied system user group"), apply_system_user_group,
|
||||||
__("Applied actions"), apply_actions_display,
|
_("Applied actions"), apply_actions_display,
|
||||||
__('Applied date start'), apply_date_start,
|
_('Applied date start'), apply_date_start,
|
||||||
__('Applied date expired'), apply_date_expired,
|
_('Applied date expired'), apply_date_expired,
|
||||||
)
|
)
|
||||||
return applied_body
|
return applied_body
|
||||||
|
|
||||||
|
@ -75,11 +75,11 @@ class Handler(BaseHandler):
|
||||||
{}: {},
|
{}: {},
|
||||||
{}: {}
|
{}: {}
|
||||||
'''.format(
|
'''.format(
|
||||||
__('Approved assets'), approve_assets_display,
|
_('Approved assets'), approve_assets_display,
|
||||||
__('Approved system users'), approve_system_users_display,
|
_('Approved system users'), approve_system_users_display,
|
||||||
__('Approved actions'), ', '.join(approve_actions_display),
|
_('Approved actions'), ', '.join(approve_actions_display),
|
||||||
__('Approved date start'), approve_date_start,
|
_('Approved date start'), approve_date_start,
|
||||||
__('Approved date expired'), approve_date_expired,
|
_('Approved date expired'), approve_date_expired,
|
||||||
)
|
)
|
||||||
return approved_body
|
return approved_body
|
||||||
|
|
||||||
|
@ -95,23 +95,25 @@ class Handler(BaseHandler):
|
||||||
approve_actions = self.ticket.meta.get('approve_actions', Action.NONE)
|
approve_actions = self.ticket.meta.get('approve_actions', Action.NONE)
|
||||||
approve_date_start = self.ticket.meta.get('approve_date_start')
|
approve_date_start = self.ticket.meta.get('approve_date_start')
|
||||||
approve_date_expired = self.ticket.meta.get('approve_date_expired')
|
approve_date_expired = self.ticket.meta.get('approve_date_expired')
|
||||||
permission_name = '{}({})'.format(
|
permission_name = _('Created by ticket ({}) ({})'.format(
|
||||||
__('Created by ticket ({})'.format(self.ticket.title)), str(self.ticket.id)[:4]
|
self.ticket.title, str(self.ticket.id)[:4])
|
||||||
)
|
)
|
||||||
permission_comment = __(
|
permission_comment = _(
|
||||||
'Created by the ticket, '
|
'Created by the ticket, '
|
||||||
'ticket title: {}, '
|
'ticket title: {}, '
|
||||||
'ticket applicant: {}, '
|
'ticket applicant: {}, '
|
||||||
'ticket processor: {}, '
|
'ticket processor: {}, '
|
||||||
'ticket ID: {}'
|
'ticket ID: {}'
|
||||||
''.format(
|
''.format(
|
||||||
self.ticket.title, self.ticket.applicant_display, self.ticket.processor_display,
|
self.ticket.title,
|
||||||
|
self.ticket.applicant_display,
|
||||||
|
self.ticket.processor_display,
|
||||||
str(self.ticket.id)
|
str(self.ticket.id)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
permission_data = {
|
permission_data = {
|
||||||
'id': self.ticket.id,
|
'id': self.ticket.id,
|
||||||
'name': permission_name,
|
'name': str(permission_name),
|
||||||
'comment': permission_comment,
|
'comment': permission_comment,
|
||||||
'created_by': '{}:{}'.format(str(self.__class__.__name__), str(self.ticket.id)),
|
'created_by': '{}:{}'.format(str(self.__class__.__name__), str(self.ticket.id)),
|
||||||
'actions': approve_actions,
|
'actions': approve_actions,
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
from django.utils.translation import ugettext as __
|
from django.utils.translation import ugettext as _
|
||||||
from common.utils import get_logger
|
from common.utils import get_logger
|
||||||
from tickets.utils import send_ticket_processed_mail_to_applicant
|
from tickets.utils import (
|
||||||
|
send_ticket_processed_mail_to_applicant, send_ticket_applied_mail_to_assignees
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
logger = get_logger(__name__)
|
logger = get_logger(__name__)
|
||||||
|
@ -14,9 +16,11 @@ class BaseHandler(object):
|
||||||
# on action
|
# on action
|
||||||
def _on_open(self):
|
def _on_open(self):
|
||||||
self.ticket.applicant_display = str(self.ticket.applicant)
|
self.ticket.applicant_display = str(self.ticket.applicant)
|
||||||
|
self.ticket.assignees_display = [str(assignee) for assignee in self.ticket.assignees.all()]
|
||||||
meta_display = getattr(self, '_construct_meta_display_of_open', lambda: {})()
|
meta_display = getattr(self, '_construct_meta_display_of_open', lambda: {})()
|
||||||
self.ticket.meta.update(meta_display)
|
self.ticket.meta.update(meta_display)
|
||||||
self.ticket.save()
|
self.ticket.save()
|
||||||
|
self._send_applied_mail_to_assignees()
|
||||||
|
|
||||||
def _on_approve(self):
|
def _on_approve(self):
|
||||||
meta_display = getattr(self, '_construct_meta_display_of_approve', lambda: {})()
|
meta_display = getattr(self, '_construct_meta_display_of_approve', lambda: {})()
|
||||||
|
@ -41,11 +45,12 @@ class BaseHandler(object):
|
||||||
return method()
|
return method()
|
||||||
|
|
||||||
# email
|
# email
|
||||||
|
def _send_applied_mail_to_assignees(self):
|
||||||
|
logger.debug('Send applied email to assignees: {}'.format(self.ticket.assignees_display))
|
||||||
|
send_ticket_applied_mail_to_assignees(self.ticket)
|
||||||
|
|
||||||
def _send_processed_mail_to_applicant(self):
|
def _send_processed_mail_to_applicant(self):
|
||||||
msg = 'Ticket ({}) has processed, send mail to applicant ({})'.format(
|
logger.debug('Send processed mail to applicant: {}'.format(self.ticket.applicant_display))
|
||||||
self.ticket.title, self.ticket.applicant_display
|
|
||||||
)
|
|
||||||
logger.debug(msg)
|
|
||||||
send_ticket_processed_mail_to_applicant(self.ticket)
|
send_ticket_processed_mail_to_applicant(self.ticket)
|
||||||
|
|
||||||
# comments
|
# comments
|
||||||
|
@ -54,13 +59,18 @@ class BaseHandler(object):
|
||||||
user_display = str(user)
|
user_display = str(user)
|
||||||
action_display = self.ticket.get_action_display()
|
action_display = self.ticket.get_action_display()
|
||||||
data = {
|
data = {
|
||||||
'body': __('User {} {} the ticket'.format(user_display, action_display)),
|
'body': _('User {} {} the ticket'.format(user_display, action_display)),
|
||||||
'user': user,
|
'user': user,
|
||||||
'user_display': user_display
|
'user_display': user_display
|
||||||
}
|
}
|
||||||
return self.ticket.comments.create(**data)
|
return self.ticket.comments.create(**data)
|
||||||
|
|
||||||
# body
|
# body
|
||||||
|
body_html_format = '''
|
||||||
|
{}:
|
||||||
|
<div style="margin-left: 20px;">{}</div>
|
||||||
|
'''
|
||||||
|
|
||||||
def get_body(self):
|
def get_body(self):
|
||||||
old_body = self.ticket.meta.get('body')
|
old_body = self.ticket.meta.get('body')
|
||||||
if old_body:
|
if old_body:
|
||||||
|
@ -71,9 +81,7 @@ class BaseHandler(object):
|
||||||
return basic_body + meta_body
|
return basic_body + meta_body
|
||||||
|
|
||||||
def _construct_basic_body(self):
|
def _construct_basic_body(self):
|
||||||
body = '''
|
basic_body = '''{}: {},
|
||||||
{}:
|
|
||||||
{}: {},
|
|
||||||
{}: {},
|
{}: {},
|
||||||
{}: {},
|
{}: {},
|
||||||
{}: {},
|
{}: {},
|
||||||
|
@ -81,15 +89,15 @@ class BaseHandler(object):
|
||||||
{}: {},
|
{}: {},
|
||||||
{}: {}
|
{}: {}
|
||||||
'''.format(
|
'''.format(
|
||||||
__("Ticket basic info"),
|
_('Ticket title'), self.ticket.title,
|
||||||
__('Ticket title'), self.ticket.title,
|
_('Ticket type'), self.ticket.get_type_display(),
|
||||||
__('Ticket type'), self.ticket.get_type_display(),
|
_('Ticket applicant'), self.ticket.applicant_display,
|
||||||
__('Ticket applicant'), self.ticket.applicant_display,
|
_('Ticket assignees'), self.ticket.assignees_display,
|
||||||
__('Ticket assignees'), self.ticket.assignees_display,
|
_('Ticket processor'), self.ticket.processor_display or _('No'),
|
||||||
__('Ticket processor'), self.ticket.processor_display,
|
_('Ticket action'), self.ticket.get_action_display(),
|
||||||
__('Ticket action'), self.ticket.get_action_display(),
|
_('Ticket status'), self.ticket.get_status_display()
|
||||||
__('Ticket status'), self.ticket.get_status_display()
|
|
||||||
)
|
)
|
||||||
|
body = self.body_html_format.format(_("Ticket basic info"), basic_body)
|
||||||
return body
|
return body
|
||||||
|
|
||||||
def _construct_meta_body(self):
|
def _construct_meta_body(self):
|
||||||
|
@ -102,21 +110,11 @@ class BaseHandler(object):
|
||||||
return body
|
return body
|
||||||
|
|
||||||
def _base_construct_meta_body_of_open(self):
|
def _base_construct_meta_body_of_open(self):
|
||||||
open_body = '''
|
meta_body_of_open = getattr(self, '_construct_meta_body_of_open', lambda: 'No')()
|
||||||
{}:
|
body = self.body_html_format.format(_('Ticket applied info'), meta_body_of_open)
|
||||||
{}
|
return body
|
||||||
'''.format(
|
|
||||||
__('Ticket applied info'),
|
|
||||||
getattr(self, '_construct_meta_body_of_open', lambda: 'No')()
|
|
||||||
)
|
|
||||||
return open_body
|
|
||||||
|
|
||||||
def _base_construct_meta_body_of_approve(self):
|
def _base_construct_meta_body_of_approve(self):
|
||||||
approve_body = '''
|
meta_body_of_approve = getattr(self, '_construct_meta_body_of_approve', lambda: 'No')()
|
||||||
{}:
|
body = self.body_html_format.format(_('Ticket approved info'), meta_body_of_approve)
|
||||||
{}
|
return body
|
||||||
'''.format(
|
|
||||||
__('Ticket approved info'),
|
|
||||||
getattr(self, '_construct_meta_body_of_approve', lambda: 'No')()
|
|
||||||
)
|
|
||||||
return approve_body
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from django.utils.translation import ugettext as __
|
from django.utils.translation import ugettext as _
|
||||||
from .base import BaseHandler
|
from .base import BaseHandler
|
||||||
|
|
||||||
|
|
||||||
|
@ -13,8 +13,8 @@ class Handler(BaseHandler):
|
||||||
{}: {},
|
{}: {},
|
||||||
{}: {}
|
{}: {}
|
||||||
'''.format(
|
'''.format(
|
||||||
__("Applied login IP"), apply_login_ip,
|
_("Applied login IP"), apply_login_ip,
|
||||||
__("Applied login city"), apply_login_city,
|
_("Applied login city"), apply_login_city,
|
||||||
__("Applied login datetime"), apply_login_datetime,
|
_("Applied login datetime"), apply_login_datetime,
|
||||||
)
|
)
|
||||||
return applied_body
|
return applied_body
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
#
|
#
|
||||||
from django.dispatch import receiver
|
from django.dispatch import receiver
|
||||||
from django.db.models.signals import m2m_changed
|
|
||||||
|
|
||||||
from common.utils import get_logger
|
from common.utils import get_logger
|
||||||
from tickets.models import Ticket
|
from tickets.models import Ticket
|
||||||
from tickets.utils import send_ticket_applied_mail_to_assignees
|
|
||||||
from ..signals import post_change_ticket_action
|
from ..signals import post_change_ticket_action
|
||||||
|
|
||||||
|
|
||||||
|
@ -15,19 +13,3 @@ logger = get_logger(__name__)
|
||||||
@receiver(post_change_ticket_action, sender=Ticket)
|
@receiver(post_change_ticket_action, sender=Ticket)
|
||||||
def on_post_change_ticket_action(sender, ticket, action, **kwargs):
|
def on_post_change_ticket_action(sender, ticket, action, **kwargs):
|
||||||
ticket.handler.dispatch(action)
|
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)
|
|
||||||
|
|
||||||
|
|
|
@ -11,10 +11,10 @@ from . import const
|
||||||
logger = get_logger(__file__)
|
logger = get_logger(__file__)
|
||||||
|
|
||||||
|
|
||||||
def send_ticket_applied_mail_to_assignees(ticket, assignees):
|
def send_ticket_applied_mail_to_assignees(ticket):
|
||||||
if not assignees:
|
if not ticket.assignees:
|
||||||
logger.debug("Not found assignees, ticket: {}({}), assignees: {}".format(
|
logger.debug("Not found assignees, ticket: {}({}), assignees: {}".format(
|
||||||
ticket, str(ticket.id), assignees)
|
ticket, str(ticket.id), ticket.assignees)
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -22,25 +22,22 @@ def send_ticket_applied_mail_to_assignees(ticket, assignees):
|
||||||
ticket_detail_url = urljoin(
|
ticket_detail_url = urljoin(
|
||||||
settings.SITE_URL, const.TICKET_DETAIL_URL.format(id=str(ticket.id))
|
settings.SITE_URL, const.TICKET_DETAIL_URL.format(id=str(ticket.id))
|
||||||
)
|
)
|
||||||
message = _(
|
message = """
|
||||||
"""<div>
|
<div>
|
||||||
<p>Your has a new ticket</p>
|
<p>{title} <a href={ticket_detail_url}>{ticket_detail_url_description}</a></p>
|
||||||
<div>
|
<div>
|
||||||
<b>Ticket:</b>
|
{body}
|
||||||
<br/>
|
|
||||||
{body}
|
|
||||||
<br/>
|
|
||||||
<a href={ticket_detail_url}>click here to review</a>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
""".format(
|
""".format(
|
||||||
|
title=_('Your has a new ticket, from applicant - {}').format(str(ticket.applicant)),
|
||||||
|
ticket_detail_url=ticket_detail_url,
|
||||||
|
ticket_detail_url_description=_('click here to review'),
|
||||||
body=ticket.body.replace('\n', '<br/>'),
|
body=ticket.body.replace('\n', '<br/>'),
|
||||||
ticket_detail_url=ticket_detail_url
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
if settings.DEBUG:
|
if settings.DEBUG:
|
||||||
logger.debug(message)
|
logger.debug(message)
|
||||||
recipient_list = [assignee.email for assignee in assignees]
|
recipient_list = [assignee.email for assignee in ticket.assignees.all()]
|
||||||
send_mail_async.delay(subject, message, recipient_list, html_message=message)
|
send_mail_async.delay(subject, message, recipient_list, html_message=message)
|
||||||
|
|
||||||
|
|
||||||
|
@ -48,22 +45,18 @@ def send_ticket_processed_mail_to_applicant(ticket):
|
||||||
if not ticket.applicant:
|
if not ticket.applicant:
|
||||||
logger.error("Not found applicant: {}({})".format(ticket.title, ticket.id))
|
logger.error("Not found applicant: {}({})".format(ticket.title, ticket.id))
|
||||||
return
|
return
|
||||||
subject = _('Ticket has processed: {} ({})').format(ticket.title, ticket.get_type_display())
|
subject = _('Ticket has processed: {} ({})').format(ticket.title, ticket.processor_display)
|
||||||
message = _(
|
message = """
|
||||||
"""
|
|
||||||
<div>
|
<div>
|
||||||
<p>Your ticket has been processed</p>
|
<p>{title}</p>
|
||||||
<div>
|
<div>
|
||||||
<b>Ticket:</b>
|
{body}
|
||||||
<br/>
|
|
||||||
{body}
|
|
||||||
<br/>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
""".format(
|
""".format(
|
||||||
|
title=_('Your ticket has been ({}) processed').format(ticket.processor_display),
|
||||||
body=ticket.body.replace('\n', '<br/>'),
|
body=ticket.body.replace('\n', '<br/>'),
|
||||||
)
|
)
|
||||||
)
|
|
||||||
if settings.DEBUG:
|
if settings.DEBUG:
|
||||||
logger.debug(message)
|
logger.debug(message)
|
||||||
recipient_list = [ticket.applicant.email]
|
recipient_list = [ticket.applicant.email]
|
||||||
|
|
Loading…
Reference in New Issue