summaryrefslogtreecommitdiffstats
path: root/wallace/module_resources.py
diff options
context:
space:
mode:
authorThomas Bruederli <bruederli@kolabsys.com>2015-03-02 12:57:32 -0500
committerThomas Bruederli <bruederli@kolabsys.com>2015-03-02 12:57:32 -0500
commite0cdbb50abceae359934f6421445491315069ab7 (patch)
treee415d3bc985e34bf9c30d42afbabbfbc7102c016 /wallace/module_resources.py
parent403257f86465a53237bb88fd6c7f2d292ab9f041 (diff)
downloadpykolab-e0cdbb50abceae359934f6421445491315069ab7.tar.gz
Store reservations for single occurrences with the same UID in one object (#4766)
Diffstat (limited to 'wallace/module_resources.py')
-rw-r--r--wallace/module_resources.py20
1 files changed, 14 insertions, 6 deletions
diff --git a/wallace/module_resources.py b/wallace/module_resources.py
index c1a684c..6742658 100644
--- a/wallace/module_resources.py
+++ b/wallace/module_resources.py
@@ -336,7 +336,7 @@ def execute(*args, **kw):
log.debug(_("Cancellation for entire event %r: deleting") % (itip_event['uid']), level=8)
delete_resource_event(itip_event['uid'], resources[resource], event._msguid)
# just cancel one single occurrence: add exception with status=cancelled
- elif master and master.is_recurring():
+ elif master is not None:
log.debug(_("Cancellation for a single occurrence %r of %r: updating...") % (itip_event['recurrence-id'], itip_event['uid']), level=8)
event.set_status('CANCELLED')
event.set_transparency(True)
@@ -687,9 +687,9 @@ def read_resource_calendar(resource_rec, itip_events):
for itip in itip_events:
conflict = check_event_conflict(event, itip)
- if event.get_uid() == itip['uid'] and (event.is_recurring() or itip['recurrence-id'] == event.get_recurrence_id()):
+ if event.get_uid() == itip['uid']:
setattr(event, '_msguid', msguid)
- if event.is_recurring():
+ if event.is_recurring() or itip['recurrence-id']:
resource_rec['existing_master'] = event
else:
resource_rec['existing_events'].append(event)
@@ -740,21 +740,29 @@ def find_existing_event(uid, recurrence_id, resource_rec):
event = event_from_message(message_from_string(data[0][1]))
# find instance in a recurring series
- if recurrence_id and event.is_recurring():
+ if recurrence_id and (event.is_recurring() or event.has_exceptions()):
master = event
event = master.get_instance(recurrence_id)
setattr(master, '_msguid', msguid)
+ # return master, even if instance is not found
+ if not event and master.uid == uid:
+ return (event, master)
+
# compare recurrence-id and skip to next message if not matching
- elif recurrence_id and not event.is_recurring() and not xmlutils.dates_equal(recurrence_id, event.get_recurrence_id()):
+ elif recurrence_id and not xmlutils.dates_equal(recurrence_id, event.get_recurrence_id()):
log.debug(_("Recurrence-ID not matching on message %s, skipping: %r != %r") % (
msguid, recurrence_id, event.get_recurrence_id()
), level=8)
continue
- setattr(event, '_msguid', msguid)
+
+ if event is not None:
+ setattr(event, '_msguid', msguid)
except Exception, e:
log.error(_("Failed to parse event from message %s/%s: %r") % (mailbox, num, e))
+ event = None
+ master = None
continue
if event and event.uid == uid: