1.1 --- a/imiptools/handlers/resource.py Mon Oct 26 17:19:39 2015 +0100
1.2 +++ b/imiptools/handlers/resource.py Mon Oct 26 19:07:51 2015 +0100
1.3 @@ -20,9 +20,9 @@
1.4 """
1.5
1.6 from imiptools.data import get_address, to_part, uri_dict
1.7 -from imiptools.dates import ValidityError
1.8 from imiptools.handlers import Handler
1.9 from imiptools.handlers.common import CommonFreebusy, CommonEvent
1.10 +from imiptools.handlers.scheduling import scheduling_functions
1.11
1.12 class ResourceHandler(CommonEvent, Handler):
1.13
1.14 @@ -162,36 +162,15 @@
1.15 invalid requests.
1.16 """
1.17
1.18 - # Check any constraints on the request.
1.19 -
1.20 - try:
1.21 - corrected = self.correct_object()
1.22 -
1.23 - # Refuse to schedule obviously invalid requests.
1.24 + scheduling_function = self.get_preferences().get("scheduling_function", "schedule_in_freebusy")
1.25 + fn = scheduling_functions.get(scheduling_function)
1.26
1.27 - except ValidityError:
1.28 - return None
1.29 -
1.30 - # With a valid request, determine whether the event can be scheduled.
1.31 -
1.32 - # If newer than any old version, discard old details from the
1.33 - # free/busy record and check for suitability.
1.34 + # NOTE: Should signal an error for incorrectly configured resources.
1.35
1.36 - periods = self.get_periods(self.obj)
1.37 -
1.38 - freebusy = self.store.get_freebusy(self.user)
1.39 - offers = self.store.get_freebusy_offers(self.user)
1.40 -
1.41 - # Check the periods against any scheduled events and against
1.42 - # any outstanding offers.
1.43 -
1.44 - scheduled = self.can_schedule(freebusy, periods)
1.45 - scheduled = scheduled and self.can_schedule(offers, periods)
1.46 -
1.47 - # Where the corrected object can be scheduled, issue a counter
1.48 - # request.
1.49 -
1.50 - return scheduled and (corrected and "COUNTER" or "ACCEPTED") or "DECLINED"
1.51 + if not fn:
1.52 + return "DECLINED"
1.53 + else:
1.54 + return fn(self)
1.55
1.56 class Event(ResourceHandler):
1.57