mirror of
https://gitlab.science.ru.nl/technicie/MarietjeDjango.git
synced 2025-12-09 21:02:24 +01:00
Add 'unlimited_queue_length' permission
The 'unlimited_queue_length' permission allows a user to queue songs without being restricted by the 45-minute queue length.
This commit is contained in:
@ -0,0 +1,17 @@
|
|||||||
|
# Generated by Django 2.2.13 on 2020-06-09 15:24
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('queues', '0008_remove_queuecommand_executed'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterModelOptions(
|
||||||
|
name='queue',
|
||||||
|
options={'permissions': (('can_skip', 'Can skip the currently playing song'), ('can_move', 'Can move all songs in the queue'), ('can_cancel', 'Can cancel all songs in the queue'), ('can_control_volume', 'Can control the volume of Marietje'), ('unlimited_queue_length', 'Is unlimited by maximum queue length'))},
|
||||||
|
),
|
||||||
|
]
|
||||||
@ -64,6 +64,7 @@ class Queue(models.Model):
|
|||||||
('can_move', 'Can move all songs in the queue'),
|
('can_move', 'Can move all songs in the queue'),
|
||||||
('can_cancel', 'Can cancel all songs in the queue'),
|
('can_cancel', 'Can cancel all songs in the queue'),
|
||||||
('can_control_volume', 'Can control the volume of Marietje'),
|
('can_control_volume', 'Can control the volume of Marietje'),
|
||||||
|
('unlimited_queue_length', 'Is unlimited by maximum queue length'),
|
||||||
)
|
)
|
||||||
|
|
||||||
name = models.TextField()
|
name = models.TextField()
|
||||||
@ -111,7 +112,7 @@ class Queue(models.Model):
|
|||||||
return songs[1:]
|
return songs[1:]
|
||||||
|
|
||||||
def request(self, song, user):
|
def request(self, song, user):
|
||||||
if not user.is_superuser:
|
if not user.has_perm('unlimited_queue_length'):
|
||||||
playlist_songs = PlaylistSong.objects.filter(playlist=self.playlist, state=0).order_by('id')
|
playlist_songs = PlaylistSong.objects.filter(playlist=self.playlist, state=0).order_by('id')
|
||||||
|
|
||||||
seconds_in_a_row = sum(ps.song.duration for ps in playlist_songs if ps.user == user)
|
seconds_in_a_row = sum(ps.song.duration for ps in playlist_songs if ps.user == user)
|
||||||
|
|||||||
Reference in New Issue
Block a user