summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Bruederli <bruederli@kolabsys.com>2015-02-17 10:29:19 +0100
committerThomas Bruederli <bruederli@kolabsys.com>2015-02-17 10:29:19 +0100
commit073abc3611c52707f4a5fc63ab964f960366a9a6 (patch)
tree5dcb166cb794750dd6fc4fbd0dc415b8c2acf7e5
parente25e91e5c23621c53e1c0034cf5d3c42e939363e (diff)
downloadpykolab-073abc3611c52707f4a5fc63ab964f960366a9a6.tar.gz
Fix attendee updates on exceptions
-rw-r--r--pykolab/xml/event.py20
-rw-r--r--tests/unit/test-003-event.py6
2 files changed, 18 insertions, 8 deletions
diff --git a/pykolab/xml/event.py b/pykolab/xml/event.py
index 325cbc5..3fdd8dc 100644
--- a/pykolab/xml/event.py
+++ b/pykolab/xml/event.py
@@ -157,7 +157,7 @@ class Event(object):
attendee = Attendee(email_or_attendee, name, rsvp, role, participant_status, cutype, params)
# apply update to self and all exceptions
- self.update_attendees([attendee])
+ self.update_attendees([attendee], True)
def add_category(self, category):
self._categories.append(ustr(category))
@@ -722,15 +722,19 @@ class Event(object):
attendee.set_rsvp(rsvp)
# apply update to self and all exceptions
- self.update_attendees([attendee])
+ self.update_attendees([attendee], False)
- def update_attendees(self, _attendees):
- self.merge_attendee_data(_attendees)
+ def update_attendees(self, _attendees, append=True):
+ self.merge_attendee_data(_attendees, append)
- for exception in self._exceptions:
- exception.merge_attendee_data(_attendees)
+ if len(self._exceptions):
+ vexceptions = self.event.exceptions()
+ for i, exception in enumerate(self._exceptions):
+ exception.merge_attendee_data(_attendees, append)
+ vexceptions[i] = exception.event
+ self.event.setExceptions(vexceptions)
- def merge_attendee_data(self, _attendees):
+ def merge_attendee_data(self, _attendees, append=True):
for attendee in _attendees:
found = False
@@ -740,7 +744,7 @@ class Event(object):
found = True
break
- if not found:
+ if not found and append:
self._attendees.append(attendee)
self.event.setAttendees(self._attendees)
diff --git a/tests/unit/test-003-event.py b/tests/unit/test-003-event.py
index 1d0ad10..d79d877 100644
--- a/tests/unit/test-003-event.py
+++ b/tests/unit/test-003-event.py
@@ -855,16 +855,22 @@ END:VEVENT
jane = event.get_attendee("jane@example.org")
jane.set_participant_status('TENTATIVE')
jack = Attendee("jack@example.org", name="Jack", role='OPT-PARTICIPANT')
+ some = event.set_attendee_participant_status("somebody@else.com", 'ACCEPTED')
# update jane + add jack
event.update_attendees([jane,jack])
self.assertEqual(len(event.get_attendees()), 3)
self.assertEqual(event.get_attendee("jane@example.org").get_participant_status(), kolabformat.PartTentative)
+ self.assertEqual(event.get_attendee("somebody@else.com").get_participant_status(), kolabformat.PartAccepted)
+ # test write + read
+ event = event_from_string(str(event))
exception = event.get_exceptions()[0]
self.assertEqual(len(exception.get_attendees()), 2)
self.assertEqual(event.get_attendee("jane@example.org").get_participant_status(), kolabformat.PartTentative)
self.assertEqual(event.get_attendee("jack@example.org").get_name(), "Jack")
+ self.assertRaises(ValueError, exception.get_attendee, "somebody@else.com") # not addded to exception
+
def _find_prop_in_list(self, diff, name):
for prop in diff: