1.1 --- a/imiptools/client.py Sun Sep 06 02:17:33 2015 +0200
1.2 +++ b/imiptools/client.py Sun Sep 06 17:59:02 2015 +0200
1.3 @@ -339,7 +339,7 @@
1.4 """
1.5
1.6 attendees = uri_dict((obj or self.obj).get_value_map("ATTENDEE"))
1.7 - return attendees.get(user or self.user) or {}
1.8 + return attendees.get(user or self.user)
1.9
1.10 def is_participating(self, user, as_organiser=False, obj=None):
1.11
1.12 @@ -349,8 +349,11 @@
1.13 participating in the current object event.
1.14 """
1.15
1.16 + # Use any attendee property information for an organiser, not the
1.17 + # organiser property attributes.
1.18 +
1.19 attr = self.get_attendance(user, obj=obj)
1.20 - return as_organiser or not attr or attr.get("PARTSTAT") != "DECLINED"
1.21 + return as_organiser or attr is not None and not attr or attr and attr.get("PARTSTAT") != "DECLINED"
1.22
1.23 def get_overriding_transparency(self, user, as_organiser=False):
1.24
1.25 @@ -567,18 +570,32 @@
1.26 """
1.27
1.28 # Record in the free/busy details unless a non-participating attendee.
1.29 - # Use any attendee property information for an organiser, not the
1.30 - # organiser property attributes.
1.31 + # Remove periods for non-participating attendees.
1.32
1.33 if self.is_participating(user, for_organiser and not updating_other):
1.34 self.update_freebusy(freebusy, user, for_organiser)
1.35 else:
1.36 self.remove_from_freebusy(freebusy)
1.37
1.38 + def remove_freebusy_for_participant(self, freebusy, user, for_organiser=False,
1.39 + updating_other=False):
1.40 +
1.41 + """
1.42 + Remove details from the 'freebusy' collection for the given 'user',
1.43 + indicating whether the modification is 'for_organiser' (being done for
1.44 + the organiser of an event) or not, and whether it is 'updating_other'
1.45 + (meaning another user's details).
1.46 + """
1.47 +
1.48 + # Remove from the free/busy details if a specified attendee.
1.49 +
1.50 + if self.is_participating(user, for_organiser and not updating_other):
1.51 + self.remove_from_freebusy(freebusy)
1.52 +
1.53 # Convenience methods for updating stored free/busy information received
1.54 # from other users.
1.55
1.56 - def update_freebusy_from_participant(self, user, for_organiser):
1.57 + def update_freebusy_from_participant(self, user, for_organiser, fn=None):
1.58
1.59 """
1.60 For the current user, record the free/busy information for another
1.61 @@ -586,6 +603,8 @@
1.62 maintaining a separate record of their free/busy details.
1.63 """
1.64
1.65 + fn = fn or self.update_freebusy_for_participant
1.66 +
1.67 # A user does not store free/busy information for themself as another
1.68 # party.
1.69
1.70 @@ -593,7 +612,7 @@
1.71 return
1.72
1.73 freebusy = self.store.get_freebusy_for_other(self.user, user)
1.74 - self.update_freebusy_for_participant(freebusy, user, for_organiser, True)
1.75 + fn(freebusy, user, for_organiser, True)
1.76
1.77 # Tidy up any obsolete recurrences.
1.78
1.79 @@ -613,4 +632,17 @@
1.80 for attendee in attendees.keys():
1.81 self.update_freebusy_from_participant(attendee, False)
1.82
1.83 + def remove_freebusy_from_organiser(self, organiser):
1.84 +
1.85 + "For the current user, remove free/busy information from 'organiser'."
1.86 +
1.87 + self.update_freebusy_from_participant(organiser, True, self.remove_freebusy_for_participant)
1.88 +
1.89 + def remove_freebusy_from_attendees(self, attendees):
1.90 +
1.91 + "For the current user, remove free/busy information from 'attendees'."
1.92 +
1.93 + for attendee in attendees.keys():
1.94 + self.update_freebusy_from_participant(attendee, False, self.remove_freebusy_for_participant)
1.95 +
1.96 # vim: tabstop=4 expandtab shiftwidth=4