Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ekaterina
erp5
Commits
ee8facd0
Commit
ee8facd0
authored
Dec 20, 2013
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move Event_send logic of sending email in MailMessage_send.
We only want to send an email for mail message portal type
parent
822f2ba9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
177 additions
and
97 deletions
+177
-97
bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/Event_send.xml
...se/SkinTemplateItem/portal_skins/erp5_base/Event_send.xml
+4
-96
bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/MailMessage_send.xml
...nTemplateItem/portal_skins/erp5_base/MailMessage_send.xml
+172
-0
bt5/erp5_base/bt/revision
bt5/erp5_base/bt/revision
+1
-1
No files found.
bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/Event_send.xml
View file @
ee8facd0
...
@@ -50,102 +50,10 @@
...
@@ -50,102 +50,10 @@
</item>
</item>
<item>
<item>
<key>
<string>
_body
</string>
</key>
<key>
<string>
_body
</string>
</key>
<value>
<string>
from email.utils import formataddr\n
<value>
<string>
"""Event send does nothing by default, it has to be implemented for each kind\n
from email import message_from_string\n
of event, look at MailMessage_send for example.\n
portal = context.getPortalObject()\n
"""\n
\n
pass\n
if attachment_list is None:\n
attachment_list = []\n
use_activity = False\n
mail_message = None\n
to_url_list = []\n
\n
if not context.isTempDocument() and to_url is None:\n
use_activity = True\n
\n
if to_url is None:\n
if use_activity:\n
recipient = context.getDestinationValue()\n
to_url_list.append(formataddr((recipient.getTitle(), recipient.getDefaultEmailText())))\n
else:\n
to_email_list = []\n
for recipient in context.getDestinationValueList():\n
email = recipient.getDefaultEmailText()\n
if email:\n
to_email_list.append(email)\n
to_url_list.append(formataddr((recipient.getTitle(), recipient.getDefaultEmailText())))\n
else:\n
raise ValueError("One email must be set to %s" % recipient.getRelativeUrl())\n
else:\n
to_url_list.append(to_url)\n
\n
if download or not use_activity:\n
for to_url in to_url_list:\n
body = body or context.getTextContent()\n
subject = subject or context.getTitle()\n
\n
# From\n
if from_url is None:\n
sender = context.getSourceValue()\n
from_url = formataddr((sender.getTitle(), sender.getDefaultEmailText()))\n
\n
# Return-Path\n
if reply_url is None:\n
reply_url = portal.portal_preferences.getPreferredEventSenderEmail()\n
additional_headers = None\n
if reply_url:\n
additional_headers = {\'Return-Path\':reply_url}\n
\n
# Attachments\n
document_type_list = list(context.getPortalEmbeddedDocumentTypeList()) + list(context.getPortalDocumentTypeList())\n
embedded_file_list = context.getAggregateValueList(portal_type=document_type_list)\n
\n
content_type = context.getContentType()\n
\n
mail_message = context.Base_createMailMessageAsString(from_url, \n
to_url,\n
subject,\n
body,\n
content_type,\n
attachment_list=attachment_list,\n
embedded_file_list=embedded_file_list)\n
\n
if len(embedded_file_list):\n
# do not store aggregated documents in Email document\n
# to avoid duplicate data\n
tmp_mail_message = context.Base_createMailMessageAsString(from_url,\n
to_url,\n
subject,\n
body,\n
content_type,\n
attachment_list=attachment_list)\n
context.setData(tmp_mail_message)\n
else:\n
context.setData(mail_message)\n
if not use_activity:\n
context.activate(activity=\'SQLQueue\').sendMailHostMessage(mail_message)\n
\n
if use_activity:\n
destination_list = context.getDestinationValueList()\n
path_list = [x.getPath() for x in destination_list]\n
uid_list = [x.getUid() for x in destination_list]\n
method_kw = dict(event_relative_url=context.getRelativeUrl(),\n
from_url=from_url,\n
attachment_list=attachment_list)\n
context.activate(\n
after_path_and_method_id=(path_list, \n
(\'immediateReindexObject\', \'recursiveImmediateReindexObject\'))).Event_sendByActivity(\n
uid_list=uid_list,\n
method_kw=method_kw, **kw)\n
\n
# Transit event workflow\n
if context.getTypeInfo() is not None:\n
for transition_id in \'plan\', \'order\', \'start\':\n
if portal.portal_workflow.isTransitionPossible(context, transition_id):\n
getattr(context, transition_id)()\n
\n
if download:\n
return mail_message\n
</string>
</value>
</string>
</value>
</item>
</item>
<item>
<item>
...
...
bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/MailMessage_send.xml
0 → 100644
View file @
ee8facd0
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"PythonScript"
module=
"Products.PythonScripts.PythonScript"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
Script_magic
</string>
</key>
<value>
<int>
3
</int>
</value>
</item>
<item>
<key>
<string>
_bind_names
</string>
</key>
<value>
<object>
<klass>
<global
name=
"NameAssignments"
module=
"Shared.DC.Scripts.Bindings"
/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key>
<string>
_asgns
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
name_container
</string>
</key>
<value>
<string>
container
</string>
</value>
</item>
<item>
<key>
<string>
name_context
</string>
</key>
<value>
<string>
context
</string>
</value>
</item>
<item>
<key>
<string>
name_m_self
</string>
</key>
<value>
<string>
script
</string>
</value>
</item>
<item>
<key>
<string>
name_subpath
</string>
</key>
<value>
<string>
traverse_subpath
</string>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key>
<string>
_body
</string>
</key>
<value>
<string>
"""Send a mail message.\n
\n
This script is used by notification tool, that\'s why it is in erp5_base.\n
"""\n
\n
from email.utils import formataddr\n
portal = context.getPortalObject()\n
\n
if attachment_list is None:\n
attachment_list = []\n
use_activity = False\n
mail_message = None\n
to_url_list = []\n
\n
if not context.isTempDocument() and to_url is None:\n
use_activity = True\n
\n
if to_url is None:\n
for recipient in context.getDestinationValueList():\n
email = recipient.getDefaultEmailText()\n
if email:\n
to_url_list.append(formataddr((recipient.getTitle(), recipient.getDefaultEmailText())))\n
else:\n
# MailMessage portal type is supposed to have a constraint to report this\n
# to the user earlier\n
raise ValueError("One email must be set to %s" % recipient.getRelativeUrl())\n
else:\n
to_url_list.append(to_url)\n
\n
if download or not use_activity:\n
for to_url in to_url_list:\n
body = body or context.getTextContent()\n
subject = subject or context.getTitle()\n
\n
# From\n
if from_url is None:\n
sender = context.getSourceValue()\n
if sender is not None:\n
from_url = formataddr((sender.getTitle(), sender.getDefaultEmailText()))\n
else:\n
from_url = portal.portal_preferences.getPreferredEventSenderEmail()\n
if not from_url:\n
raise ValueError(\'Preferred Event Sender Email not configured\')\n
\n
# Return-Path\n
if reply_url is None:\n
reply_url = portal.portal_preferences.getPreferredEventSenderEmail()\n
additional_headers = None\n
if reply_url:\n
additional_headers = {\'Return-Path\':reply_url}\n
\n
# Attachments\n
document_type_list = list(context.getPortalEmbeddedDocumentTypeList()) + list(context.getPortalDocumentTypeList())\n
embedded_file_list = context.getAggregateValueList(portal_type=document_type_list)\n
\n
content_type = context.getContentType()\n
\n
mail_message = context.Base_createMailMessageAsString(from_url, \n
to_url,\n
subject,\n
body,\n
content_type,\n
attachment_list=attachment_list,\n
embedded_file_list=embedded_file_list)\n
\n
if len(embedded_file_list):\n
# do not store aggregated documents in Email document\n
# to avoid duplicate data\n
tmp_mail_message = context.Base_createMailMessageAsString(from_url,\n
to_url,\n
subject,\n
body,\n
content_type,\n
attachment_list=attachment_list)\n
context.setData(tmp_mail_message)\n
else:\n
context.setData(mail_message)\n
if not use_activity:\n
context.activate(activity=\'SQLQueue\').sendMailHostMessage(mail_message)\n
\n
if use_activity:\n
destination_list = context.getDestinationValueList()\n
path_list = [x.getPath() for x in destination_list]\n
uid_list = [x.getUid() for x in destination_list]\n
method_kw = dict(event_relative_url=context.getRelativeUrl(),\n
from_url=from_url,\n
attachment_list=attachment_list)\n
context.activate(\n
after_path_and_method_id=(path_list, \n
# XXX Event_sendByActivity only applies to Mail Message at the moment.\n
# We should either renamted it to MailMessage_ or make this logic available to \n
# all kind of events.\n
(\'immediateReindexObject\', \'recursiveImmediateReindexObject\'))).Event_sendByActivity(\n
uid_list=uid_list,\n
method_kw=method_kw, **kw)\n
\n
if download:\n
return mail_message\n
</string>
</value>
</item>
<item>
<key>
<string>
_params
</string>
</key>
<value>
<string>
from_url=None, to_url=None, reply_url=None, subject=None, body=None, attachment_format=None, attachment_list=None, download=None, **kw
</string>
</value>
</item>
<item>
<key>
<string>
_proxy_roles
</string>
</key>
<value>
<tuple>
<string>
Manager
</string>
</tuple>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
MailMessage_send
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
bt5/erp5_base/bt/revision
View file @
ee8facd0
1054
1057
\ No newline at end of file
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment