Add LIMIT_ALWAYS option which limits the queue length always

This commit is contained in:
Daan Sprenkels
2017-10-05 17:33:58 +02:00
parent 830e97eeb0
commit 3abb39916d
2 changed files with 5 additions and 3 deletions

View File

@ -124,9 +124,10 @@ class Queue(models.Model):
seconds_in_a_row += playlist_song.song.duration
now = timezone.now()
if seconds_in_a_row > 0 and seconds_in_a_row + song.duration > settings.MAX_MINUTES_IN_A_ROW * 60\
and not user.is_superuser and settings.LIMIT_HOURS[0] <= now.hour < settings.LIMIT_HOURS[1]:
return False
if not settings.LIMIT_ALWAYS:
if seconds_in_a_row > 0 and seconds_in_a_row + song.duration > settings.MAX_MINUTES_IN_A_ROW * 60\
and not user.is_superuser and settings.LIMIT_HOURS[0] <= now.hour < settings.LIMIT_HOURS[1]:
return False
if order is None:
order = 0