diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index fab58b5..25975d3 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -8,4 +8,3 @@ before_script: pylint: script: - pylint marietje/marietje marietje/metrics marietje/playerapi marietje/queues marietje/songs marietje/stats - allow_failure: yes diff --git a/marietje/api/views.py b/marietje/api/views.py index 7a21351..ec0d2f0 100644 --- a/marietje/api/views.py +++ b/marietje/api/views.py @@ -111,7 +111,7 @@ def songs(request): except EmptyPage: songs = paginator.page(paginator.num_pages) - songs_dict = [song_to_dict(song, user=True) for song in songs.object_list] + songs_dict = [song_to_dict(song, include_user=True) for song in songs.object_list] return JsonResponse({ 'per_page': pagesize, 'current_page': page, @@ -170,7 +170,7 @@ def queue(request): queue = request.user.queue return JsonResponse({ 'current_song': playlist_song_to_dict(queue.current_song()), - 'queue': [playlist_song_to_dict(playlist_song, user=request.user) for playlist_song in queue.queue()], + 'queue': [playlist_song_to_dict(playlist_song, include_user=request.user) for playlist_song in queue.queue()], 'started_at': 0 if queue.started_at is None else int(queue.started_at.timestamp()), 'current_time': int(time.time()) }) diff --git a/marietje/marietje/forms.py b/marietje/marietje/forms.py index c04b1c1..41e741a 100644 --- a/marietje/marietje/forms.py +++ b/marietje/marietje/forms.py @@ -5,9 +5,6 @@ from django.utils.translation import ugettext_lazy as _ class AuthenticationForm(BaseAuthenticationForm): - def __init__(self, request=None, *args, **kwargs): - super(AuthenticationForm, self).__init__(request, *args, **kwargs) - def confirm_login_allowed(self, user): if user.activation_token: raise forms.ValidationError( diff --git a/marietje/marietje/models.py b/marietje/marietje/models.py index b89c502..6421c5d 100644 --- a/marietje/marietje/models.py +++ b/marietje/marietje/models.py @@ -1,14 +1,14 @@ -from django.db import models -from queues.models import Queue from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager from django.contrib.auth.hashers import make_password from django.contrib.auth.models import PermissionsMixin from django.contrib.auth.validators import ASCIIUsernameValidator, UnicodeUsernameValidator +from django.core.mail import send_mail +from django.db import models from django.utils import six, timezone from django.utils.translation import ugettext_lazy as _ -from django.core.mail import send_mail from marietje.utils import get_first_queue +from queues.models import Queue class UserManager(BaseUserManager): diff --git a/marietje/marietje/settings.py b/marietje/marietje/settings.py index 07c5038..0f4fb17 100644 --- a/marietje/marietje/settings.py +++ b/marietje/marietje/settings.py @@ -62,7 +62,7 @@ DATABASES = { 'PASSWORD': 'v8TzZwdAdSi7Tk5I', 'HOST': 'localhost', 'PORT': '3306', - 'OPTIONS': { 'init_command': "SET sql_mode='STRICT_TRANS_TABLES'" }, + 'OPTIONS': {'init_command': "SET sql_mode='STRICT_TRANS_TABLES'"}, } } @@ -95,12 +95,12 @@ CACHES = { 'default': { 'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache', 'LOCATION': '/var/tmp/MarietjeDjango_cache/default', - 'OPTIONS': { 'MAX_ENTRIES': 1000 }, + 'OPTIONS': {'MAX_ENTRIES': 1000}, }, 'song_search': { 'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache', 'LOCATION': '/var/tmp/MarietjeDjango_cache/song_search', - 'OPTIONS': { 'MAX_ENTRIES': 1000 }, + 'OPTIONS': {'MAX_ENTRIES': 1000}, }, } diff --git a/marietje/marietje/utils.py b/marietje/marietje/utils.py index 8c6f03b..b7fea32 100644 --- a/marietje/marietje/utils.py +++ b/marietje/marietje/utils.py @@ -1,10 +1,13 @@ -import socket, struct, binascii +import binascii +import socket +import struct + from django.conf import settings -from queues.models import Queue, Playlist from django.http import StreamingHttpResponse +from queues.models import Queue, Playlist -def song_to_dict(song, hash=False, user=False, replaygain=False): +def song_to_dict(song, include_hash=False, include_user=False, include_replaygain=False): data = { 'id': song.id, 'artist': song.artist, @@ -12,13 +15,13 @@ def song_to_dict(song, hash=False, user=False, replaygain=False): 'duration': song.duration, } - if hash: + if include_hash: data['hash'] = song.hash - if user is not None and song.user is not None and song.user.name: + if include_user is not None and song.user is not None and song.user.name: data['uploader_name'] = song.user.name - if replaygain: + if include_replaygain: data['rg_gain'] = song.rg_gain data['rg_peak'] = song.rg_peak @@ -44,9 +47,9 @@ def send_to_bertha(file): for chunk in file.chunks(): sock.sendall(chunk) sock.shutdown(socket.SHUT_WR) - hash = binascii.hexlify(sock.recv(64)) + song_hash = binascii.hexlify(sock.recv(64)) sock.close() - return hash + return song_hash def get_first_queue(): @@ -61,10 +64,10 @@ def get_first_queue(): return queue -def bertha_stream(hash): +def bertha_stream(song_hash): sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.connect(settings.BERTHA_HOST) - sock.sendall(struct.pack("