1.1 --- a/imiptools/handlers/scheduling/freebusy.py Fri May 13 15:41:38 2016 +0200
1.2 +++ b/imiptools/handlers/scheduling/freebusy.py Fri May 13 16:20:29 2016 +0200
1.3 @@ -30,11 +30,22 @@
1.4 free/busy schedule of a resource, returning an indication of the kind of
1.5 response to be returned.
1.6
1.7 + The 'args' are used to configure the behaviour of the function. If a number
1.8 + is indicated, it is taken to mean the number of concurrent events that can
1.9 + be scheduled at the same point in time, with the default being 1.
1.10 +
1.11 If 'freebusy' is specified, the given collection of busy periods will be
1.12 used to determine whether any conflicts occur. Otherwise, the current user's
1.13 free/busy records will be used.
1.14 """
1.15
1.16 + # Permit the indication that concurrent events may be scheduled.
1.17 +
1.18 + try:
1.19 + max_concurrent = int((args[1:] or ["1"])[0])
1.20 + except ValueError:
1.21 + max_concurrent = 1
1.22 +
1.23 # If newer than any old version, discard old details from the
1.24 # free/busy record and check for suitability.
1.25
1.26 @@ -46,8 +57,14 @@
1.27 # Check the periods against any scheduled events and against
1.28 # any outstanding offers.
1.29
1.30 - scheduled = handler.can_schedule(freebusy, periods)
1.31 - scheduled = scheduled and handler.can_schedule(offers, periods)
1.32 + if max_concurrent == 1:
1.33 + scheduled = handler.can_schedule(freebusy, periods)
1.34 + scheduled = scheduled and handler.can_schedule(offers, periods)
1.35 + else:
1.36 + conflicts = get_scheduling_conflicts(handler, freebusy, [handler.user])
1.37 + scheduled = conflicts[handler.user] < max_concurrent
1.38 + conflicts = get_scheduling_conflicts(handler, offers, [handler.user])
1.39 + scheduled = scheduled and conflicts[handler.user] < max_concurrent
1.40
1.41 return standard_responses(handler, scheduled and "ACCEPTED" or "DECLINED")
1.42
1.43 @@ -57,6 +74,10 @@
1.44 Attempt to schedule the current object of the given 'handler', correcting
1.45 specified datetimes according to the configuration of a resource,
1.46 returning an indication of the kind of response to be returned.
1.47 +
1.48 + The 'args' are used to configure the behaviour of the function. If a number
1.49 + is indicated, it is taken to mean the number of concurrent events that can
1.50 + be scheduled at the same point in time, with the default being 1.
1.51 """
1.52
1.53 obj = handler.obj.copy()
1.54 @@ -96,6 +117,10 @@
1.55 suggesting the next available period in the free/busy records if scheduling
1.56 cannot occur for the requested period, returning an indication of the kind
1.57 of response to be returned.
1.58 +
1.59 + The 'args' are used to configure the behaviour of the function. If a number
1.60 + is indicated, it is taken to mean the number of concurrent events that can
1.61 + be scheduled at the same point in time, with the default being 1.
1.62 """
1.63
1.64 _ = handler.get_translator()