@property<EOL><INDENT>def availableDurations(self):<DEDENT>
potential_slots = InstructorAvailabilitySlot.objects.filter(<EOL>instructor=self.instructor,<EOL>location=self.location,<EOL>room=self.room,<EOL>pricingTier=self.pricingTier,<EOL>startTime__gte=self.startTime,<EOL>startTime__lte=self.startTime + timedelta(minutes=getConstant('<STR_LIT>')),<EOL>).exclude(id=self.id).order_by('<STR_LIT>')<EOL>duration_list = [self.duration,]<EOL>last_start = self.startTime<EOL>last_duration = self.duration<EOL>max_duration = self.duration<EOL>for slot in potential_slots:<EOL><INDENT>if max_duration + slot.duration > getConstant('<STR_LIT>'):<EOL><INDENT>break<EOL><DEDENT>if (<EOL>slot.startTime == last_start + timedelta(minutes=last_duration) and<EOL>slot.isAvailable<EOL>):<EOL><INDENT>duration_list.append(max_duration + slot.duration)<EOL>last_start = slot.startTime<EOL>last_duration = slot.duration<EOL>max_duration += slot.duration<EOL><DEDENT><DEDENT>return duration_list<EOL>
A lesson can always be booked for the length of a single slot, but this method
checks if multiple slots are available.  This method requires that slots are
non-overlapping, which needs to be enforced on slot save.