mirror of
https://gitlab.science.ru.nl/technicie/MarietjeDjango.git
synced 2025-12-09 18:42:21 +01:00
Limit hours when MAX_MINUTES_IN_A_ROW is in effect.
This commit is contained in:
@ -121,7 +121,7 @@ AUTH_USER_MODEL = 'marietje.User'
|
||||
|
||||
LANGUAGE_CODE = 'en-us'
|
||||
|
||||
TIME_ZONE = 'UTC'
|
||||
TIME_ZONE = 'Europe/Amsterdam'
|
||||
|
||||
USE_I18N = True
|
||||
|
||||
@ -144,4 +144,8 @@ BERTHA_HOST = ('hardcoding.nl', 1819)
|
||||
|
||||
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_HOURS = (12, 16)
|
||||
|
||||
@ -2,6 +2,7 @@ from django.db import models
|
||||
from django.db.models import Q, Max
|
||||
from django.conf import settings
|
||||
from songs.models import Song
|
||||
from django.utils import timezone
|
||||
|
||||
|
||||
class Playlist(models.Model):
|
||||
@ -122,8 +123,9 @@ class Queue(models.Model):
|
||||
else:
|
||||
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 order is None:
|
||||
|
||||
Reference in New Issue
Block a user