1.1 --- a/imiptools/handlers/scheduling.py Wed Oct 28 11:56:06 2015 +0100
1.2 +++ b/imiptools/handlers/scheduling.py Wed Oct 28 12:52:31 2015 +0100
1.3 @@ -21,7 +21,8 @@
1.4
1.5 from imiptools.data import uri_values
1.6 from imiptools.dates import ValidityError, to_timezone
1.7 -from imiptools.period import get_common_periods, invert_freebusy, periods_from
1.8 +from imiptools.period import get_common_periods, invert_freebusy, \
1.9 + periods_from, remove_period, remove_periods
1.10
1.11 def schedule_in_freebusy(handler):
1.12
1.13 @@ -97,17 +98,27 @@
1.14 if scheduled in ("ACCEPTED", "COUNTER"):
1.15 return scheduled
1.16
1.17 - # Find free periods, update the object with the details.
1.18 # There should already be free/busy information for the user.
1.19
1.20 - all_free = [invert_freebusy(handler.store.get_freebusy(handler.user))]
1.21 + user_freebusy = handler.store.get_freebusy(handler.user)
1.22 + all_freebusy = [user_freebusy]
1.23 +
1.24 + # Subtract any periods from this event from the free/busy collections.
1.25 +
1.26 + event_periods = remove_period(user_freebusy, handler.uid, handler.recurrenceid)
1.27 +
1.28 + # Find busy periods for the other attendees.
1.29
1.30 for attendee in uri_values(handler.obj.get_values("ATTENDEE")):
1.31 if attendee != handler.user:
1.32 freebusy = handler.store.get_freebusy_for_other(handler.user, attendee)
1.33 if freebusy:
1.34 - all_free.append(invert_freebusy(freebusy))
1.35 + remove_periods(freebusy, event_periods)
1.36 + all_freebusy.append(freebusy)
1.37
1.38 + # Obtain free periods.
1.39 +
1.40 + all_free = [invert_freebusy(fb) for fb in all_freebusy]
1.41 free = get_common_periods(all_free)
1.42 permitted_values = handler.get_permitted_values()
1.43 periods = []