Changeset View
Changeset View
Standalone View
Standalone View
pykolab/itip/__init__.py
Show First 20 Lines • Show All 166 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 _es is not None: | while not conflict and _es is not None: | ||||
_is = to_dt(itip_event['start']) | _is = to_dt(itip_event['start']) | ||||
_ie = to_dt(itip_event['end']) | _ie = to_dt(itip_event['end']) | ||||
_iv = itip_event['xml'] | _iv = itip_event['xml'] | ||||
_ii = 0 | _ii = 0 | ||||
while not conflict and _is is not None: | # T1988: For performance reasons we add "and _is < _ee" here | ||||
while not conflict and _is is not None and _is < _ee: | |||||
# log.debug("* Comparing event dates at %s/%s with %s/%s" % (_es, _ee, _is, _ie), level=9) | # log.debug("* Comparing event dates at %s/%s with %s/%s" % (_es, _ee, _is, _ie), level=9) | ||||
conflict = not _is_transparent(_ev) and not _is_transparent(_iv) and check_date_conflict(_es, _ee, _is, _ie) | conflict = not _is_transparent(_ev) and not _is_transparent(_iv) and check_date_conflict(_es, _ee, _is, _ie) | ||||
# T1988: For performance reasons we modify recurrence iteration | |||||
if _is < _es: | |||||
_is = _is.replace(_es.year, _es.month, _es.day, 0, 0) | |||||
_is = to_dt(itip_event['xml'].get_next_occurence(_is)) if itip_event['xml'].is_recurring() else None | _is = to_dt(itip_event['xml'].get_next_occurence(_is)) if itip_event['xml'].is_recurring() else None | ||||
_ie = to_dt(itip_event['xml'].get_occurence_end_date(_is)) | _ie = to_dt(itip_event['xml'].get_occurence_end_date(_is)) | ||||
# get full occurrence to compare the dates from a possible exception | # get full occurrence to compare the dates from a possible exception | ||||
if _is is not None and itip_event['xml'].has_exceptions(): | if _is is not None and itip_event['xml'].has_exceptions(): | ||||
_ix = itip_event['xml'].get_instance(_is) | _ix = itip_event['xml'].get_instance(_is) | ||||
if _ix is not None: | if _ix is not None: | ||||
_is = to_dt(_ix.get_start()) | _is = to_dt(_ix.get_start()) | ||||
▲ Show 20 Lines • Show All 178 Lines • Show Last 20 Lines |