mirror of
https://gitlab.science.ru.nl/technicie/MarietjeDjango.git
synced 2025-12-09 21:02:24 +01:00
Implement traditional queue length restrictions
This commit is contained in:
@ -121,10 +121,15 @@ class Queue(models.Model):
|
||||
seconds_in_a_row += playlist_song.song.duration
|
||||
|
||||
now = timezone.now()
|
||||
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 not user.is_superuser:
|
||||
if settings.LIMIT_ALWAYS:
|
||||
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
|
||||
|
||||
playlist_song = PlaylistSong(playlist=self.playlist, song=song, user=user)
|
||||
playlist_song.save()
|
||||
|
||||
Reference in New Issue
Block a user