1.1 --- a/imiptools/handlers/scheduling/freebusy.py Fri Apr 22 20:30:51 2016 +0200
1.2 +++ b/imiptools/handlers/scheduling/freebusy.py Fri Apr 22 20:33:51 2016 +0200
1.3 @@ -34,6 +34,8 @@
1.4 free/busy records will be used.
1.5 """
1.6
1.7 + _ = handler.get_translator()
1.8 +
1.9 # If newer than any old version, discard old details from the
1.10 # free/busy record and check for suitability.
1.11
1.12 @@ -48,7 +50,7 @@
1.13 scheduled = handler.can_schedule(freebusy, periods)
1.14 scheduled = scheduled and handler.can_schedule(offers, periods)
1.15
1.16 - return scheduled and "ACCEPTED" or "DECLINED"
1.17 + return standard_responses(handler, scheduled and "ACCEPTED" or "DECLINED")
1.18
1.19 def schedule_corrected_in_freebusy(handler, args):
1.20
1.21 @@ -58,6 +60,8 @@
1.22 returning an indication of the kind of response to be returned.
1.23 """
1.24
1.25 + _ = handler.get_translator()
1.26 +
1.27 obj = handler.obj.copy()
1.28
1.29 # Check any constraints on the request.
1.30 @@ -73,17 +77,19 @@
1.31 # With a valid request, determine whether the event can be scheduled.
1.32
1.33 scheduled = schedule_in_freebusy(handler, args)
1.34 + response, description = scheduled or ("DECLINED", None)
1.35
1.36 # Restore the original object if it was corrected but could not be
1.37 # scheduled.
1.38
1.39 - if scheduled == "DECLINED" and corrected:
1.40 + if response == "DECLINED" and corrected:
1.41 handler.set_object(obj)
1.42
1.43 # Where the corrected object can be scheduled, issue a counter
1.44 # request.
1.45
1.46 - return scheduled == "ACCEPTED" and (corrected and "COUNTER" or "ACCEPTED") or "DECLINED"
1.47 + response = response == "ACCEPTED" and (corrected and "COUNTER" or "ACCEPTED") or "DECLINED"
1.48 + return standard_responses(handler, response)
1.49
1.50 def schedule_next_available_in_freebusy(handler, args):
1.51
1.52 @@ -95,9 +101,12 @@
1.53 of response to be returned.
1.54 """
1.55
1.56 - scheduled = schedule_corrected_in_freebusy(handler, args)
1.57 + _ = handler.get_translator()
1.58
1.59 - if scheduled in ("ACCEPTED", "COUNTER"):
1.60 + scheduled = schedule_corrected_in_freebusy(handler, args)
1.61 + response, description = scheduled or ("DECLINED", None)
1.62 +
1.63 + if response in ("ACCEPTED", "COUNTER"):
1.64 return scheduled
1.65
1.66 # There should already be free/busy information for the user.
1.67 @@ -191,7 +200,7 @@
1.68 # Where no period can be found, decline the invitation.
1.69
1.70 else:
1.71 - return "DECLINED"
1.72 + return "DECLINED", _("The recipient is unavailable in the requested period.")
1.73
1.74 # Use the found period to set the start of the next window to search.
1.75
1.76 @@ -205,11 +214,29 @@
1.77 # Check one last time, reverting the change if not scheduled.
1.78
1.79 scheduled = schedule_in_freebusy(handler, args, busy)
1.80 + response, description = scheduled or ("DECLINED", None)
1.81
1.82 - if scheduled == "DECLINED":
1.83 + if response == "DECLINED":
1.84 handler.set_object(obj)
1.85
1.86 - return scheduled == "ACCEPTED" and (changed and "COUNTER" or "ACCEPTED") or "DECLINED"
1.87 + response = response == "ACCEPTED" and (changed and "COUNTER" or "ACCEPTED") or "DECLINED"
1.88 + return standard_responses(handler, response)
1.89 +
1.90 +def standard_responses(handler, response):
1.91 +
1.92 + """
1.93 + Using 'handler' to translate descriptions, return a tuple containing the
1.94 + 'response' and a suitable description.
1.95 + """
1.96 +
1.97 + _ = handler.get_translator()
1.98 +
1.99 + if response == "ACCEPTED":
1.100 + return response, _("The recipient has scheduled the requested period.")
1.101 + elif response == "COUNTER":
1.102 + return response, _("The recipient has suggested a different period.")
1.103 + else:
1.104 + return response, _("The recipient is unavailable in the requested period.")
1.105
1.106 # Registry of scheduling functions.
1.107