1.1 --- a/imiptools/data.py Thu May 12 23:15:18 2016 +0200
1.2 +++ b/imiptools/data.py Fri May 13 00:22:56 2016 +0200
1.3 @@ -973,22 +973,35 @@
1.4 """
1.5 Using the 'attendee_map', check the attributes for the given 'attendee'
1.6 provided as 'attendee_attr', following the delegation chain back to the
1.7 - delegator and forward again to yield the delegate identity. Return
1.8 - whether this identity is the given 'attendee', providing the delegator
1.9 - identity; otherwise return None.
1.10 + delegators and forward again to yield the delegate identities in each
1.11 + case. Pictorially...
1.12 +
1.13 + attendee -> DELEGATED-FROM -> delegator
1.14 + ? <- DELEGATED-TO <---
1.15 +
1.16 + Return whether 'attendee' was identified as a delegate by providing the
1.17 + identity of any delegators referencing the attendee.
1.18 """
1.19
1.20 + delegators = []
1.21 +
1.22 # The recipient should have a reference to the delegator.
1.23
1.24 delegated_from = attendee_attr and attendee_attr.get("DELEGATED-FROM")
1.25 - delegated_from = delegated_from and delegated_from[0]
1.26 - delegator = delegated_from and attendee_map.get(delegated_from)
1.27 + if delegated_from:
1.28 +
1.29 + # Examine all delegators.
1.30 +
1.31 + for delegator in delegated_from:
1.32 + delegator_attr = attendee_map.get(delegator)
1.33
1.34 - # The delegator should have a reference to the recipient.
1.35 + # The delegator should have a reference to the recipient.
1.36
1.37 - delegated_to = delegator and delegator.get("DELEGATED-TO")
1.38 - delegated_to = delegated_to and delegated_to[0]
1.39 - return delegated_to == attendee and delegated_from or None
1.40 + delegated_to = delegator_attr and delegator_attr.get("DELEGATED-TO")
1.41 + if delegated_to and attendee in delegated_to:
1.42 + delegators.append(delegator)
1.43 +
1.44 + return delegators
1.45
1.46 def get_periods(obj, tzid, end=None, inclusive=False):
1.47
2.1 --- a/imiptools/handlers/resource.py Thu May 12 23:15:18 2016 +0200
2.2 +++ b/imiptools/handlers/resource.py Fri May 13 00:22:56 2016 +0200
2.3 @@ -90,7 +90,7 @@
2.4 "Attempt to schedule the current object for the current user."
2.5
2.6 attendee_attr = uri_dict(self.obj.get_value_map("ATTENDEE"))[self.user]
2.7 - delegate = None
2.8 + delegates = None
2.9
2.10 # Attempt to schedule the event.
2.11
2.12 @@ -124,7 +124,7 @@
2.13 if scheduled == "ACCEPTED":
2.14 self.confirm_scheduling()
2.15
2.16 - # For delegated proposals, prepare a request to the delegate in
2.17 + # For delegated proposals, prepare a request to the delegates in
2.18 # addition to the usual response.
2.19
2.20 elif scheduled == "DELEGATED":
2.21 @@ -134,8 +134,7 @@
2.22 # The recipient will have indicated the delegate whose details
2.23 # will have been added to the object.
2.24
2.25 - delegated_to = attendee_attr["DELEGATED-TO"]
2.26 - delegate = delegated_to and delegated_to[0]
2.27 + delegates = attendee_attr["DELEGATED-TO"]
2.28
2.29 # For countered proposals, record the offer in the resource's
2.30 # free/busy collection.
2.31 @@ -169,21 +168,23 @@
2.32 self.update_sender(attendee_attr)
2.33 attendees = [(self.user, attendee_attr)]
2.34
2.35 - # Add the delegate if delegating (RFC 5546 being inconsistent here since
2.36 + # Add delegates if delegating (RFC 5546 being inconsistent here since
2.37 # it provides an example reply to the organiser without the delegate).
2.38
2.39 - if delegate:
2.40 - delegate_attr = uri_dict(self.obj.get_value_map("ATTENDEE"))[delegate]
2.41 - attendees.append((delegate, delegate_attr))
2.42 + if delegates:
2.43 + for delegate in delegates:
2.44 + delegate_attr = uri_dict(self.obj.get_value_map("ATTENDEE"))[delegate]
2.45 + attendees.append((delegate, delegate_attr))
2.46
2.47 # Reply to the delegator in addition to the organiser if replying to a
2.48 # delegation request.
2.49
2.50 - delegator = self.is_delegation()
2.51 - if delegator:
2.52 - delegator_attr = uri_dict(self.obj.get_value_map("ATTENDEE"))[delegator]
2.53 - attendees.append((delegator, delegator_attr))
2.54 - recipients.append(get_address(delegator))
2.55 + delegators = self.is_delegation()
2.56 + if delegators:
2.57 + for delegator in delegators:
2.58 + delegator_attr = uri_dict(self.obj.get_value_map("ATTENDEE"))[delegator]
2.59 + attendees.append((delegator, delegator_attr))
2.60 + recipients.append(get_address(delegator))
2.61
2.62 # Prepare the response for the organiser plus any delegator.
2.63
2.64 @@ -191,11 +192,11 @@
2.65 self.update_dtstamp()
2.66 self.add_result(method, recipients, self.object_to_part(method, self.obj))
2.67
2.68 - # If delegating, send a request to the delegate.
2.69 + # If delegating, send a request to the delegates.
2.70
2.71 - if delegate:
2.72 + if delegates:
2.73 method = "REQUEST"
2.74 - self.add_result(method, [get_address(delegate)], self.object_to_part(method, self.obj))
2.75 + self.add_result(method, map(get_address, delegates), self.object_to_part(method, self.obj))
2.76
2.77 def _cancel_for_attendee(self):
2.78