Commit bb6f01ea authored by Yusei Tahara's avatar Yusei Tahara

Transit workflow state when event_workflow is installed.

Support default sender and recipient address.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@20984 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent b32b3ef1
...@@ -274,9 +274,6 @@ class NotificationTool(BaseTool): ...@@ -274,9 +274,6 @@ class NotificationTool(BaseTool):
if email_value is not None and email_value.asText(): if email_value is not None and email_value.asText():
from_person = sender from_person = sender
if from_person is None:
raise ValueError, 'the argument sender is not an appropriate value.'
# Find "To" Person list # Find "To" Person list
to_person_list = [] to_person_list = []
if recipient: if recipient:
...@@ -296,8 +293,15 @@ class NotificationTool(BaseTool): ...@@ -296,8 +293,15 @@ class NotificationTool(BaseTool):
raise AttributeError, "Default email address of %s is empty" % person.getRelativeUrl() raise AttributeError, "Default email address of %s is empty" % person.getRelativeUrl()
to_person_list.append(person) to_person_list.append(person)
# prepare low-level arguments if needed.
low_level_kw = {}
default_from_email = portal.email_from_address
default_to_email = getattr(portal, 'email_to_address',
default_from_email)
if from_person is None:
low_level_kw['from_url'] = default_from_email
if not to_person_list: if not to_person_list:
raise ValueError, 'the argument recipient is not an appropriate value.' low_level_kw['to_url'] = default_to_email
# Make event # Make event
available_notifier_list = self.getNotifierList() available_notifier_list = self.getNotifierList()
...@@ -323,11 +327,16 @@ class NotificationTool(BaseTool): ...@@ -323,11 +327,16 @@ class NotificationTool(BaseTool):
event.setTextContent(message) event.setTextContent(message)
event.setAggregateValueList(attachment_document_list) event.setAggregateValueList(attachment_document_list)
event_list.append(event) event_list.append(event)
portal_workflow = getToolByName(self, 'portal_workflow')
for event in event_list: for event in event_list:
event.plan() # transit workflow if event_workflow is available.
event.order() if ('event_workflow' in portal_workflow.getChainFor(event) and
event.start() callable(getattr(event, 'plan', None))):
event.send() event.plan()
event.order()
event.start()
event.send(**low_level_kw)
return return
# Future implemetation could consist in implementing # Future implemetation could consist in implementing
......
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