[gen] Removed the obsolete mail notification system.

This commit is contained in:
Gaetan Delannay 2014-10-28 17:48:54 +01:00
parent cc776dc2f0
commit 50544aaecf
5 changed files with 7 additions and 71 deletions

View file

@ -788,12 +788,4 @@ class ZopeGenerator(Generator):
# We need to generate a label for the message that will be shown
# in the confirm popup.
self.i18n('%s_%s_confirm'%(wfName, name),po.CONFIRM, nice=False)
if transition.notify:
# Appy will send a mail when this transition is triggered.
# So we need 2 i18n labels: one for the mail subject and one for
# the mail body.
self.i18n('%s_%s_mail_subject' % (wfName, name),
po.EMAIL_SUBJECT, nice=False)
self.i18n('%s_%s_mail_body' % (wfName, name),
po.EMAIL_BODY, nice=False)
# ------------------------------------------------------------------------------

View file

@ -116,48 +116,4 @@ def sendMail(config, to, subject, body, attachments=None, log=None):
if log: log('mail sending failed: %s' % str(e), type='error')
except socket.error, se:
if log: log('mail sending failed: %s' % str(se), type='error')
# ------------------------------------------------------------------------------
def sendNotification(obj, transition, transitionName, workflow):
'''Sends mail about p_transition named p_transitionName, that has been
triggered on p_obj that is controlled by p_workflow.'''
from appy.gen.descriptors import WorkflowDescriptor
wfName = WorkflowDescriptor.getWorkflowName(workflow.__class__)
zopeObj = obj.o
tool = zopeObj.getTool()
mailInfo = transition.notify(workflow, obj)
if not mailInfo[0]: return # Send a mail to nobody.
# mailInfo may be one of the following:
# (to,)
# (to, cc)
# (to, mailSubject, mailBody)
# (to, cc, mailSubject, mailBody)
# "to" and "cc" maybe simple strings (one simple string = one email
# address or one role) or sequences of strings.
# Determine mail subject and body.
if len(mailInfo) <= 2:
# The user didn't mention mail body and subject. We will use those
# defined from i18n labels.
wfHistory = zopeObj.getHistory()
labelPrefix = '%s_%s' % (wfName, transitionName)
tName = obj.translate(labelPrefix)
keys = {'siteUrl': tool.getPath('/').absolute_url(),
'siteTitle': tool.getAppName(),
'objectUrl': zopeObj.absolute_url(),
'objectTitle': zopeObj.Title(),
'transitionName': tName,
'transitionComment': wfHistory[0]['comments']}
mailSubject = obj.translate(labelPrefix + '_mail_subject', keys)
mailBody = obj.translate(labelPrefix + '_mail_body', keys)
else:
mailSubject = mailInfo[-1]
mailBody = mailInfo[-2]
# Determine "to" and "cc".
to = mailInfo[0]
cc = []
if (len(mailInfo) in (2,4)) and mailInfo[1]: cc = mailInfo[1]
if type(to) not in sequenceTypes: to = [to]
if type(cc) not in sequenceTypes: cc = [cc]
# Send the mail
sendMail(tool.appy(), to, mailSubject, mailBody)
# ------------------------------------------------------------------------------

View file

@ -23,9 +23,6 @@ fallbacks = {'en': 'en-us en-ca',
# Default values for i18n labels whose ids are not fixed.
CONFIG = "Configuration panel for product '%s'"
EMAIL_SUBJECT = '${siteTitle} - Action \\"${transitionName}\\" has been ' \
'performed on element entitled \\"${objectTitle}\\".'
EMAIL_BODY = 'You can consult this element at ${objectUrl}.'
CONFIRM = 'Are you sure ?'
# ------------------------------------------------------------------------------

View file

@ -939,7 +939,7 @@ class AbstractWrapper(object):
return self.o.translate(label, mapping, domain, language=language,
format=format)
def do(self, name, comment='', doAction=True, doNotify=True, doHistory=True,
def do(self, name, comment='', doAction=True, doHistory=True,
noSecurity=False):
'''Triggers on p_self a transition named p_name programmatically.'''
o = self.o
@ -948,7 +948,7 @@ class AbstractWrapper(object):
if not tr or (tr.__class__.__name__ != 'Transition'):
raise Exception('Transition "%s" not found.' % name)
return tr.trigger(name, o, wf, comment, doAction=doAction,
doNotify=doNotify, doHistory=doHistory, doSay=False,
doHistory=doHistory, doSay=False,
noSecurity=noSecurity)
def log(self, message, type='info'): return self.o.log(message, type)