Changeset View
Changeset View
Standalone View
Standalone View
pykolab/itip/__init__.py
Show First 20 Lines • Show All 184 Lines • ▼ Show 20 Lines | def check_event_conflict(kolab_event, itip_event): | ||||
# naive loops to check for collisions in (recurring) events | # naive loops to check for collisions in (recurring) events | ||||
# TODO: compare recurrence rules directly (e.g. matching time slot or weekday or monthday) | # TODO: compare recurrence rules directly (e.g. matching time slot or weekday or monthday) | ||||
while not conflict and not done: | while not conflict and not done: | ||||
loop += 1 | loop += 1 | ||||
# Scroll forward the kolab event recurrence until we're in the prime | # Scroll forward the kolab event recurrence until we're in the prime | ||||
# spot. We choose to start with the Kolab event because that is likely | # spot. We choose to start with the Kolab event because that is likely | ||||
# the older one. | # the older o:wqne. | ||||
if _ee < _is: | if _ee < _is: | ||||
while _ee < _is and _es is not None and kolab_event.is_recurring(): | while _ee < _is and _es is not None and kolab_event.is_recurring(): | ||||
log.debug("Attempt to move forward kolab event recurrence from %s closer to %s" % (_ee, _is), level=8) | log.debug("Attempt to move forward kolab event recurrence from %s closer to %s" % (_ee, _is), level=8) | ||||
__es = to_dt(kolab_event.get_next_occurence(_es)) | __es = to_dt(kolab_event.get_next_occurence(_es)) | ||||
if not __es is None: | if __es is not None and not __es == _es: | ||||
_es = __es | _es = __es | ||||
_ee = to_dt(kolab_event.get_occurence_end_date(_es)) | _ee = to_dt(kolab_event.get_occurence_end_date(_es)) | ||||
else: | else: | ||||
done = True | done = True | ||||
break | break | ||||
# Scroll forward the itip event recurrence until we're in the | # Scroll forward the itip event recurrence until we're in the | ||||
# prime spot, this time with the iTip event. | # prime spot, this time with the iTip event. | ||||
elif _ie < _es: | elif _ie < _es: | ||||
while _ie < _es and _is is not None and itip_event['xml'].is_recurring(): | while _ie < _es and _is is not None and itip_event['xml'].is_recurring(): | ||||
log.debug("Attempt to move forward itip event recurrence from %s closer to %s" % (_ie, _es), level=8) | log.debug("Attempt to move forward itip event recurrence from %s closer to %s" % (_ie, _es), level=8) | ||||
__is = to_dt(itip_event['xml'].get_next_occurence(_is)) | __is = to_dt(itip_event['xml'].get_next_occurence(_is)) | ||||
if not __is is None: | if __is is not None and not _is == __is: | ||||
_is = __is | _is = __is | ||||
_ie = to_dt(itip_event['xml'].get_occurence_end_date(_is)) | _ie = to_dt(itip_event['xml'].get_occurence_end_date(_is)) | ||||
else: | else: | ||||
done = True | done = True | ||||
break | break | ||||
# Now that we have some events somewhere in the same neighborhood... | # Now that we have some events somewhere in the same neighborhood... | ||||
conflict = check_date_conflict(_es, _ee, _is, _ie) | conflict = check_date_conflict(_es, _ee, _is, _ie) | ||||
log.debug("* Comparing itip at %s/%s with kolab at %s/%s: %r (%d)" % (_is, _ie, _es, _ee, conflict, loop), level=8) | log.debug( | ||||
"* Comparing itip at %s/%s with kolab at %s/%s: conflict - %r (occurence - %d)" % ( | |||||
_is, _ie, _es, _ee, conflict, loop | |||||
), | |||||
level=8 | |||||
) | |||||
if not conflict: | if not conflict: | ||||
if kolab_event.is_recurring() and itip_event['xml'].is_recurring(): | if kolab_event.is_recurring() and itip_event['xml'].is_recurring(): | ||||
if not kolab_event.has_exceptions() and not itip_event['xml'].has_exceptions(): | if not kolab_event.has_exceptions() and not itip_event['xml'].has_exceptions(): | ||||
log.debug("No conflict, both recurring, but neither with exceptions", level=8) | log.debug("No conflict, both recurring, but neither with exceptions", level=8) | ||||
done = True | done = True | ||||
break | break | ||||
▲ Show 20 Lines • Show All 157 Lines • Show Last 20 Lines |