Commit 4a5fa825 authored by Sebastien Robin's avatar Sebastien Robin

erp5_calendar: allow to customize the list of periods (exceptions included)

parent 33f8dc6b
...@@ -38,18 +38,32 @@ class GroupCalendarAssignment(PresencePeriod): ...@@ -38,18 +38,32 @@ class GroupCalendarAssignment(PresencePeriod):
security = ClassSecurityInfo() security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation) security.declareObjectProtected(Permissions.AccessContentsInformation)
security.declareProtected(Permissions.AccessContentsInformation,
'getPeriodList')
def getPeriodList(self):
period_list = []
method = self._getTypeBasedMethod("getPeriodList")
if method is None:
group_calendar = self.getSpecialiseValue()
if group_calendar is not None:
period_list = group_calendar.objectValues(
portal_type=self.getPortalCalendarPeriodTypeList())
else:
period_list = method()
return period_list
def _getDatePeriodDataList(self): def _getDatePeriodDataList(self):
result = [] result = []
start_date = self.getStartDate() start_date = self.getStartDate()
stop_date = self.getStopDate() stop_date = self.getStopDate()
group_calendar = self.getSpecialiseValue() if not(None in (self.getDestinationUid(), start_date)):
if not(None in (self.getDestinationUid(), group_calendar, start_date, period_list = self.getPeriodList()
stop_date)): if len(period_list):
presence_period_list = group_calendar.objectValues( for period in period_list:
portal_type="Group Presence Period") for date_period_data in period._getDatePeriodDataList():
for presence_period in presence_period_list: if date_period_data['start_date'].greaterThanEqualTo(start_date):
for date_period_data in presence_period._getDatePeriodDataList(): if stop_date is None or date_period_data['stop_date'].lessThanEqualTo(
if date_period_data['start_date'].greaterThanEqualTo(start_date) and \ stop_date):
date_period_data['stop_date'].lessThanEqualTo(stop_date):
result.append(date_period_data) result.append(date_period_data)
return result return result
\ No newline at end of file
390 392
\ No newline at end of file \ 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