1.1 --- a/imiptools/period.py Thu Feb 12 22:35:16 2015 +0100
1.2 +++ b/imiptools/period.py Thu Feb 12 22:41:50 2015 +0100
1.3 @@ -25,16 +25,16 @@
1.4
1.5 # Time management with datetime strings in the UTC time zone.
1.6
1.7 -def can_schedule(freebusy, periods, uid):
1.8 +def can_schedule(freebusy, periods, uid, recurrenceid):
1.9
1.10 """
1.11 Return whether the 'freebusy' list can accommodate the given 'periods'
1.12 - employing the specified 'uid'.
1.13 + employing the specified 'uid' and 'recurrenceid'.
1.14 """
1.15
1.16 for conflict in have_conflict(freebusy, periods, True):
1.17 - start, end, found_uid, found_transp = conflict
1.18 - if found_uid != uid:
1.19 + start, end, found_uid, found_transp, found_recurrenceid = conflict
1.20 + if found_uid != uid and found_recurrenceid != recurrenceid:
1.21 return False
1.22
1.23 return True
1.24 @@ -64,11 +64,11 @@
1.25 def insert_period(freebusy, period):
1.26 insort_left(freebusy, period)
1.27
1.28 -def remove_period(freebusy, uid):
1.29 +def remove_period(freebusy, uid, recurrenceid=None):
1.30 i = 0
1.31 while i < len(freebusy):
1.32 t = freebusy[i]
1.33 - if len(t) >= 3 and t[2] == uid:
1.34 + if len(t) >= 5 and t[2] == uid and t[4] == recurrenceid:
1.35 del freebusy[i]
1.36 else:
1.37 i += 1
1.38 @@ -332,7 +332,7 @@
1.39 for point, active in slots:
1.40 for t in active:
1.41 if t and len(t) >= 2:
1.42 - start, end, uid, key = get_freebusy_details(t)
1.43 + start, end, uid, recurrenceid, key = get_freebusy_details(t)
1.44
1.45 try:
1.46 start_slot = points.index(start)
1.47 @@ -348,73 +348,74 @@
1.48
1.49 def get_freebusy_details(t):
1.50
1.51 - "Return a tuple of the form (start, end, uid, key) from 't'."
1.52 + "Return a tuple of the form (start, end, uid, recurrenceid, key) from 't'."
1.53
1.54 # Handle both complete free/busy details...
1.55
1.56 - if len(t) > 2:
1.57 - start, end, uid = t[:3]
1.58 - key = uid
1.59 + if len(t) > 4:
1.60 + start, end, uid, transp, recurrenceid = t[:5]
1.61 + key = uid, recurrenceid
1.62
1.63 # ...and published details without specific event details.
1.64
1.65 else:
1.66 start, end = t[:2]
1.67 uid = None
1.68 + recurrenceid = None
1.69 key = (start, end)
1.70
1.71 - return start, end, uid, key
1.72 + return start, end, uid, recurrenceid, key
1.73
1.74 -def remove_from_freebusy(freebusy, attendee, uid, store):
1.75 +def remove_from_freebusy(freebusy, attendee, uid, recurrenceid, store):
1.76
1.77 """
1.78 For the given 'attendee', remove periods from 'freebusy' that are associated
1.79 - with 'uid' in the 'store'.
1.80 + with 'uid' and 'recurrenceid' in the 'store'.
1.81 """
1.82
1.83 - remove_period(freebusy, uid)
1.84 + remove_period(freebusy, uid, recurrenceid)
1.85 store.set_freebusy(attendee, freebusy)
1.86
1.87 -def remove_from_freebusy_for_other(freebusy, user, other, uid, store):
1.88 +def remove_from_freebusy_for_other(freebusy, user, other, uid, recurrenceid, store):
1.89
1.90 """
1.91 For the given 'user', remove for the 'other' party periods from 'freebusy'
1.92 - that are associated with 'uid' in the 'store'.
1.93 + that are associated with 'uid' and 'recurrenceid' in the 'store'.
1.94 """
1.95
1.96 - remove_period(freebusy, uid)
1.97 + remove_period(freebusy, uid, recurrenceid)
1.98 store.set_freebusy_for_other(user, freebusy, other)
1.99
1.100 -def _update_freebusy(freebusy, periods, transp, uid):
1.101 +def _update_freebusy(freebusy, periods, transp, uid, recurrenceid):
1.102
1.103 """
1.104 Update the free/busy details with the given 'periods', 'transp' setting and
1.105 - 'uid'.
1.106 + 'uid' plus 'recurrenceid'.
1.107 """
1.108
1.109 - remove_period(freebusy, uid)
1.110 + remove_period(freebusy, uid, recurrenceid)
1.111
1.112 for start, end in periods:
1.113 - insert_period(freebusy, (start, end, uid, transp))
1.114 + insert_period(freebusy, (start, end, uid, transp, recurrenceid))
1.115
1.116 -def update_freebusy(freebusy, attendee, periods, transp, uid, store):
1.117 +def update_freebusy(freebusy, attendee, periods, transp, uid, recurrenceid, store):
1.118
1.119 """
1.120 For the given 'attendee', update the free/busy details with the given
1.121 - 'periods', 'transp' setting and 'uid' in the 'store'.
1.122 + 'periods', 'transp' setting and 'uid' plus 'recurrenceid' in the 'store'.
1.123 """
1.124
1.125 - _update_freebusy(freebusy, periods, transp, uid)
1.126 + _update_freebusy(freebusy, periods, transp, uid, recurrenceid)
1.127 store.set_freebusy(attendee, freebusy)
1.128
1.129 -def update_freebusy_for_other(freebusy, user, other, periods, transp, uid, store):
1.130 +def update_freebusy_for_other(freebusy, user, other, periods, transp, uid, recurrenceid, store):
1.131
1.132 """
1.133 For the given 'user', update the free/busy details of 'other' with the given
1.134 - 'periods', 'transp' setting and 'uid' in the 'store'.
1.135 + 'periods', 'transp' setting and 'uid' plus 'recurrenceid' in the 'store'.
1.136 """
1.137
1.138 - _update_freebusy(freebusy, periods, transp, uid)
1.139 + _update_freebusy(freebusy, periods, transp, uid, recurrenceid)
1.140 store.set_freebusy_for_other(user, freebusy, other)
1.141
1.142 # vim: tabstop=4 expandtab shiftwidth=4