1.1 --- a/imiptools/editing.py Thu Jan 18 22:00:14 2018 +0100
1.2 +++ b/imiptools/editing.py Fri Jan 19 19:26:36 2018 +0100
1.3 @@ -1434,6 +1434,8 @@
1.4 active_periods = new + replaced + retained
1.5 active_non_rule = filter(lambda p: p.origin != "RRULE", active_periods)
1.6
1.7 + main_modified = get_main_period(modified)
1.8 +
1.9 # Modified replaced recurrences are used for incremental updates.
1.10
1.11 replaced_modified = select_recurrences(replaced, modified).values()
1.12 @@ -1442,11 +1444,6 @@
1.13
1.14 replaced_unmodified = subtract_recurrences(replaced, modified).values()
1.15
1.16 - # Determine any new replacement periods. These are edited periods that were
1.17 - # not previously replacements.
1.18 -
1.19 - replaced_new = filter(lambda p: p.new_replacement, replaced)
1.20 -
1.21 # Obtain the removed periods in terms of existing periods. These are used in
1.22 # incremental updates.
1.23
1.24 @@ -1516,23 +1513,33 @@
1.25 to_add = []
1.26
1.27 # Parent event changes cause redefinition of the entire event.
1.28 - # The event is defined in terms of new periods and exceptions for
1.29 - # removed periods or obsolete rule periods.
1.30 +
1.31 + # New, removed, reinstated periods cannot be expressed as counter-
1.32 + # proposals individually and so cause the entire event to be expressed
1.33 + # as a counter-proposal.
1.34
1.35 - if new or removed or is_changed or reinstated or replaced_new:
1.36 + # Main period changes can only be sensibly expressed as a counter-
1.37 + # proposal by expressing the entire event as such.
1.38 +
1.39 + if new or removed or is_changed or main_modified or reinstated or \
1.40 + reinstated_attendance:
1.41 +
1.42 + # The event is defined in terms of new periods and exceptions for
1.43 + # removed periods or obsolete rule periods.
1.44 +
1.45 to_set = active_non_rule
1.46 to_exclude = list(chain(cancelled, obsolete_rule, cancelled_main))
1.47 to_reschedule = []
1.48 all_unscheduled = []
1.49 all_rescheduled = []
1.50
1.51 - # Changed periods without new or removed periods are proposed as
1.52 + # Changed but not new, removed or reinstated periods are proposed as
1.53 # separate changes.
1.54
1.55 else:
1.56 to_set = []
1.57 to_exclude = []
1.58 - to_reschedule = replaced_modified
1.59 + to_reschedule = list(chain(replaced_modified, replaced_modified_attendance))
1.60 all_unscheduled = cancelled_unmodified
1.61 all_rescheduled = list(chain(replaced_unmodified, to_reschedule))
1.62