mirror of
https://gitlab.science.ru.nl/technicie/MarietjeDjango.git
synced 2025-12-09 18:52:23 +01:00
Add LIMIT_ALWAYS option which limits the queue length always
This commit is contained in:
@ -148,4 +148,5 @@ MAIL_FROM = 'marietje@hardcoding.nl'
|
||||
MAX_MINUTES_IN_A_ROW = 20
|
||||
|
||||
# Time range (dependent on timezone specified) when MAX_MINUTES_IN_A_ROW is in effect.
|
||||
LIMIT_ALWAYS = False
|
||||
LIMIT_HOURS = (12, 16)
|
||||
|
||||
@ -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
|
||||
|
||||
Reference in New Issue
Block a user