1.1 --- a/imiptools/content.py Mon Feb 09 16:34:24 2015 +0100
1.2 +++ b/imiptools/content.py Mon Feb 09 20:11:02 2015 +0100
1.3 @@ -175,6 +175,27 @@
1.4 def update_freebusy(self, freebusy, attendee, periods):
1.5 return update_freebusy(freebusy, attendee, periods, self.obj.get_value("TRANSP"), self.uid, self.store)
1.6
1.7 + def update_freebusy_from_participant(self, user, participant_item, tzid):
1.8 +
1.9 + """
1.10 + For the given 'user', record the free/busy information for the
1.11 + 'participant_item' (a value plus attributes), using the 'tzid' to define
1.12 + period information.
1.13 + """
1.14 +
1.15 + participant, participant_attr = participant_item
1.16 +
1.17 + if participant != user:
1.18 + freebusy = self.store.get_freebusy_for_other(user, participant)
1.19 +
1.20 + if participant_attr.get("PARTSTAT") != "DECLINED":
1.21 + update_freebusy_for_other(freebusy, user, participant,
1.22 + self.obj.get_periods_for_freebusy(tzid),
1.23 + self.obj.get_value("TRANSP"),
1.24 + self.uid, self.store)
1.25 + else:
1.26 + self.remove_from_freebusy_for_other(freebusy, user, participant)
1.27 +
1.28 def update_freebusy_from_organiser(self, attendee, organiser_item, tzid=None):
1.29
1.30 """
1.31 @@ -182,34 +203,14 @@
1.32 'organiser_item' (a value plus attributes).
1.33 """
1.34
1.35 - organiser, organiser_attr = organiser_item
1.36 -
1.37 - if organiser != attendee:
1.38 - freebusy = self.store.get_freebusy_for_other(attendee, organiser)
1.39 -
1.40 - if organiser_attr.get("PARTSTAT") != "DECLINED":
1.41 - update_freebusy_for_other(freebusy, attendee, organiser,
1.42 - self.obj.get_periods_for_freebusy(tzid),
1.43 - self.obj.get_value("TRANSP"),
1.44 - self.uid, self.store)
1.45 - else:
1.46 - self.remove_from_freebusy_for_other(freebusy, attendee, organiser)
1.47 + self.update_freebusy_from_participant(attendee, organiser_item, tzid)
1.48
1.49 def update_freebusy_from_attendees(self, organiser, attendees, tzid=None):
1.50
1.51 "For the 'organiser', record free/busy information from 'attendees'."
1.52
1.53 - for attendee, attendee_attr in attendees.items():
1.54 - if organiser != attendee:
1.55 - freebusy = self.store.get_freebusy_for_other(organiser, attendee)
1.56 -
1.57 - if attendee_attr.get("PARTSTAT") != "DECLINED":
1.58 - update_freebusy_for_other(freebusy, organiser, attendee,
1.59 - self.obj.get_periods_for_freebusy(tzid),
1.60 - self.obj.get_value("TRANSP"),
1.61 - self.uid, self.store)
1.62 - else:
1.63 - self.remove_from_freebusy_for_other(freebusy, organiser, attendee)
1.64 + for attendee_item in attendees.items():
1.65 + self.update_freebusy_from_participant(organiser, attendee_item, tzid)
1.66
1.67 def can_schedule(self, freebusy, periods):
1.68 return can_schedule(freebusy, periods, self.uid)