Email notification for task cancelling #22006
This commit is contained in:
parent
5586f4d32c
commit
19b501b5ca
|
@ -166,6 +166,10 @@ msgstr ""
|
|||
msgid "One of your tasks has been cancelled"
|
||||
msgstr ""
|
||||
|
||||
#: ../subscribers/document.py:480
|
||||
msgid "One of your tasks has been cancelled"
|
||||
msgstr ""
|
||||
|
||||
#: ../browser/ask_opinion.py:25
|
||||
msgid "Opinion application for version ${version}"
|
||||
msgstr ""
|
||||
|
|
|
@ -184,7 +184,7 @@ class CustomMenu(menu.WorkflowMenu):
|
|||
description = ''
|
||||
|
||||
if action['id'] in ('submit', 'ask_opinion', 'attribute',
|
||||
'to_process', 'refuse', 'send_by_email'):
|
||||
'to_process', 'refuse', 'send_by_email', 'cancel-attribution'):
|
||||
cssClass += " overlay-form-reload"
|
||||
|
||||
if action['id'] in ('send_with_docbow',):
|
||||
|
|
|
@ -454,6 +454,47 @@ def email_notification_of_refused_task(context, event):
|
|||
log.exception(e)
|
||||
|
||||
|
||||
def email_notification_of_canceled_subtask(context):
|
||||
document = None
|
||||
for obj in aq_chain(context):
|
||||
obj = aq_parent(obj)
|
||||
if IDmsDocument.providedBy(obj):
|
||||
document = obj
|
||||
break
|
||||
if not document:
|
||||
return
|
||||
absolute_url = document.absolute_url()
|
||||
|
||||
responsible = context.responsible[0]
|
||||
principal = api.user.get(responsible)
|
||||
if not principal:
|
||||
principal = api.group.get(responsible)
|
||||
recipient_email = principal.getProperty('email') if principal else None
|
||||
if recipient_email:
|
||||
|
||||
email_from = api.user.get_current().email or api.portal.get().getProperty(
|
||||
'email_from_address') or 'admin@localhost'
|
||||
|
||||
subject = '%s - %s' % (context.title, document.title)
|
||||
|
||||
body = translate(_('One of your tasks has been cancelled'), context=context.REQUEST) + \
|
||||
'\n\n' + \
|
||||
translate(_('Title: %s'), context=context.REQUEST) % context.title + \
|
||||
'\n\n' + \
|
||||
translate(_('Document: %s'), context=context.REQUEST) % document.title + \
|
||||
'\n\n' + \
|
||||
translate(_('Document Address: %s'), context=context.REQUEST) % document.absolute_url() + \
|
||||
'\n\n\n\n-- \n' + \
|
||||
translate(_('Sent by GED'))
|
||||
body = body.encode('utf-8')
|
||||
|
||||
try:
|
||||
context.MailHost.send(body, recipient_email, email_from, subject, charset='utf-8')
|
||||
except Exception as e:
|
||||
# do not abort transaction in case of email error
|
||||
log = logging.getLogger('pfwbged.policy')
|
||||
log.exception(e)
|
||||
|
||||
|
||||
@grok.subscribe(IDmsDocument, IObjectModifiedEvent)
|
||||
def log_some_history(context, event):
|
||||
|
|
Reference in New Issue