Commit 01b17ab2 authored by Ivan Tyagov's avatar Ivan Tyagov

Make it possible that use can send a notification to an email or person about...

Make it possible that use can send a notification to an email or person about a post creation (disabled by default).

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@34544 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 29dd95fa
...@@ -56,6 +56,7 @@ ...@@ -56,6 +56,7 @@
<value> <string>"""\n <value> <string>"""\n
This script allows to create a new Discussion Post in context.\n This script allows to create a new Discussion Post in context.\n
"""\n """\n
from DateTime import DateTime\n
\n \n
portal = context.getPortalObject()\n portal = context.getPortalObject()\n
person = portal.ERP5Site_getAuthenticatedMemberPersonValue()\n person = portal.ERP5Site_getAuthenticatedMemberPersonValue()\n
...@@ -73,6 +74,35 @@ discussion_post = context.newContent(\n ...@@ -73,6 +74,35 @@ discussion_post = context.newContent(\n
# depending on security model Post can be submited for review\n # depending on security model Post can be submited for review\n
portal_status_message = "New post created."\n portal_status_message = "New post created."\n
discussion_post.release()\n discussion_post.release()\n
if send_notification_text not in (\'\', None):\n
# we can send notifications\n
email_list = []\n
notification_list = send_notification_text.split(\'\\r\\n\')\n
for notification in notification_list:\n
if \'@\' in notification:\n
# user specified an email\n
email_list.append(notification)\n
else:\n
# we can assume user wanted to specify Person\'s title\n
person_list = portal.portal_catalog(portal_type=\'Person\',\n
title=notification)\n
email_list.extend([x.getDefaultEmailText() for x in person_list])\n
email_from = portal.email_from_address\n
email_subject = "New forum post"\n
email_template = """\n
\n
New forum post has been created at this url:\n
\n
${url}""" \n
email_body = context.Base_translateString(email_template, mapping={\'url\':discussion_post.absolute_url()})\n
for email_to in email_list:\n
mail_headers = """\n
To: %s\n
From: %s\n
Subject: %s\n
Date: %s""" %(email_to, email_from, email_subject, DateTime().rfc822())\n
mail_source =\'%s\\n\\n%s\' %(mail_headers, email_body)\n
context.MailHost.send(mail_source)\n
\n \n
return context.Base_redirect(form_id,\n return context.Base_redirect(form_id,\n
keep_items = dict(portal_status_message=context.Base_translateString(portal_status_message)))\n keep_items = dict(portal_status_message=context.Base_translateString(portal_status_message)))\n
...@@ -86,13 +116,14 @@ return context.Base_redirect(form_id,\n ...@@ -86,13 +116,14 @@ return context.Base_redirect(form_id,\n
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>title, text_content, form_id, predecessor=None,**kw</string> </value> <value> <string>title, text_content, form_id, send_notification_text=None, predecessor=None,**kw</string> </value>
</item> </item>
<item> <item>
<key> <string>_proxy_roles</string> </key> <key> <string>_proxy_roles</string> </key>
<value> <value>
<tuple> <tuple>
<string>Assignor</string> <string>Assignor</string>
<string>Manager</string>
</tuple> </tuple>
</value> </value>
</item> </item>
...@@ -114,7 +145,7 @@ return context.Base_redirect(form_id,\n ...@@ -114,7 +145,7 @@ return context.Base_redirect(form_id,\n
<dictionary> <dictionary>
<item> <item>
<key> <string>co_argcount</string> </key> <key> <string>co_argcount</string> </key>
<value> <int>4</int> </value> <value> <int>5</int> </value>
</item> </item>
<item> <item>
<key> <string>co_varnames</string> </key> <key> <string>co_varnames</string> </key>
...@@ -123,8 +154,10 @@ return context.Base_redirect(form_id,\n ...@@ -123,8 +154,10 @@ return context.Base_redirect(form_id,\n
<string>title</string> <string>title</string>
<string>text_content</string> <string>text_content</string>
<string>form_id</string> <string>form_id</string>
<string>send_notification_text</string>
<string>predecessor</string> <string>predecessor</string>
<string>kw</string> <string>kw</string>
<string>DateTime</string>
<string>_getattr_</string> <string>_getattr_</string>
<string>context</string> <string>context</string>
<string>portal</string> <string>portal</string>
...@@ -133,6 +166,22 @@ return context.Base_redirect(form_id,\n ...@@ -133,6 +166,22 @@ return context.Base_redirect(form_id,\n
<string>language</string> <string>language</string>
<string>discussion_post</string> <string>discussion_post</string>
<string>portal_status_message</string> <string>portal_status_message</string>
<string>None</string>
<string>email_list</string>
<string>notification_list</string>
<string>_getiter_</string>
<string>notification</string>
<string>person_list</string>
<string>append</string>
<string>$append0</string>
<string>x</string>
<string>email_from</string>
<string>email_subject</string>
<string>email_template</string>
<string>email_body</string>
<string>email_to</string>
<string>mail_headers</string>
<string>mail_source</string>
<string>dict</string> <string>dict</string>
</tuple> </tuple>
</value> </value>
...@@ -147,6 +196,7 @@ return context.Base_redirect(form_id,\n ...@@ -147,6 +196,7 @@ return context.Base_redirect(form_id,\n
<value> <value>
<tuple> <tuple>
<none/> <none/>
<none/>
</tuple> </tuple>
</value> </value>
</item> </item>
......
...@@ -100,6 +100,7 @@ ...@@ -100,6 +100,7 @@
<value> <value>
<list> <list>
<string>your_title</string> <string>your_title</string>
<string>your_send_notification_text</string>
</list> </list>
</value> </value>
</item> </item>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>description</string>
<string>editable</string>
<string>enabled</string>
<string>title</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>your_send_notification_text</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>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>display_width</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</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>description</string> </key>
<value> <string>Use this text area to specify email addresses or persons\' titles which should receive notification about this post\'s creation. Each on a new line. Wildcards like \'%\' are supported.</string> </value>
</item>
<item>
<key> <string>display_width</string> </key>
<value> <int>40</int> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_text_area_field</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Base_viewFieldLibrary</string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string>Click to edit the target</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Notification list</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
42 43
\ No newline at end of file \ No newline at end of file
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