mirror of
https://gitlab.science.ru.nl/technicie/MarietjeDjango.git
synced 2025-12-10 10:32:22 +01:00
Implement traditional queue length restrictions
This commit is contained in:
@ -121,9 +121,14 @@ 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 not settings.LIMIT_ALWAYS:
|
if not user.is_superuser:
|
||||||
if seconds_in_a_row > 0 and seconds_in_a_row + song.duration > settings.MAX_MINUTES_IN_A_ROW * 60\
|
if settings.LIMIT_ALWAYS:
|
||||||
and not user.is_superuser and settings.LIMIT_HOURS[0] <= now.hour < settings.LIMIT_HOURS[1]:
|
if seconds_in_a_row > settings.MAX_MINUTES_IN_A_ROW * 60:
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
if seconds_in_a_row > 0 and \
|
||||||
|
seconds_in_a_row + song.duration > settings.MAX_MINUTES_IN_A_ROW * 60 and \
|
||||||
|
settings.LIMIT_HOURS[0] <= now.hour < settings.LIMIT_HOURS[1]:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
playlist_song = PlaylistSong(playlist=self.playlist, song=song, user=user)
|
playlist_song = PlaylistSong(playlist=self.playlist, song=song, user=user)
|
||||||
|
|||||||
Reference in New Issue
Block a user