Correction de la gestion des exceptions dans les événements récurrents
Fix #395
This commit is contained in:
parent
f3977fee54
commit
4efa5aca50
@ -58,14 +58,14 @@ class DayInCalendar:
|
||||
|
||||
def is_ancestor_uuid_event_from_other(self, event):
|
||||
for e in self.events:
|
||||
if event.is_ancestor_by_uuid(e):
|
||||
if event.is_ancestor_by_uuid_and_rules(e):
|
||||
return True
|
||||
return False
|
||||
|
||||
def remove_event_with_ancestor_uuid_if_exists(self, event):
|
||||
removed = False
|
||||
for i, e in enumerate(self.events):
|
||||
if e.is_ancestor_by_uuid(event):
|
||||
if e.is_ancestor_by_uuid_and_rules(event):
|
||||
# remove e from events_by_category
|
||||
for k, v in self.events_by_category.items():
|
||||
if e in v:
|
||||
|
@ -2066,18 +2066,22 @@ class Event(models.Model):
|
||||
else:
|
||||
return ":".join(els), 0
|
||||
|
||||
def is_ancestor_uuid(uuid1, uuid2):
|
||||
def is_ancestor_uuid_and_rules(uuid1, uuid2, r1, r2):
|
||||
root1, version1 = Event.split_uuid(uuid1)
|
||||
root2, version2 = Event.split_uuid(uuid2)
|
||||
return root1 == root2 and version1 < version2
|
||||
return root1 == root2 and ((r1 and not r2) or (version1 < version2))
|
||||
|
||||
def is_ancestor_by_uuid(self, event):
|
||||
def is_ancestor_by_uuid_and_rules(self, event):
|
||||
if self.uuids is None or event.uuids is None:
|
||||
return False
|
||||
if (not self.recurrences) and event.recurrences:
|
||||
return False
|
||||
|
||||
for s_uuid in self.uuids:
|
||||
for e_uuid in event.uuids:
|
||||
if Event.is_ancestor_uuid(s_uuid, e_uuid):
|
||||
if Event.is_ancestor_uuid_and_rules(
|
||||
s_uuid, e_uuid, self.recurrences, event.recurrences
|
||||
):
|
||||
return True
|
||||
return False
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user