Commit 0674b2a1 authored by Sebastien Robin's avatar Sebastien Robin

ERP5/Calendars: define group type list for calendars, partial design change

Calendar Assignments are now handled in a separate module, update
code in consequence
parent 9cacc60b
......@@ -214,11 +214,7 @@ class Person(Node, LoginAccountProviderMixin, EncryptedPasswordMixin):
See SimulationTool.getAvailableTime
"""
assignment_list = self.contentValues(portal_type='Assignment')
calendar_uid_list = []
for assignment in assignment_list:
calendar_uid_list.extend(assignment.getCalendarUidList())
kw['node'] = [self.getUid()] + calendar_uid_list
kw['node'] = [self.getUid()]
portal_simulation = self.getPortalObject().portal_simulation
return portal_simulation.getAvailableTime(*args, **kw)
......@@ -231,11 +227,7 @@ class Person(Node, LoginAccountProviderMixin, EncryptedPasswordMixin):
See SimulationTool.getAvailableTimeSequence
"""
assignment_list = self.contentValues(portal_type='Assignment')
calendar_uid_list = []
for assignment in assignment_list:
calendar_uid_list.extend(assignment.getCalendarUidList())
kw['node'] = [self.getUid()] + calendar_uid_list
kw['node'] = [self.getUid()]
portal_simulation = self.getPortalObject().portal_simulation
return portal_simulation.getAvailableTimeSequence(*args, **kw)
......
......@@ -102,9 +102,9 @@ class PresencePeriod(Movement, PeriodicityMixin):
single destination.
"""
result = []
for from_date, to_date in self._getDatePeriodList():
result.append(self.asContext(self, start_date=to_date,
stop_date=from_date))
if self.getSource() != None or self.getDestination() != None:
for date_period_data in self._getDatePeriodDataList():
result.append(self.asContext(self, **date_period_data))
return result
def _getDatePeriodDataList(self):
......
......@@ -1444,6 +1444,14 @@ class ERP5Site(FolderMixIn, CMFSite, CacheCookieMixin):
"""
return self._getPortalGroupedTypeList('trade_model_path')
security.declareProtected(Permissions.AccessContentsInformation,
'getPortalCalendarTypeList')
def getPortalCalendarTypeList(self):
"""
Return calendar types.
"""
return self._getPortalGroupedTypeList('calendar')
security.declareProtected(Permissions.AccessContentsInformation,
'getPortalCalendarPeriodTypeList')
def getPortalCalendarPeriodTypeList(self):
......
......@@ -280,7 +280,7 @@ class TestCalendar(ERP5ReportTestCase):
leave_request = sequence.get('leave_request')
personal_leave_period = leave_request.newContent(
portal_type=self.leave_request_period_portal_type,
resource='calendar_period_type/type1',
resource_value=self.portal.service_module.consulting_service
)
sequence.edit(
personal_leave_period=personal_leave_period,
......@@ -461,7 +461,7 @@ class TestCalendar(ERP5ReportTestCase):
start_date = self.start_date
stop_date = self.stop_date
second_availability = int(stop_date) - int(start_date)
date_period_list = obj_to_check._getDatePeriodList()
date_period_list = obj_to_check._getDatePeriodDataList()
# Check 1 period
self.assertEqual(second_availability,
......@@ -480,7 +480,7 @@ class TestCalendar(ERP5ReportTestCase):
self.assertEqual(2 * second_availability,
person.getAvailableTime(
from_date=start_date,
to_date=date_period_list[1][1]))
to_date=date_period_list[1]['stop_date']))
# # Check all periods
# self.assertEqual(len(date_period_list) * second_availability,
# person.getAvailableTime())
......
......@@ -307,6 +307,7 @@ class ERP5TypeInformation(XMLObject,
# Movement Group
'movement_group',
# Calendar
'calendar',
'calendar_period',
# Project
'project',
......
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