1.1 --- a/imiptools/handlers/__init__.py Tue May 19 23:40:57 2015 +0200
1.2 +++ b/imiptools/handlers/__init__.py Wed May 20 13:41:23 2015 +0200
1.3 @@ -84,6 +84,9 @@
1.4 except OSError:
1.5 self.publisher = None
1.6
1.7 + def get_definitive_object(self, from_organiser):
1.8 + return from_organiser and self.obj or self.get_object()
1.9 +
1.10 def set_object(self, obj):
1.11 self.obj = obj
1.12 self.uid = self.obj.get_uid()
1.13 @@ -197,12 +200,18 @@
1.14
1.15 # Organisers employ a special transparency if not attending.
1.16
1.17 - if for_organiser or not attr or attr.get("PARTSTAT") != "DECLINED":
1.18 - self.update_freebusy(freebusy, periods, transp=(
1.19 - for_organiser and not (attr and attr.get("PARTSTAT")) and "ORG" or None))
1.20 + if self.is_participating(attr, for_organiser):
1.21 + self.update_freebusy(freebusy, periods,
1.22 + transp=self.get_transparency(attr, for_organiser))
1.23 else:
1.24 self.remove_from_freebusy(freebusy)
1.25
1.26 + def is_participating(self, attr, as_organiser=False):
1.27 + return as_organiser or not attr or attr.get("PARTSTAT") != "DECLINED"
1.28 +
1.29 + def get_transparency(self, attr, as_organiser=False):
1.30 + return as_organiser and not (attr and attr.get("PARTSTAT")) and "ORG" or None
1.31 +
1.32 # Convenience methods for updating stored free/busy information.
1.33
1.34 def update_freebusy_from_participant(self, participant_item, for_organiser):
1.35 @@ -215,6 +224,9 @@
1.36
1.37 participant, participant_attr = participant_item
1.38
1.39 + # A user does not store free/busy information for themself as another
1.40 + # party.
1.41 +
1.42 if participant == self.user:
1.43 return
1.44
1.45 @@ -223,7 +235,7 @@
1.46 # Obtain the stored object if the current object is not issued by the
1.47 # organiser.
1.48
1.49 - obj = for_organiser and self.obj or self.get_object()
1.50 + obj = self.get_definitive_object(for_organiser)
1.51 if not obj:
1.52 return
1.53