1.1 --- a/imiptools/client.py Wed Apr 01 00:00:16 2015 +0200
1.2 +++ b/imiptools/client.py Wed Apr 01 01:31:39 2015 +0200
1.3 @@ -19,20 +19,23 @@
1.4 this program. If not, see <http://www.gnu.org/licenses/>.
1.5 """
1.6
1.7 -from imiptools.data import get_window_end, uri_items
1.8 +from imiptools.data import 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 -def update_attendees(obj, added, removed):
1.13 +def update_attendees(obj, attendees, removed):
1.14
1.15 """
1.16 - Update the attendees in 'obj' with the given 'added' and 'removed'
1.17 + Update the attendees in 'obj' with the given 'attendees' and 'removed'
1.18 attendee lists. A list is returned containing the attendees whose
1.19 attendance should be cancelled.
1.20 """
1.21
1.22 to_cancel = []
1.23
1.24 + existing_attendees = uri_values(obj.get_values("ATTENDEE") or [])
1.25 + added = set(attendees).difference(existing_attendees)
1.26 +
1.27 if added or removed:
1.28 attendees = uri_items(obj.get_items("ATTENDEE") or [])
1.29 sequence = obj.get_value("SEQUENCE")
1.30 @@ -55,12 +58,26 @@
1.31
1.32 if added:
1.33 for attendee in added:
1.34 - attendees.append((attendee, {"PARTSTAT" : "NEEDS-ACTION", "RSVP" : "TRUE"}))
1.35 + attendee = attendee.strip()
1.36 + if attendee:
1.37 + attendees.append((get_uri(attendee), {"PARTSTAT" : "NEEDS-ACTION", "RSVP" : "TRUE"}))
1.38
1.39 obj["ATTENDEE"] = attendees
1.40
1.41 return to_cancel
1.42
1.43 +def update_participation(obj, user, partstat):
1.44 +
1.45 + "Update the participation in 'obj' of 'user' with the given 'partstat'."
1.46 +
1.47 + existing_attendees = uri_dict(obj.get_value_map("ATTENDEE"))
1.48 +
1.49 + if partstat:
1.50 + if existing_attendees.has_key(user):
1.51 + existing_attendees[user]["PARTSTAT"] = partstat
1.52 + if existing_attendees[user].has_key("RSVP"):
1.53 + del existing_attendees[user]["RSVP"]
1.54 +
1.55 class Client:
1.56
1.57 "Common handler and manager methods."