Truncate schedule items that run over the time of the containing show

Fixes: #1272
This commit is contained in:
Kyle Robbertze 2021-08-10 16:30:02 +02:00
parent 0f4466b9ab
commit 7e1be7b028
3 changed files with 104 additions and 0 deletions

View file

@ -22,6 +22,28 @@ class Schedule(models.Model):
def get_owner(self):
return self.instance.get_owner()
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.
"""
if 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.
"""
if self.instance.ends < self.ends:
return self.instance.ends
return self.ends
class Meta:
managed = False
db_table = "cc_schedule"