Allow cancelling of information notices #22006
This commit is contained in:
parent
19b501b5ca
commit
511613505b
|
@ -448,6 +448,24 @@ class CustomMenu(menu.WorkflowMenu):
|
|||
'class': cssClass},
|
||||
'submenu': None,
|
||||
})
|
||||
|
||||
if IDmsDocument.providedBy(context) and \
|
||||
context.listFolderContents(contentFilter={
|
||||
'portal_type': 'information',
|
||||
'Creator': api.user.get_current().id,
|
||||
}):
|
||||
results.append({
|
||||
'title': _(u'Cancel information'),
|
||||
'description': '',
|
||||
'action': context.absolute_url() + '/@@cancel_information',
|
||||
'selected': False,
|
||||
'icon': None,
|
||||
'extra': {'id': 'plone-contentmenu-actions-cancel-information',
|
||||
'separator': None,
|
||||
'class': ''},
|
||||
'submenu': None,
|
||||
})
|
||||
|
||||
return results
|
||||
|
||||
def getWorkflowActionsForType(self, context, request, portal_type):
|
||||
|
|
|
@ -496,6 +496,46 @@ def email_notification_of_canceled_subtask(context):
|
|||
log.exception(e)
|
||||
|
||||
|
||||
def email_notification_of_canceled_information(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)
|
||||
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 document is not mentioned for your information anymore'), 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):
|
||||
for description in event.descriptions:
|
||||
|
|
Reference in New Issue