mirror of
https://gitlab.science.ru.nl/technicie/MarietjeDjango.git
synced 2025-12-10 11:12:20 +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
|
MAX_MINUTES_IN_A_ROW = 20
|
||||||
|
|
||||||
# Time range (dependent on timezone specified) when MAX_MINUTES_IN_A_ROW is in effect.
|
# Time range (dependent on timezone specified) when MAX_MINUTES_IN_A_ROW is in effect.
|
||||||
|
LIMIT_ALWAYS = False
|
||||||
LIMIT_HOURS = (12, 16)
|
LIMIT_HOURS = (12, 16)
|
||||||
|
|||||||
@ -124,9 +124,10 @@ class Queue(models.Model):
|
|||||||
seconds_in_a_row += playlist_song.song.duration
|
seconds_in_a_row += playlist_song.song.duration
|
||||||
|
|
||||||
now = timezone.now()
|
now = timezone.now()
|
||||||
if seconds_in_a_row > 0 and seconds_in_a_row + song.duration > settings.MAX_MINUTES_IN_A_ROW * 60\
|
if not settings.LIMIT_ALWAYS:
|
||||||
and not user.is_superuser and settings.LIMIT_HOURS[0] <= now.hour < settings.LIMIT_HOURS[1]:
|
if seconds_in_a_row > 0 and seconds_in_a_row + song.duration > settings.MAX_MINUTES_IN_A_ROW * 60\
|
||||||
return False
|
and not user.is_superuser and settings.LIMIT_HOURS[0] <= now.hour < settings.LIMIT_HOURS[1]:
|
||||||
|
return False
|
||||||
|
|
||||||
if order is None:
|
if order is None:
|
||||||
order = 0
|
order = 0
|
||||||
|
|||||||
Reference in New Issue
Block a user