1.1 --- a/imipweb/event.py Tue Sep 12 23:07:14 2017 +0200
1.2 +++ b/imipweb/event.py Wed Sep 13 00:11:22 2017 +0200
1.3 @@ -1035,6 +1035,43 @@
1.4 origin_name="recur-origin", replaced_name="recur-replaced",
1.5 tzid=self.get_tzid())
1.6
1.7 + def get_removed_periods(self, periods):
1.8 +
1.9 + """
1.10 + From the recurrence 'periods' and information provided in the request,
1.11 + return the remaining active periods, the periods to unschedule, and the
1.12 + periods to exclude, in a tuple of the form (active, unscheduled,
1.13 + excluded).
1.14 + """
1.15 +
1.16 + to_unschedule = set()
1.17 + to_exclude = set()
1.18 +
1.19 + # Get all periods that are not replaced.
1.20 +
1.21 + active_periods = get_active_periods(periods)
1.22 +
1.23 + for period in self.get_state("recur-remove", list):
1.24 + active_periods[period] -= 1
1.25 +
1.26 + if not self.can_edit_recurrence(period) and self.is_organiser():
1.27 + l = to_unschedule
1.28 + else:
1.29 + l = to_exclude
1.30 + l.add(period)
1.31 +
1.32 + # Determine whether some periods are both removed and added.
1.33 +
1.34 + remaining = []
1.35 + for period, n in active_periods.items():
1.36 + if n > 0:
1.37 + remaining.append(period)
1.38 +
1.39 + to_unschedule.difference_update(remaining)
1.40 + to_exclude.difference_update(remaining)
1.41 +
1.42 + return remaining, to_unschedule, to_exclude
1.43 +
1.44 def get_attendees_from_page(self):
1.45
1.46 """
1.47 @@ -1205,42 +1242,6 @@
1.48
1.49 return self.get_state("remove", list)
1.50
1.51 - def get_removed_periods(self, periods):
1.52 -
1.53 - """
1.54 - Return those from the recurrence 'periods' to remove upon updating an
1.55 - event along with those to exclude in a tuple of the form (unscheduled,
1.56 - excluded).
1.57 - """
1.58 -
1.59 - to_unschedule = set()
1.60 - to_exclude = set()
1.61 -
1.62 - # Get all periods that are not replaced.
1.63 -
1.64 - active_periods = get_active_periods(periods)
1.65 -
1.66 - for period in self.get_state("recur-remove", list):
1.67 - active_periods[period] -= 1
1.68 -
1.69 - if not self.can_edit_recurrence(period) and self.is_organiser():
1.70 - l = to_unschedule
1.71 - else:
1.72 - l = to_exclude
1.73 - l.add(period)
1.74 -
1.75 - # Determine whether some periods are both removed and added.
1.76 -
1.77 - remaining = []
1.78 - for period, n in active_periods.items():
1.79 - if n > 0:
1.80 - remaining.append(period)
1.81 -
1.82 - to_unschedule.difference_update(remaining)
1.83 - to_exclude.difference_update(remaining)
1.84 -
1.85 - return remaining, to_unschedule, to_exclude
1.86 -
1.87 # Full page output methods.
1.88
1.89 def show(self, path_info):