Commit 9bc5eb10 authored by Jérome Perrin's avatar Jérome Perrin

Update Calendar when Calendar Exception is Modifed

When the user add, modify or remove a Calendar Exception, related Group Calendar Assignments should be updated.

This is a continuation of !261  implementing also the suggestions from 1fa90034 (comment 17234)


@rafael @tb @seb @romain @georgios.dagkakis 

/reviewed-on !631
parents 1ce55c56 be060a1e
<workflow_chain>
<chain>
<type>Calendar Exception</type>
<workflow>group_calendar_interaction_workflow</workflow>
</chain>
<chain>
<type>Group Calendar</type>
<workflow>edit_workflow, group_calendar_interaction_workflow, group_calendar_workflow</workflow>
......
......@@ -27,15 +27,15 @@
<item>
<key> <string>after_script_name</string> </key>
<value>
<list>
<string>GroupCalendar_callUpdateRelatedAssignment</string>
</list>
<tuple/>
</value>
</item>
<item>
<key> <string>before_commit_script_name</string> </key>
<value>
<tuple/>
<list>
<string>callUpdateRelatedAssignment</string>
</list>
</value>
</item>
<item>
......@@ -57,6 +57,8 @@
<value>
<list>
<string>_set.*</string>
<string>manage_delObjects</string>
<string>deleteContent</string>
</list>
</value>
</item>
......@@ -67,9 +69,7 @@
<item>
<key> <string>portal_type_filter</string> </key>
<value>
<list>
<string>Group Calendar</string>
</list>
<none/>
</value>
</item>
<item>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="InteractionDefinition" module="Products.ERP5.Interaction"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>actbox_category</string> </key>
<value> <string>workflow</string> </value>
</item>
<item>
<key> <string>actbox_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>actbox_url</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>activate_script_name</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>after_script_name</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>before_commit_script_name</string> </key>
<value>
<list>
<string>GroupPresencePeriod_callUpdateRelatedAssignment</string>
</list>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>guard</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>group_presence_period_update_related_assignment</string> </value>
</item>
<item>
<key> <string>method_id</string> </key>
<value>
<list>
<string>_set.*</string>
</list>
</value>
</item>
<item>
<key> <string>once_per_transaction</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>portal_type_filter</string> </key>
<value>
<list>
<string>Group Presence Period</string>
</list>
</value>
</item>
<item>
<key> <string>portal_type_group_filter</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>script_name</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>temporary_document_disallowed</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>trigger_type</string> </key>
<value> <int>2</int> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
group_calendar = state_change["object"].getParentValue()
group_calendar.GroupCalendar_updateRelatedAssignment()
<?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>_params</string> </key>
<value> <string>state_change, **kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>GroupPresencePeriod_callUpdateRelatedAssignment</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
'''Re-calculate capacity when a calendar or an exception is modified.
Possible structures are:
Leave Request
Leave Request Period
Calendar Exception *
Presence Request
Presence Request Period
Calendar Exception *
Group Calendar *
Group Presence Period *
Calendar Exception *
This interaction can be triggered at all levels marked with *
For Leave and Presence Request Period, the action is simple, just reindex the period.
For Group Calendar, we reindex all calendar assignments using the group calendar.
'''
calendar = state_change["object"]
def updateLeaveOrPresenceRequestPeriod(calendar):
calendar.reindexObject()
def updateGroupCalendar(calendar):
calendar.GroupCalendar_updateRelatedAssignment()
action_mapping = {
'Leave Request Period': updateLeaveOrPresenceRequestPeriod,
'Presence Request Period': updateLeaveOrPresenceRequestPeriod,
'Group Calendar': updateGroupCalendar,
}
while calendar.getPortalType() not in action_mapping:
calendar = calendar.getParentValue()
action_mapping[calendar.getPortalType()](calendar)
......@@ -54,7 +54,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>GroupCalendar_callUpdateRelatedAssignment</string> </value>
<value> <string>callUpdateRelatedAssignment</string> </value>
</item>
</dictionary>
</pickle>
......
Calendar Exception | group_calendar_interaction_workflow
Group Calendar Assignment | edit_workflow
Group Calendar Assignment | group_calendar_workflow
Group Calendar | edit_workflow
......
This diff is collapsed.
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