From 3724b94e4ada60367ab1d1dedcfcb462c612e8d5 Mon Sep 17 00:00:00 2001 From: Daan Sprenkels Date: Tue, 9 Jun 2020 17:36:12 +0200 Subject: [PATCH 1/2] 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. --- .../0009_unlimited_queue_length_perm.py | 17 +++++++++++++++++ marietje/queues/models.py | 3 ++- 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 marietje/queues/migrations/0009_unlimited_queue_length_perm.py diff --git a/marietje/queues/migrations/0009_unlimited_queue_length_perm.py b/marietje/queues/migrations/0009_unlimited_queue_length_perm.py new file mode 100644 index 0000000..7bede28 --- /dev/null +++ b/marietje/queues/migrations/0009_unlimited_queue_length_perm.py @@ -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'))}, + ), + ] diff --git a/marietje/queues/models.py b/marietje/queues/models.py index 962512b..e7ac8a7 100644 --- a/marietje/queues/models.py +++ b/marietje/queues/models.py @@ -64,6 +64,7 @@ class Queue(models.Model): ('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'), ) name = models.TextField() @@ -111,7 +112,7 @@ class Queue(models.Model): return songs[1:] 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') seconds_in_a_row = sum(ps.song.duration for ps in playlist_songs if ps.user == user) From 23f651bbd1694958fe7e010b9ca2c1dae51aeb8c Mon Sep 17 00:00:00 2001 From: Daan Sprenkels Date: Tue, 9 Jun 2020 17:57:25 +0200 Subject: [PATCH 2/2] Fix pylint errors --- marietje/queues/models.py | 4 ++-- pylintrc | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/marietje/queues/models.py b/marietje/queues/models.py index e7ac8a7..1ca76a9 100644 --- a/marietje/queues/models.py +++ b/marietje/queues/models.py @@ -150,7 +150,7 @@ class Queue(models.Model): song_count += 1 def __str__(self): - return self.name + return str(self.name) class QueueCommand(models.Model): @@ -162,4 +162,4 @@ class QueueCommand(models.Model): command = models.TextField() def __str__(self): - return self.command + return str(self.command) diff --git a/pylintrc b/pylintrc index 2cdd747..79f2553 100644 --- a/pylintrc +++ b/pylintrc @@ -150,6 +150,7 @@ disable=missing-docstring, missing-format-attribute, too-few-public-methods, unused-argument, + signature-differs, # Enable the message, report, category or checker with the given id(s). You can # either give multiple identifier separated by comma (,) or put this option