Commit f98d2752 authored by Jérome Perrin's avatar Jérome Perrin

CRM: Introduce a script to choose the content type of response events

parent a178f661
......@@ -64,7 +64,7 @@ response = module.newContent(portal_type=response_event_portal_type,\n
start_date=response_event_start_date,\n
causality_value=context,\n
follow_up_list=context.getFollowUpList(),\n
content_type=context.getContentType())\n
content_type=response_event_content_type or context.getContentType())\n
\n
if response_event_notification_message:\n
response.Event_setTextContentFromNotificationMessage(\n
......@@ -87,7 +87,7 @@ else:\n
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>form_id=None, response_event_portal_type=None, response_event_resource=None, response_event_title=None, response_event_text_content=None, response_event_start_date=None, response_workflow_action=None, response_event_notification_message=None, **kw</string> </value>
<value> <string>form_id=None, response_event_portal_type=None, response_event_resource=None, response_event_title=None, response_event_text_content=None, response_event_start_date=None, response_workflow_action=None, response_event_notification_message=None, response_event_content_type=None, **kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......
<?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>"""Returns the default text format for response events.\n
\n
This script is here so that we can easily customized depending on the context event, ticket or user preferences.\n
"""\n
return context.getTextFormat()\\\n
or context.getPortalObject().portal_preferences.getPreferredTextFormat()\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Event_getPreferredResponseEventContentType</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -87,6 +87,7 @@
<string>your_response_event_portal_type</string>
<string>your_response_event_resource</string>
<string>your_response_event_start_date</string>
<string>your_response_event_content_type</string>
</list>
</value>
</item>
......
......@@ -13,6 +13,7 @@
<string>css_class</string>
<string>default</string>
<string>editable</string>
<string>text_editor</string>
<string>title</string>
</list>
</value>
......@@ -81,6 +82,12 @@
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>text_editor</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
......@@ -116,6 +123,10 @@
<key> <string>target</string> </key>
<value> <string>Click to edit the target</string> </value>
</item>
<item>
<key> <string>text_editor</string> </key>
<value> <string>text_area</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Message</string> </value>
......@@ -134,7 +145,20 @@
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>here/getReplyBody</string> </value>
<value> <string>python: context.getReplyBody(content_type=context.Event_getPreferredResponseEventContentType())</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: context.Base_getEditorFieldPreferredTextEditor(content_type=context.Event_getPreferredResponseEventContentType())</string> </value>
</item>
</dictionary>
</pickle>
......
691
\ No newline at end of file
694
\ No newline at end of file
......@@ -529,20 +529,22 @@ class EmailDocument(TextDocument):
# Methods which can be useful to prepare a reply by email to an event
security.declareProtected(Permissions.AccessContentsInformation, 'getReplyBody')
def getReplyBody(self):
def getReplyBody(self, content_type=None):
"""This is used in order to respond to a mail, this put a '> ' before each
line of the body.
"""
This is used in order to respond to a mail,
this put a '> ' before each line of the body
"""
if self.getContentType() == 'text/plain':
if not content_type:
content_type = self.getContentType()
if content_type == 'text/plain':
body = self.asText()
if body:
return '> ' + str(body).replace('\n', '\n> ')
elif self.getContentType() == 'text/html':
# XXX we add an empty <p> to be able to enter text before the quoted
# content in CKEditor
return '<p>&nbsp;</p><blockquote type="cite">\n%s\n</blockquote>' %\
self.asStrippedHTML()
elif content_type == 'text/html':
# XXX we add some empty <p> to be able to enter text before the quoted
# content in CKEditor.
return '''<p>&nbsp;</p><blockquote type="cite">
%s
</blockquote><p>&nbsp;</p>''' % self.asStrippedHTML()
return ''
security.declareProtected(Permissions.AccessContentsInformation, 'getReplySubject')
......
......@@ -50,19 +50,18 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>"""\n
Returns the preferred text editor and tries to take into \n
account a default content type if any.\n
<value> <string>"""Returns the preferred text editor and tries to take into account a default\n
content type if any.\n
The content type can also be passed, for example to use the editor in a dialog\n
that will create a document of this target content type.\n
"""\n
# By default, everthing related to EditorField is HTML\n
content_type = \'text/html\'\n
\n
# If this document provide a text format property, \n
# get the content type from the property\n
if getattr(context, \'getContentType\', None) is not None:\n
content_type = context.getContentType()\n
if not content_type:\n
content_type = \'text/html\'\n
if not content_type:\n
# By default, everthing related to EditorField is HTML\n
content_type = \'text/html\'\n
\n
# If this document has a content type we use this information\n
if getattr(context, \'getContentType\', None) is not None:\n
content_type = context.getContentType() or \'text/html\'\n
\n
# If this is not HTML, fallback to TextArea\n
if content_type != \'text/html\':\n
......@@ -74,7 +73,7 @@ return context.portal_preferences.getPreferredTextEditor() or \'text_area\'\n
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
<value> <string>content_type=None</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......
41155
\ No newline at end of file
41156
\ 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