Commit e9675ba1 authored by Yusei Tahara's avatar Yusei Tahara

Support attachment_list.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@20989 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent b7f49893
...@@ -366,8 +366,7 @@ class EmailDocument(File, TextDocument): ...@@ -366,8 +366,7 @@ class EmailDocument(File, TextDocument):
security.declareProtected(Permissions.UseMailhostServices, 'send') security.declareProtected(Permissions.UseMailhostServices, 'send')
def send(self, from_url=None, to_url=None, reply_url=None, subject=None, def send(self, from_url=None, to_url=None, reply_url=None, subject=None,
body=None, body=None, attachment_format=None, attachment_list=None, download=False):
attachment_format=None, download=False):
""" """
Sends the current event content by email. If documents are Sends the current event content by email. If documents are
attached through the aggregate category, enclose them. attached through the aggregate category, enclose them.
...@@ -391,6 +390,10 @@ class EmailDocument(File, TextDocument): ...@@ -391,6 +390,10 @@ class EmailDocument(File, TextDocument):
use the text representation of the event use the text representation of the event
as body (UTF-8) as body (UTF-8)
attachment_list -- list of dictionary which contains raw data and
name and mimetype for attachment.
See NotificationTool.buildEmailMessage.
attachment_format - defines an option format attachment_format - defines an option format
to convet attachments to (ex. application/pdf) to convet attachments to (ex. application/pdf)
...@@ -449,7 +452,8 @@ class EmailDocument(File, TextDocument): ...@@ -449,7 +452,8 @@ class EmailDocument(File, TextDocument):
to_url_list.append(to_url) to_url_list.append(to_url)
# Attachments # Attachments
attachment_list = [] if attachment_list is None:
attachment_list = []
document_type_list = self.getPortalDocumentTypeList() document_type_list = self.getPortalDocumentTypeList()
for attachment in self.getAggregateValueList(): for attachment in self.getAggregateValueList():
mime_type = None mime_type = None
......
...@@ -102,7 +102,8 @@ class Event(EmailDocument, Movement): ...@@ -102,7 +102,8 @@ class Event(EmailDocument, Movement):
security.declareProtected(Permissions.UseMailhostServices, 'send') security.declareProtected(Permissions.UseMailhostServices, 'send')
def send(self, from_url=None, to_url=None, reply_url=None, subject=None, def send(self, from_url=None, to_url=None, reply_url=None, subject=None,
body=None, attachment_format=None, download=False, **kw): body=None, attachment_format=None, attachment_list=None,
download=False, **kw):
""" """
Make the send method overridable by typed based script Make the send method overridable by typed based script
so that special kinds of events can use a different gateway so that special kinds of events can use a different gateway
...@@ -115,8 +116,10 @@ class Event(EmailDocument, Movement): ...@@ -115,8 +116,10 @@ class Event(EmailDocument, Movement):
send_script = self._getTypeBasedMethod('send') send_script = self._getTypeBasedMethod('send')
if send_script is None: if send_script is None:
return Event.inheritedAttribute('send')( return Event.inheritedAttribute('send')(
self, from_url, to_url, reply_url, subject, body, attachment_format, download self, from_url, to_url, reply_url, subject, body, attachment_format,
attachment_list, download
) )
return send_script( return send_script(
from_url, to_url, reply_url, subject, body, attachment_format, download, **kw from_url, to_url, reply_url, subject, body, attachment_format, attachment_list,
download, **kw
) )
...@@ -221,7 +221,8 @@ class NotificationTool(BaseTool): ...@@ -221,7 +221,8 @@ class NotificationTool(BaseTool):
# high-level interface # high-level interface
security.declareProtected(Permissions.UseMailhostServices, 'sendMessage') security.declareProtected(Permissions.UseMailhostServices, 'sendMessage')
def sendMessage(self, sender=None, recipient=None, subject=None, def sendMessage(self, sender=None, recipient=None, subject=None,
message=None, attachment_document_list=None, message=None,
attachment_list=None, attachment_document_list=None,
notifier_list=None, priority_level=None, notifier_list=None, priority_level=None,
store_as_event=False, store_as_event=False,
message_text_format='text/plain', message_text_format='text/plain',
...@@ -243,6 +244,10 @@ class NotificationTool(BaseTool): ...@@ -243,6 +244,10 @@ class NotificationTool(BaseTool):
message -- the text of the message (already translated) message -- the text of the message (already translated)
attachment_list -- list of dictionary which contains raw data and
name and mimetype for attachment.
See buildEmailMessage.
attachment_document_list -- list of document (optional) attachment_document_list -- list of document (optional)
which will be attachment. which will be attachment.
...@@ -302,6 +307,8 @@ class NotificationTool(BaseTool): ...@@ -302,6 +307,8 @@ class NotificationTool(BaseTool):
low_level_kw['from_url'] = default_from_email low_level_kw['from_url'] = default_from_email
if not to_person_list: if not to_person_list:
low_level_kw['to_url'] = default_to_email low_level_kw['to_url'] = default_to_email
if attachment_list is not None:
low_level_kw['attachment_list'] = attachment_list
# Make event # Make event
available_notifier_list = self.getNotifierList() available_notifier_list = self.getNotifierList()
......
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