1.1 --- a/imiptools/handlers/person.py Thu Oct 30 23:44:37 2014 +0100
1.2 +++ b/imiptools/handlers/person.py Thu Oct 30 23:52:27 2014 +0100
1.3 @@ -20,7 +20,7 @@
1.4
1.5 def _record_and_deliver(self, objtype, from_organiser=True, queue=False):
1.6
1.7 - oa = self.require_organiser_and_attendees()
1.8 + oa = self.require_organiser_and_attendees(from_organiser)
1.9 if not oa:
1.10 return False
1.11
1.12 @@ -28,24 +28,47 @@
1.13
1.14 # Validate the organiser or attendee, ignoring spoofed requests.
1.15
1.16 - if not self.validate_identities(from_organiser and [organiser_item] or attendees):
1.17 + if not self.validate_identities(from_organiser and [organiser_item] or attendees.items()):
1.18 return False
1.19
1.20 # Process each attendee separately.
1.21
1.22 - for attendee, attendee_attr in attendees.items():
1.23 + if from_organiser:
1.24 + for attendee, attendee_attr in attendees.items():
1.25 +
1.26 + if not self.have_new_object(attendee, objtype):
1.27 + continue
1.28 +
1.29 + # Store the object and queue any request.
1.30
1.31 - if not self.have_new_object(attendee, objtype):
1.32 - continue
1.33 + self.store.set_event(attendee, self.uid, to_node(
1.34 + {objtype : [(self.details, {})]}
1.35 + ))
1.36
1.37 - # Store the object and queue any request.
1.38 + if queue:
1.39 + self.store.queue_request(attendee, self.uid)
1.40 +
1.41 + # As organiser, update attendance.
1.42
1.43 - self.store.set_event(attendee, self.uid, to_node(
1.44 - {objtype : [(self.details, {})]}
1.45 - ))
1.46 + else:
1.47 + obj = self.get_object(organiser, objtype)
1.48 +
1.49 + if obj and self.have_new_object(organiser, objtype, obj):
1.50 + attendee_map = self.get_value_map("ATTENDEE")
1.51 +
1.52 + for attendee, attendee_attr in attendees.items():
1.53 +
1.54 + # Update attendance in the loaded object.
1.55
1.56 - if queue:
1.57 - self.store.queue_request(attendee, self.uid)
1.58 + attendee_map[attendee] = attendee_attr
1.59 +
1.60 + # Set the new details and store the object.
1.61 +
1.62 + obj["ATTENDEE"] = attendee_map.items()
1.63 +
1.64 + self.store.set_event(organiser, self.uid, to_node(
1.65 + {objtype : [(obj, {})]}
1.66 + ))
1.67
1.68 return True
1.69