Commit 5dba4afe authored by Jérome Perrin's avatar Jérome Perrin

get rid of send_mail variable in new event workflow

We always generate the event upon start. User can pass another transition not to generate the event.
parent b66148b0
...@@ -74,8 +74,7 @@ if response_event_notification_message:\n ...@@ -74,8 +74,7 @@ if response_event_notification_message:\n
\n \n
message = portal.Base_translateString(\'Response Created.\')\n message = portal.Base_translateString(\'Response Created.\')\n
if response_workflow_action == \'send\':\n if response_workflow_action == \'send\':\n
# use doActionFor to initialise workflow variable\n response.start()\n
portal.portal_workflow.doActionFor(response, \'start_action\', send_mail=True)\n
return context.Base_redirect(form_id, keep_items={\'portal_status_message\': message})\n return context.Base_redirect(form_id, keep_items={\'portal_status_message\': message})\n
elif response_workflow_action == \'plan\':\n elif response_workflow_action == \'plan\':\n
response.plan()\n response.plan()\n
......
...@@ -96,7 +96,6 @@ ...@@ -96,7 +96,6 @@
<string>your_comment</string> <string>your_comment</string>
<string>your_workflow_action</string> <string>your_workflow_action</string>
<string>your_warning_message</string> <string>your_warning_message</string>
<string>your_send_mail</string>
</list> </list>
</value> </value>
</item> </item>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="CheckBoxField" module="Products.Formulator.StandardFields"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>your_send_mail</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>alternate_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>external_validator</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>alternate_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>external_validator</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>alternate_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>css_class</string> </key>
<value> <string>invisible</string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>When checked, this Mail Message will actually be sent to each recipient.</string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>external_validator</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Send Mail</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<tuple>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: here.getPortalType() in (\'Mail Message\', )</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -52,11 +52,15 @@ ...@@ -52,11 +52,15 @@
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>event = state_change[\'object\']\n <value> <string>event = state_change[\'object\']\n
portal = event.getPortalObject()\n portal = event.getPortalObject()\n
send_mail = portal.portal_workflow.getInfoFor(event, \'send_mail\')\n \n
if send_mail and event.getPortalType() in (\'Mail Message\', ):\n # FIXME: we should always call send here, and the type based method must\n
# decide what to do.\n
\n
if event.getPortalType() in (\'Mail Message\', ):\n
if event.getSource():\n if event.getSource():\n
event.send()\n event.send()\n
else:\n else:\n
# FIXME: this "email only" logic must be moved to MailMessage_send\n
sender_email = portal.portal_preferences.getPreferredEventSenderEmail()\n sender_email = portal.portal_preferences.getPreferredEventSenderEmail()\n
if not sender_email:\n if not sender_email:\n
raise NotImplementedError(\'Preferred Event Sender Email not configured\')\n raise NotImplementedError(\'Preferred Event Sender Email not configured\')\n
......
...@@ -93,30 +93,10 @@ ...@@ -93,30 +93,10 @@
<item> <item>
<key> <string>data</string> </key> <key> <string>data</string> </key>
<value> <value>
<dictionary> <dictionary/>
<item>
<key> <string>send_mail</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
</dictionary>
</value> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="Expression" module="Products.CMFCore.Expression"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string>kwargs/send_mail | nothing </string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData> </ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="VariableDefinition" module="Products.DCWorkflow.Variables"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>default_expr</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>default_value</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>for_catalog</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>for_status</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>send_mail</string> </value>
</item>
<item>
<key> <string>info_guard</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>update_always</string> </key>
<value> <int>0</int> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -1028,8 +1028,7 @@ class TestCRMMailSend(BaseTestCRM): ...@@ -1028,8 +1028,7 @@ class TestCRMMailSend(BaseTestCRM):
event.setDestination('person_module/recipient') event.setDestination('person_module/recipient')
event.setTitle('A Mail') event.setTitle('A Mail')
event.setTextContent(text_content) event.setTextContent(text_content)
self.portal.portal_workflow.doActionFor(event, 'start_action', self.portal.portal_workflow.doActionFor(event, 'start_action')
send_mail=1)
self.tic() self.tic()
last_message = self.portal.MailHost._last_message last_message = self.portal.MailHost._last_message
self.assertNotEquals((), last_message) self.assertNotEquals((), last_message)
...@@ -1055,8 +1054,7 @@ class TestCRMMailSend(BaseTestCRM): ...@@ -1055,8 +1054,7 @@ class TestCRMMailSend(BaseTestCRM):
event.setDestinationList(['person_module/recipient', 'person_module/me']) event.setDestinationList(['person_module/recipient', 'person_module/me'])
event.setTitle('A Mail') event.setTitle('A Mail')
event.setTextContent(text_content) event.setTextContent(text_content)
self.portal.portal_workflow.doActionFor(event, 'start_action', self.portal.portal_workflow.doActionFor(event, 'start_action')
send_mail=1)
self.tic() self.tic()
last_message_1, last_message_2 = self.portal.MailHost._message_list[-2:] last_message_1, last_message_2 = self.portal.MailHost._message_list[-2:]
self.assertNotEquals((), last_message_1) self.assertNotEquals((), last_message_1)
...@@ -1070,19 +1068,20 @@ class TestCRMMailSend(BaseTestCRM): ...@@ -1070,19 +1068,20 @@ class TestCRMMailSend(BaseTestCRM):
sorted([x[1] for x in (last_message_1, last_message_2)])) sorted([x[1] for x in (last_message_1, last_message_2)]))
def test_MailFromMailMessageEventNoSendMail(self): def test_MailFromMailMessageEventNoSendMail(self):
# passing start_action transition on event workflow will send an email to the # for Mail Message, passing start_action transition on event workflow will send an email to the
# person as destination, unless you don't check "send_mail" box in the # person as destination. To prevent this, one can use initial_stop_action to mark
# workflow dialog # the event receieved.
event = self.portal.event_module.newContent(portal_type='Mail Message') event = self.portal.event_module.newContent(portal_type='Mail Message')
event.setSource('person_module/me') event.setSource('person_module/me')
event.setDestination('person_module/recipient') event.setDestination('person_module/recipient')
event.setTitle('A Mail') event.setTitle('A Mail')
event.setTextContent('Mail Content') event.setTextContent('Mail Content')
self.portal.portal_workflow.doActionFor(event, 'start_action', self.portal.portal_workflow.doActionFor(event, 'initial_stop_action')
send_mail=1) self.assertEquals('stopped', event.getSimulationState())
self.tic() self.tic()
# no mail sent # no mail sent
last_message = self.portal.MailHost._last_message last_message = self.portal.MailHost._last_message
self.assertEquals((), last_message)
def test_MailFromOtherEvents(self): def test_MailFromOtherEvents(self):
# passing start_action transition on event workflow will not send an email # passing start_action transition on event workflow will not send an email
...@@ -1094,30 +1093,12 @@ class TestCRMMailSend(BaseTestCRM): ...@@ -1094,30 +1093,12 @@ class TestCRMMailSend(BaseTestCRM):
event.setSource('person_module/me') event.setSource('person_module/me')
event.setDestination('person_module/recipient') event.setDestination('person_module/recipient')
event.setTextContent('Hello !') event.setTextContent('Hello !')
self.portal.portal_workflow.doActionFor(event, 'start_action',
send_mail=1)
self.tic()
# this means no message have been set
self.assertEquals((), self.portal.MailHost._last_message)
def test_MailMarkPosted(self):
# start_action transition without send_mail variable on event
# simulation workflow will not send an email even if the portal
# type is a Mail Message
for ptype in [x for x in self.portal.getPortalEventTypeList() if x !=
'Acknowledgement']:
event = self.portal.event_module.newContent(portal_type=ptype)
event.setSource('person_module/me')
event.setDestination('person_module/recipient')
event.setTextContent('Hello !')
self.portal.portal_workflow.doActionFor(event, 'start_action') self.portal.portal_workflow.doActionFor(event, 'start_action')
self.tic() self.tic()
# this means no message have been set # this means no message have been set
self.assertEquals((), self.portal.MailHost._last_message) self.assertEquals((), self.portal.MailHost._last_message)
def test_MailMessageHTML(self): def test_MailMessageHTML(self):
# test sending a mail message edited as HTML (the default with FCKEditor), # test sending a mail message edited as HTML (the default with FCKEditor),
# then the mail should have HTML. # then the mail should have HTML.
...@@ -1127,8 +1108,7 @@ class TestCRMMailSend(BaseTestCRM): ...@@ -1127,8 +1108,7 @@ class TestCRMMailSend(BaseTestCRM):
event.setDestination('person_module/recipient') event.setDestination('person_module/recipient')
event.setContentType('text/html') event.setContentType('text/html')
event.setTextContent(text_content) event.setTextContent(text_content)
self.portal.portal_workflow.doActionFor(event, 'start_action', self.portal.portal_workflow.doActionFor(event, 'start_action')
send_mail=1)
self.tic() self.tic()
# content type is kept # content type is kept
self.assertEquals(event.getContentType(), 'text/html') self.assertEquals(event.getContentType(), 'text/html')
...@@ -1159,8 +1139,7 @@ class TestCRMMailSend(BaseTestCRM): ...@@ -1159,8 +1139,7 @@ class TestCRMMailSend(BaseTestCRM):
event.setDestination('person_module/recipient') event.setDestination('person_module/recipient')
event.setTitle('Héhé') event.setTitle('Héhé')
event.setTextContent('Hàhà') event.setTextContent('Hàhà')
self.portal.portal_workflow.doActionFor(event, 'start_action', self.portal.portal_workflow.doActionFor(event, 'start_action')
send_mail=1)
self.tic() self.tic()
last_message = self.portal.MailHost._last_message last_message = self.portal.MailHost._last_message
self.assertNotEquals((), last_message) self.assertNotEquals((), last_message)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment