Commit 19ebbe92 authored by Gabriel Monnerat's avatar Gabriel Monnerat Committed by Jérome Perrin

erp5_calendar: Improve workflow interaction to update calendar if any sub-object is changed

The interaction should also be triggered if a Calendar Exception is changed.
parent 77e40e94
<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>
......@@ -67,9 +67,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>
group_calendar = state_change["object"]
while group_calendar.getPortalType() != "Group Calendar":
group_calendar = group_calendar.getParentValue()
group_calendar.GroupCalendar_updateRelatedAssignment()
......@@ -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
......
......@@ -874,6 +874,54 @@ class TestCalendar(ERP5ReportTestCase):
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_CalendarException(self):
organisation = self.portal.organisation_module.newContent(
portal_type='Organisation')
group_calendar = self.portal.group_calendar_module.newContent(
portal_type='Group Calendar')
group_calendar_period = group_calendar.newContent(
portal_type='Group Presence Period')
group_calendar_period.setStartDate('2008/01/01 08:00')
group_calendar_period.setStopDate('2008/01/01 18:00')
group_calendar_period.setResourceValue(
self.portal.portal_categories.calendar_period_type.type1)
group_calendar.confirm()
person1 = self.portal.person_module.newContent(
portal_type='Person',
title='Person 1',
career_reference='1',
subordination_value=organisation)
self.tic()
self.assertEqual([0], [x.total_quantity
for x in person1.getAvailableTimeSequence(
from_date=DateTime(2008, 1, 1).earliestTime(),
to_date=DateTime(2008, 1, 1).latestTime(),
day=1)])
assignment = self.portal.group_calendar_assignment_module.newContent(
specialise_value=group_calendar,
resource_value=self.portal.portal_categories.calendar_period_type.type1,
start_date=DateTime(2008, 1, 1).earliestTime(),
stop_date=DateTime(2008, 1, 1).latestTime(),
destination_value=person1)
assignment.confirm()
self.tic()
self.assertEqual([36000], [x.total_quantity
for x in person1.getAvailableTimeSequence(
from_date=DateTime(2008, 1, 1).earliestTime(),
to_date=DateTime(2008, 1, 1).latestTime(),
day=1)])
exception = group_calendar_period.newContent(
portal_type="Calendar Exception",
exception_date=DateTime(2008, 1, 1))
self.tic()
self.assertEqual([0], [x.total_quantity
for x in person1.getAvailableTimeSequence(
from_date=DateTime(2008, 1, 1).earliestTime(),
to_date=DateTime(2008, 1, 1).latestTime(),
day=1)])
def test_GroupCalendarConstraint(self):
group_calendar = self.portal.group_calendar_module.newContent(
portal_type='Group Calendar')
......
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