From 6ff170e1698fc4b5a07be42b5938da8d696e6c2c Mon Sep 17 00:00:00 2001 From: Colin Powell Date: Mon, 27 Feb 2023 10:30:20 -0500 Subject: [PATCH] Quite a few bugs --- vrobbler/apps/music/models.py | 2 +- vrobbler/apps/scrobbles/context_processors.py | 20 +++++++++---------- vrobbler/apps/scrobbles/views.py | 10 +++++----- 3 files changed, 15 insertions(+), 17 deletions(-) diff --git a/vrobbler/apps/music/models.py b/vrobbler/apps/music/models.py index 0e6b64b..38ee7df 100644 --- a/vrobbler/apps/music/models.py +++ b/vrobbler/apps/music/models.py @@ -6,7 +6,7 @@ from uuid import uuid4 import musicbrainzngs from django.conf import settings -from django.core.files.base import File +from django.core.files.base import ContentFile, File from django.db import models from django.urls import reverse from django.utils.translation import gettext_lazy as _ diff --git a/vrobbler/apps/scrobbles/context_processors.py b/vrobbler/apps/scrobbles/context_processors.py index 6ec5e4a..19358b1 100644 --- a/vrobbler/apps/scrobbles/context_processors.py +++ b/vrobbler/apps/scrobbles/context_processors.py @@ -6,14 +6,12 @@ from scrobbles.models import Scrobble def now_playing(request): user = request.user now = timezone.now() - if user.is_authenticated: - if user.profile: - timezone.activate(pytz.timezone(user.profile.timezone)) - now = timezone.localtime(timezone.now()) - return { - 'now_playing_list': Scrobble.objects.filter( - in_progress=True, - is_paused=False, - user=user, - ) - } + if not user.is_authenticated: + return {} + return { + 'now_playing_list': Scrobble.objects.filter( + in_progress=True, + is_paused=False, + user=user, + ) + } diff --git a/vrobbler/apps/scrobbles/views.py b/vrobbler/apps/scrobbles/views.py index c32510f..b6d9819 100644 --- a/vrobbler/apps/scrobbles/views.py +++ b/vrobbler/apps/scrobbles/views.py @@ -87,17 +87,17 @@ class RecentScrobbleList(ListView): data['sport_scrobble_list'] = completed_for_user.filter( sport_event__isnull=False ).order_by('-timestamp')[:15] + data['active_imports'] = AudioScrobblerTSVImport.objects.filter( + processing_started__isnull=False, + processed_finished__isnull=True, + user=self.request.user, + ) data["weekly_data"] = week_of_scrobbles(user=user) data['counts'] = scrobble_counts(user) data['imdb_form'] = ScrobbleForm data['export_form'] = ExportScrobbleForm - data['active_imports'] = AudioScrobblerTSVImport.objects.filter( - processing_started__isnull=False, - processed_finished__isnull=True, - user=self.request.user, - ) return data def get_queryset(self):