From 74c32bc4d58140503286242b5b9a0121115e15c6 Mon Sep 17 00:00:00 2001 From: Colin Powell Date: Tue, 23 Jul 2024 16:24:59 -0400 Subject: [PATCH] [views] Move elaborate charts to the charts page --- vrobbler/apps/scrobbles/views.py | 27 +++++++++++++++++++ vrobbler/templates/scrobbles/chart_index.html | 5 ++++ .../templates/scrobbles/scrobble_list.html | 11 +++----- 3 files changed, 35 insertions(+), 8 deletions(-) diff --git a/vrobbler/apps/scrobbles/views.py b/vrobbler/apps/scrobbles/views.py index 9e54181..8e0a6fe 100644 --- a/vrobbler/apps/scrobbles/views.py +++ b/vrobbler/apps/scrobbles/views.py @@ -664,6 +664,33 @@ class ChartRecordView(TemplateView): ), "all": live_charts(**track_params, limit=limit), } + + limit = 14 + artist = {"user": user, "media_type": "Artist", "limit": limit} + # This is weird. They don't display properly as QuerySets, so we cast to lists + context_data["chart_keys"] = { + "today": "Today", + "last7": "Last 7 days", + "last30": "Last 30 days", + "year": "This year", + "all": "All time", + } + context_data["current_artist_charts"] = { + "today": list(live_charts(**artist, chart_period="today")), + "last7": list(live_charts(**artist, chart_period="last7")), + "last30": list(live_charts(**artist, chart_period="last30")), + "year": list(live_charts(**artist, chart_period="year")), + "all": list(live_charts(**artist)), + } + + track = {"user": user, "media_type": "Track", "limit": limit} + context_data["current_track_charts"] = { + "today": list(live_charts(**track, chart_period="today")), + "last7": list(live_charts(**track, chart_period="last7")), + "last30": list(live_charts(**track, chart_period="last30")), + "year": list(live_charts(**track, chart_period="year")), + "all": list(live_charts(**track)), + } return context_data # Date provided, lookup past charts, returning nothing if it's now or in the future. diff --git a/vrobbler/templates/scrobbles/chart_index.html b/vrobbler/templates/scrobbles/chart_index.html index d62f94d..9755b6c 100644 --- a/vrobbler/templates/scrobbles/chart_index.html +++ b/vrobbler/templates/scrobbles/chart_index.html @@ -3,6 +3,11 @@ {% block title %}{{name}}{% endblock %} {% block lists %} + +
+
{% if artist_charts %}
diff --git a/vrobbler/templates/scrobbles/scrobble_list.html b/vrobbler/templates/scrobbles/scrobble_list.html index 9abd6dd..3914052 100644 --- a/vrobbler/templates/scrobbles/scrobble_list.html +++ b/vrobbler/templates/scrobbles/scrobble_list.html @@ -82,19 +82,14 @@ {% if not user.is_authenticated %}

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

- {% endif %} - + {% else %}
- {% if user.is_authenticated %} -
- {% include "scrobbles/_top_charts.html" %} -
-
{% include "scrobbles/_last_scrobbles.html" %}
- {% endif %}
+ {% endif %} +