1.1 --- a/imiptools/client.py Wed May 20 13:41:23 2015 +0200
1.2 +++ b/imiptools/client.py Wed May 20 15:06:33 2015 +0200
1.3 @@ -19,7 +19,7 @@
1.4 this program. If not, see <http://www.gnu.org/licenses/>.
1.5 """
1.6
1.7 -from imiptools.data import get_uri, get_window_end, uri_dict, uri_items, uri_values
1.8 +from imiptools.data import get_address, get_uri, get_window_end, uri_dict, uri_items, uri_values
1.9 from imiptools.dates import get_default_timezone
1.10 from imiptools.profile import Preferences
1.11
1.12 @@ -66,18 +66,6 @@
1.13
1.14 return to_cancel
1.15
1.16 -def update_participation(obj, user, partstat):
1.17 -
1.18 - "Update the participation in 'obj' of 'user' with the given 'partstat'."
1.19 -
1.20 - existing_attendees = uri_dict(obj.get_value_map("ATTENDEE"))
1.21 -
1.22 - if partstat:
1.23 - if existing_attendees.has_key(user):
1.24 - existing_attendees[user]["PARTSTAT"] = partstat
1.25 - if existing_attendees[user].has_key("RSVP"):
1.26 - del existing_attendees[user]["RSVP"]
1.27 -
1.28 class Client:
1.29
1.30 "Common handler and manager methods."
1.31 @@ -119,4 +107,20 @@
1.32 prefs = self.get_preferences()
1.33 return prefs and prefs.get("freebusy_messages") == "notify" or False
1.34
1.35 + # Common operations on calendar data.
1.36 +
1.37 + def update_participation(self, obj, partstat):
1.38 +
1.39 + """
1.40 + Update the participation in 'obj' of the user with the given 'partstat'.
1.41 + """
1.42 +
1.43 + attendee_attr = uri_dict(obj.get_value_map("ATTENDEE")).get(self.user)
1.44 + attendee_attr["PARTSTAT"] = partstat
1.45 + if attendee_attr.has_key("RSVP"):
1.46 + del attendee_attr["RSVP"]
1.47 + if self.messenger and self.messenger.sender != get_address(self.user):
1.48 + attendee_attr["SENT-BY"] = get_uri(self.messenger.sender)
1.49 + return attendee_attr
1.50 +
1.51 # vim: tabstop=4 expandtab shiftwidth=4
2.1 --- a/imiptools/handlers/resource.py Wed May 20 13:41:23 2015 +0200
2.2 +++ b/imiptools/handlers/resource.py Wed May 20 15:06:33 2015 +0200
2.3 @@ -19,7 +19,7 @@
2.4 this program. If not, see <http://www.gnu.org/licenses/>.
2.5 """
2.6
2.7 -from imiptools.data import get_address, get_uri, to_part
2.8 +from imiptools.data import get_address, to_part
2.9 from imiptools.handlers import Handler
2.10 from imiptools.handlers.common import CommonFreebusy, Outgoing
2.11
2.12 @@ -27,18 +27,6 @@
2.13
2.14 "Handling mechanisms specific to resources."
2.15
2.16 - def set_participation(self, scheduled):
2.17 -
2.18 - "Set the user's participation in the current object if 'scheduled'."
2.19 -
2.20 - attendee_attr = self.obj.get_value_map("ATTENDEE").get(self.user)
2.21 - attendee_attr["PARTSTAT"] = scheduled and "ACCEPTED" or "DECLINED"
2.22 - if attendee_attr.has_key("RSVP"):
2.23 - del attendee_attr["RSVP"]
2.24 - if self.messenger and self.messenger.sender != get_address(self.user):
2.25 - attendee_attr["SENT-BY"] = get_uri(self.messenger.sender)
2.26 - return attendee_attr
2.27 -
2.28 def _record_and_respond(self, handle_for_attendee):
2.29
2.30 """
2.31 @@ -89,7 +77,8 @@
2.32
2.33 # Update the participation of the resource in the object.
2.34
2.35 - attendee_attr = self.set_participation(scheduled)
2.36 + attendee_attr = self.update_participation(self.obj,
2.37 + scheduled and "ACCEPTED" or "DECLINED")
2.38
2.39 # Set the complete event or an additional occurrence.
2.40
3.1 --- a/imipweb/event.py Wed May 20 13:41:23 2015 +0200
3.2 +++ b/imipweb/event.py Wed May 20 15:06:33 2015 +0200
3.3 @@ -20,7 +20,7 @@
3.4 """
3.5
3.6 from datetime import date, timedelta
3.7 -from imiptools.client import update_attendees, update_participation
3.8 +from imiptools.client import update_attendees
3.9 from imiptools.data import get_uri, uri_dict, uri_values
3.10 from imiptools.dates import format_datetime, get_datetime_item, \
3.11 get_period_item, to_date, to_timezone
3.12 @@ -143,10 +143,10 @@
3.13 to_cancel = update_attendees(obj, attendees, removed)
3.14 single_user = not attendees or attendees == [self.user]
3.15
3.16 - # Update attendee participation.
3.17 + # Update attendee participation for the current user.
3.18
3.19 if args.has_key("partstat"):
3.20 - update_participation(obj, self.user, args["partstat"][0])
3.21 + self.update_participation(obj, args["partstat"][0])
3.22
3.23 # Process any action.
3.24