Fix cueout for overlapping starts & ends schedule
This commit is contained in:
parent
ffb8c49784
commit
d8c5206e2e
3 changed files with 95 additions and 9 deletions
|
@ -24,21 +24,45 @@ class Schedule(models.Model):
|
|||
|
||||
def get_cueout(self):
|
||||
"""
|
||||
Returns a cueout that is based on the current show. Cueout of a specific
|
||||
item can potentially overrun the show that it is scheduled in. In that
|
||||
case, the cueout should be the end of the show. This prevents the next
|
||||
show having overlapping items playing.
|
||||
Returns a scheduled item cueout that is based on the current show instance.
|
||||
|
||||
Cueout of a specific item can potentially overrun the show that it is
|
||||
scheduled in. In that case, the cueout should be the end of the show.
|
||||
This prevents the next show having overlapping items playing.
|
||||
|
||||
Cases:
|
||||
- When the schedule ends before the end of the show instance,
|
||||
return the stored cueout.
|
||||
|
||||
- When the schedule starts before the end of the show instance
|
||||
and ends after the show instance ends,
|
||||
return timedelta between schedule starts and show instance ends.
|
||||
|
||||
- When the schedule starts after the end of the show instance,
|
||||
return the stored cue_out even if the schedule WILL NOT BE PLAYED.
|
||||
"""
|
||||
if self.instance.ends < self.ends:
|
||||
if self.starts < self.instance.ends and self.instance.ends < self.ends:
|
||||
return self.instance.ends - self.starts
|
||||
return self.cue_out
|
||||
|
||||
def get_ends(self):
|
||||
"""
|
||||
Returns an item end that is based on the current show. Ends of a
|
||||
specific item can potentially overrun the show that it is scheduled in.
|
||||
In that case, the end should be the end of the show. This prevents the
|
||||
next show having overlapping items playing.
|
||||
Returns a scheduled item ends that is based on the current show instance.
|
||||
|
||||
End of a specific item can potentially overrun the show that it is
|
||||
scheduled in. In that case, the end should be the end of the show.
|
||||
This prevents the next show having overlapping items playing.
|
||||
|
||||
Cases:
|
||||
- When the schedule ends before the end of the show instance,
|
||||
return the scheduled item ends.
|
||||
|
||||
- When the schedule starts before the end of the show instance
|
||||
and ends after the show instance ends,
|
||||
return the show instance ends.
|
||||
|
||||
- When the schedule starts after the end of the show instance,
|
||||
return the show instance ends.
|
||||
"""
|
||||
if self.instance.ends < self.ends:
|
||||
return self.instance.ends
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue