From 66a90c87f16a5c3212f0907c63e9d622e7b4a472 Mon Sep 17 00:00:00 2001 From: Colin Powell Date: Fri, 3 Mar 2023 02:29:32 -0500 Subject: [PATCH] Add demo of maloja style --- vrobbler/apps/scrobbles/views.py | 69 +++- vrobbler/templates/base.html | 48 --- .../templates/scrobbles/scrobble_list.html | 341 +++++++++++++++++- 3 files changed, 385 insertions(+), 73 deletions(-) diff --git a/vrobbler/apps/scrobbles/views.py b/vrobbler/apps/scrobbles/views.py index 5a58c70..6c6931d 100644 --- a/vrobbler/apps/scrobbles/views.py +++ b/vrobbler/apps/scrobbles/views.py @@ -67,31 +67,64 @@ class RecentScrobbleList(ListView): def get_context_data(self, **kwargs): data = super().get_context_data(**kwargs) + view = self.request.GET.get('view', 'vrobbler') user = self.request.user if user.is_authenticated: + if view == 'vrobbler': + completed_for_user = Scrobble.objects.filter( + played_to_completion=True, user=user + ) + data['video_scrobble_list'] = completed_for_user.filter( + video__isnull=False + ).order_by('-timestamp')[:15] - completed_for_user = Scrobble.objects.filter( - played_to_completion=True, user=user - ) - data['video_scrobble_list'] = completed_for_user.filter( - video__isnull=False - ).order_by('-timestamp')[:15] + data['podcast_scrobble_list'] = completed_for_user.filter( + podcast_episode__isnull=False + ).order_by('-timestamp')[:15] - data['podcast_scrobble_list'] = completed_for_user.filter( - podcast_episode__isnull=False - ).order_by('-timestamp')[:15] + data['sport_scrobble_list'] = completed_for_user.filter( + sport_event__isnull=False + ).order_by('-timestamp')[:15] - 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[ + 'active_imports' + ] = AudioScrobblerTSVImport.objects.filter( + processing_started__isnull=False, + processed_finished__isnull=True, + user=self.request.user, + ) + if view == "maloja": + artist_params = {'user': user, 'media_type': 'Artist'} + data['current_artist_charts'] = { + "today": live_charts( + **artist_params, chart_period="today", limit=14 + ), + "week": live_charts( + **artist_params, chart_period="week", limit=14 + ), + "month": live_charts( + **artist_params, chart_period="month", limit=14 + ), + "all": live_charts(**artist_params, limit=14), + } + + track_params = {'user': user, 'media_type': 'Track'} + data['current_track_charts'] = { + "today": live_charts( + **track_params, chart_period="today", limit=14 + ), + "week": live_charts( + **track_params, chart_period="week", limit=14 + ), + "month": live_charts( + **track_params, chart_period="month", limit=14 + ), + "all": live_charts(**track_params, limit=14), + } + + data["view"] = view data["weekly_data"] = week_of_scrobbles(user=user) - data['counts'] = scrobble_counts(user) data['imdb_form'] = ScrobbleForm data['export_form'] = ExportScrobbleForm diff --git a/vrobbler/templates/base.html b/vrobbler/templates/base.html index 3e23444..1fa8620 100644 --- a/vrobbler/templates/base.html +++ b/vrobbler/templates/base.html @@ -302,54 +302,6 @@ - - {% block extra_js %} {% endblock %} diff --git a/vrobbler/templates/scrobbles/scrobble_list.html b/vrobbler/templates/scrobbles/scrobble_list.html index 432a508..0af3697 100644 --- a/vrobbler/templates/scrobbles/scrobble_list.html +++ b/vrobbler/templates/scrobbles/scrobble_list.html @@ -1,12 +1,52 @@ {% extends "base.html" %} {% load humanize %} +{% load dictkey %} +{% block head_extra %} + +{% endblock %} {% block content %}
-

Dashboard

+

Dashboard

like maloja
{% if user.is_authenticated %}
@@ -25,7 +65,7 @@ + {% if view == "vrobbler" %} + {% endif %}
{% if user.is_authenticated %} + {% if view == "maloja" %}
-

Today {{counts.today}} | This Week {{counts.week}} | This Month {{counts.month}} | - This Year {{counts.year}} | All Time {{counts.alltime}}

+

Top Artist

+ + +
+ {% for chart_name, artists in current_artist_charts.items %} +
+
+
+
+
{{artists.0.name}}
+ {% if artists.0.thumbnail %} + + {% endif %} +
+
+
+
+
+
{{artists.1.name}}
+ {% if artists.1.thumbnail %} + + {% endif %} +
+
+
{{artists.2.name}}
+ {% if artists.2.thumbnail %} + + {% endif %} +
+
+
{{artists.3.name}}
+ {% if artists.3.thumbnail %} + + {% endif %} +
+
+
{{artists.4.name}}
+ {% if artists.4.thumbnail %} + + {% endif %} +
+
+
+
+
+
+
{{artists.5.name}}
+ {% if artists.5.thumbnail %} + + {% endif %} +
+
+
{{artists.6.name}}
+ {% if artists.6.thumbnail %} + + {% endif %} +
+
+
{{artists.7.name}}
+ {% if artists.7.thumbnail %} + + {% endif %} +
+
+
{{artists.8.name}}
+ {% if artists.8.thumbnail %} + + {% endif %} +
+
+
{{artists.9.name}}
+ {% if artists.9.thumbnail %} + + {% endif %} +
+
+
{{artists.10.name}}
+ {% if artists.10.thumbnail %} + + {% endif %} +
+
+
{{artists.11.name}}
+ {% if artists.11.thumbnail %} + + {% endif %} +
+
+
{{artists.12.name}}
+ {% if artists.12thumbnail %} + + {% endif %} +
+
+
{{artists.13.name}}
+ {% if artists.13.thumbnail %} + + {% endif %} +
+
+
+
+
+ {% endfor %} +
+
+ +
+

Top Tracks

+ + +
+ {% for chart_name, tracks in current_track_charts.items %} +
+
+
+
+
{{tracks.0.title}}
+ {% if tracks.0.album.cover_image %} + + {% endif %} +
+
+
+
+
+
{{tracks.1.title}}
+ {% if tracks.1.album.cover_image %} + + {% endif %} +
+
+
{{tracks.2.title}}
+ {% if tracks.2.album.cover_image %} + + {% endif %} +
+
+
{{tracks.3.title}}
+ {% if tracks.3.album.cover_image %} + + {% endif %} +
+
+
{{tracks.4.title}}
+ {% if tracks.4.album.cover_image %} + + {% endif %} +
+
+
+
+
+
+
{{tracks.5.title}}
+ {% if tracks.5.album.cover_image %} + + {% endif %} +
+
+
{{tracks.6.title}}
+ {% if tracks.6.album.cover_image %} + + {% endif %} +
+
+
{{tracks.7.title}}
+ {% if tracks.7.album.cover_image %} + + {% endif %} +
+
+
{{tracks.8.title}}
+ {% if tracks.8.album.cover_image %} + + {% endif %} +
+
+
{{tracks.9.title}}
+ {% if tracks.9.album.cover_image %} + + {% endif %} +
+
+
{{tracks.10.title}}
+ {% if tracks.10.album.cover_image %} + + {% endif %} +
+
+
{{tracks.11.title}}
+ {% if tracks.11.album.cover_image %} + + {% endif %} +
+
+
{{tracks.12.title}}
+ {% if tracks.12.album.cover_image %} + + {% endif %} +
+
+
{{tracks.13.title}}
+ {% if tracks.13.album.cover_image %} + + {% endif %} +
+
+
+
+
+ {% endfor %} +
+
+ {% endif %} +
+

Last Scrobbles

+

Today {{counts.today}} | This Week {{counts.week}} | This Month {{counts.month}} | + This Year {{counts.year}} | All Time {{counts.alltime}}