Yes we only test for intersection with first event in the chain. The heuristics could be improved i guess, but implementing a system that would find whether there is a possible intersection between 2 infinitely recurring events is very difficult and not very feasible so i am marking this as a "Wishlist".
If you want to you can try and come up with some kind of clever algorithm, i will gladly accept patches that fix this problem.
As for your current code:
def getConflictingEvents(self, resource):
"""Return a list of events that would conflict when booking resource."""
events = []
if not canAccess(resource.calendar, "expand"):
return events
if self.context.recurrence:
totest = []
# this loop is infinite when you have an infinite recurrence rule
for d in self.context.recurrence.apply(self.context): totest.append(datetime(d.year, d.month, d.day, self.context.dtstart.hour, self.context.dtstart.minute, self.context.dtstart.second, self.context.dtstart.microsecond, self.context.dtstart.tzinfo))
else:
totest = [self.context.dtstart]
for d in totest:
# expanding each of the events let's say 300 times (because we have a daily recurring event for a year)
for event in resource.calendar.expand(d,d + self.context.duration):
# for every one of like 100 events in the resource calendar
# and we show at least 10 resources
# i am afraid this would be too slow :(
if event != self.context: events.append(EventForBookingDisplay(event))
return events
Yes we only test for intersection with first event in the chain. The heuristics could be improved i guess, but implementing a system that would find whether there is a possible intersection between 2 infinitely recurring events is very difficult and not very feasible so i am marking this as a "Wishlist".
If you want to you can try and come up with some kind of clever algorithm, i will gladly accept patches that fix this problem.
As for your current code:
def getConflictingE vents(self, resource): resource. calendar, "expand"): recurrence: recurrence. apply(self. context) :
totest. append( datetime( d.year, d.month, d.day, self.context. dtstart. hour, self.context. dtstart. minute, self.context. dtstart. second, self.context. dtstart. microsecond, self.context. dtstart. tzinfo) ) dtstart] calendar. expand( d,d + self.context. duration) :
events. append( EventForBooking Display( event))
"""Return a list of events that would conflict when booking resource."""
events = []
if not canAccess(
return events
if self.context.
totest = []
# this loop is infinite when you have an infinite recurrence rule
for d in self.context.
else:
totest = [self.context.
for d in totest:
# expanding each of the events let's say 300 times (because we have a daily recurring event for a year)
for event in resource.
# for every one of like 100 events in the resource calendar
# and we show at least 10 resources
# i am afraid this would be too slow :(
if event != self.context:
return events