Commit fbd062eb authored by Nicolas Delaby's avatar Nicolas Delaby

Allow creation of events from any document (not only for Person or Organisation)

- Replace Entity_addEventDialog (kept for BBB) by Base_viewAddEventDialog
- Replace Entity_addEvent (kept for BBB) by Base_addEvent

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@43756 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 3589ad46
......@@ -32,7 +32,9 @@
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
<value>
<none/>
</value>
</item>
<item>
<key> <string>icon</string> </key>
......@@ -73,7 +75,7 @@
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string>string:${object_url}/Entity_addEventDialog</string> </value>
<value> <string>string:${object_url}/Base_viewAddEventDialog</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -32,7 +32,9 @@
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
<value>
<none/>
</value>
</item>
<item>
<key> <string>icon</string> </key>
......@@ -73,7 +75,7 @@
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string>string:${object_url}/Entity_addEventDialog</string> </value>
<value> <string>string:${object_url}/Base_viewAddEventDialog</string> </value>
</item>
</dictionary>
</pickle>
......
<?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>"""Generic script of Entity_addEvent\n
It creates new Event for any context which become follow_up of created Event.\n
\n
Connected user is source (outgoing direction)\n
for Organisations and Persons, context is destination(_section) (for outgoing direction)\n
\n
Follow_up is setted up only if context is not Entity.\n
\n
User is redirected on Event to fill in message.\n
"""\n
portal = context.getPortalObject()\n
portal_entity_type_list = portal.getPortalEntityTypeList()\n
\n
# Search current user ID\n
logged_in_user_value = portal.ERP5Site_getAuthenticatedMemberPersonValue()\n
start_date = DateTime()\n
\n
person = None\n
organisation = None\n
if logged_in_user_value is not None:\n
person = logged_in_user_value.getRelativeUrl()\n
organisation = logged_in_user_value.getSubordination()\n
\n
person_relative_url = None\n
organisation_relative_url = None\n
follow_up = None\n
if context.getPortalType() in portal_entity_type_list:\n
if context.getPortalType() == \'Person\':\n
person_relative_url = context.getRelativeUrl()\n
organisation_relative_url = context.getSubordination()\n
elif context.getPortalType() == \'Organisation\':\n
person_relative_url = None\n
organisation_relative_url = context.getRelativeUrl()\n
else:\n
follow_up = context.getRelativeUrl()\n
\n
if direction == \'out\':\n
source_url = person\n
source_section_url = organisation\n
destination_url = person_relative_url or organisation_relative_url\n
destination_section_url = organisation_relative_url\n
elif direction == \'in\':\n
source_url = person_relative_url or organisation_relative_url\n
source_section_url = organisation_relative_url\n
destination_url = person\n
destination_section_url = organisation\n
else:\n
raise NotImplementedError, \'The specified direction is not handled: %r\' % (direction,)\n
\n
event_kw = {}\n
event_kw[\'portal_type\'] = portal_type\n
event_kw[\'title\'] = title\n
event_kw[\'resource\'] = resource\n
event_kw[\'source\'] = source_url\n
event_kw[\'source_section\'] = source_section_url\n
event_kw[\'destination\'] = destination_url\n
event_kw[\'destination_section\'] = destination_section_url\n
event_kw[\'start_date\'] = start_date\n
event_kw[\'follow_up\'] = follow_up\n
\n
# Create event\n
module = portal.getDefaultModule(portal_type=portal_type)\n
event = module.newContent(**event_kw)\n
\n
message = portal.Base_translateString(\'New event created.\')\n
\n
event.Base_redirect(keep_items={\'portal_status_message\': message})\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>title, direction, portal_type, resource, **kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Base_addEvent</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ERP5Form" module="Products.ERP5Form.Form"/>
</pickle>
<pickle>
<dictionary>
<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/>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>action</string> </key>
<value> <string>Base_addEvent</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>edit_order</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>encoding</string> </key>
<value> <string>UTF-8</string> </value>
</item>
<item>
<key> <string>enctype</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>group_list</string> </key>
<value>
<list>
<string>left</string>
<string>right</string>
<string>center</string>
<string>bottom</string>
<string>hidden</string>
</list>
</value>
</item>
<item>
<key> <string>groups</string> </key>
<value>
<dictionary>
<item>
<key> <string>bottom</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>center</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>hidden</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>left</string> </key>
<value>
<list>
<string>your_title</string>
<string>your_portal_type</string>
<string>your_direction</string>
<string>your_resource</string>
</list>
</value>
</item>
<item>
<key> <string>right</string> </key>
<value>
<list/>
</value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Base_viewAddEventDialog</string> </value>
</item>
<item>
<key> <string>method</string> </key>
<value> <string>POST</string> </value>
</item>
<item>
<key> <string>name</string> </key>
<value> <string>Base_addEventDialog</string> </value>
</item>
<item>
<key> <string>pt</string> </key>
<value> <string>form_dialog</string> </value>
</item>
<item>
<key> <string>row_length</string> </key>
<value> <int>4</int> </value>
</item>
<item>
<key> <string>stored_encoding</string> </key>
<value> <string>UTF-8</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Create New Event</string> </value>
</item>
<item>
<key> <string>unicode_mode</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>update_action</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>update_action_title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>items</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>your_portal_type</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>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>items</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string>your_portal_type</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Base_viewCRMFieldLibrary</string> </value>
</item>
<item>
<key> <string>items</string> </key>
<value>
<list>
<tuple>
<string>Event</string>
<string>Event</string>
</tuple>
</list>
</value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string>Click to edit the target</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<tuple>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: [(here.Base_translateString(x), x) for x in here.getPortalEventTypeList() if here.Base_checkPermission(here.getDefaultModuleId(x), \'Add portal content\')]</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -50,57 +50,9 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>from DateTime import DateTime\n
from AccessControl import getSecurityManager\n
portal = context.getPortalObject()\n
\n
# Search current user ID\n
logged_in_user_value = portal.ERP5Site_getAuthenticatedMemberPersonValue()\n
source = None\n
person_subordination = None\n
if logged_in_user_value is not None:\n
source = logged_in_user_value.getRelativeUrl()\n
person_subordination = logged_in_user_value.getSubordination()\n
\n
start_date = DateTime()\n
destination = context.getRelativeUrl()\n
\n
if direction == \'out\':\n
source_url = source\n
source_section_url = person_subordination\n
destination_url = destination\n
if context.getPortalType() == \'Person\':\n
destination_section_url = context.getSubordination()\n
else:\n
destination_section_url = destination\n
elif direction == \'in\':\n
source_url = destination\n
if context.getPortalType() == \'Person\':\n
source_section_url = context.getRelativeUrl()\n
else:\n
source_section_url = destination\n
destination_url = source\n
destination_section_url = person_subordination\n
else:\n
raise NotImplementedError, \'The specified direction is not handled: %r\' % (direction,)\n
\n
event_kw = {}\n
event_kw[\'portal_type\'] = portal_type\n
event_kw[\'title\'] = title\n
event_kw[\'resource\'] = resource\n
event_kw[\'source\'] = source_url\n
event_kw[\'source_section\'] = source_section_url\n
event_kw[\'destination\'] = destination_url\n
event_kw[\'destination_section\'] = destination_section_url\n
event_kw[\'start_date\'] = start_date\n
\n
# Create event\n
module = portal.getDefaultModule(portal_type=portal_type)\n
event = module.newContent(**event_kw)\n
\n
message = portal.Base_translateString(\'New event created.\')\n
\n
event.Base_redirect(keep_items={\'portal_status_message\': message})\n
<value> <string>from Products.ERP5Type.Log import log\n
log(\'Obsoleted, please use Base_addEvent (with Base_viewAddEventDialog) instead\')\n
return context.Base_addEvent(title, direction, portal_type, resource, **kw)\n
</string> </value>
</item>
<item>
......
526
\ No newline at end of file
529
\ 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