1.1 --- a/imiptools/handlers/resource.py Wed Aug 12 22:40:50 2015 +0200
1.2 +++ b/imiptools/handlers/resource.py Fri Aug 14 00:44:53 2015 +0200
1.3 @@ -61,19 +61,41 @@
1.4 def _schedule_for_attendee(self):
1.5
1.6 """
1.7 - Schedule the current object for the current user.
1.8 + Attempt to schedule the current object for the current user.
1.9 """
1.10
1.11 - # Interpretation of periods can depend on the time zone.
1.12 + # Check any constraints on the request.
1.13 +
1.14 + try:
1.15 + check = self.check_object()
1.16 +
1.17 + # NOTE: Support countering by correcting any invalid values and
1.18 + # NOTE: attempting to schedule using the corrected values.
1.19
1.20 - tzid = self.get_tzid()
1.21 + if check:
1.22 + raise self.ValidityError
1.23 +
1.24 + # Refuse to schedule obviously invalid requests.
1.25 +
1.26 + except self.ValidityError:
1.27 + scheduled = False
1.28
1.29 - # If newer than any old version, discard old details from the
1.30 - # free/busy record and check for suitability.
1.31 + # With a valid request, determine whether the event can be scheduled.
1.32 +
1.33 + else:
1.34 + # Interpretation of periods can depend on the time zone.
1.35 +
1.36 + tzid = self.get_tzid()
1.37
1.38 - periods = self.obj.get_periods(tzid, self.get_window_end())
1.39 - freebusy = self.store.get_freebusy(self.user)
1.40 - scheduled = self.can_schedule(freebusy, periods)
1.41 + # If newer than any old version, discard old details from the
1.42 + # free/busy record and check for suitability.
1.43 +
1.44 + periods = self.obj.get_periods(tzid, self.get_window_end())
1.45 + freebusy = self.store.get_freebusy(self.user)
1.46 + scheduled = self.can_schedule(freebusy, periods)
1.47 +
1.48 + # NOTE: Support countering by finding the next available slot if
1.49 + # NOTE: the event cannot be scheduled.
1.50
1.51 # Update the participation of the resource in the object.
1.52