From 8e8d25aa1d187d221fc4c744072eb76971109fc3 Mon Sep 17 00:00:00 2001 From: Colin Powell Date: Wed, 18 Mar 2026 11:07:45 -0400 Subject: [PATCH] [podcasts] Add aggregation to templates --- vrobbler/apps/podcasts/views.py | 17 +++++--------- vrobbler/templates/_scrobblable_list.html | 6 +++++ vrobbler/templates/podcasts/podcast_list.html | 22 +------------------ 3 files changed, 13 insertions(+), 32 deletions(-) diff --git a/vrobbler/apps/podcasts/views.py b/vrobbler/apps/podcasts/views.py index 26bedc6..eb954ab 100644 --- a/vrobbler/apps/podcasts/views.py +++ b/vrobbler/apps/podcasts/views.py @@ -1,15 +1,15 @@ import datetime from django.utils import timezone from django.views import generic -from podcasts.models import Podcast +from podcasts.models import Podcast, PodcastEpisode from scrobbles.models import Scrobble from scrobbles.views import ScrobbleableListView, ScrobbleableDetailView -class PodcastListView(generic.ListView): - model = Podcast - paginate_by = 20 +class PodcastListView(ScrobbleableListView): + model = PodcastEpisode + template_name = "podcasts/podcast_list.html" def get_context_data(self, **kwargs): context_data = super().get_context_data(**kwargs) @@ -36,10 +36,7 @@ class PodcastListView(generic.ListView): if podcast: podcasts_this_week[podcast.id] = { "podcast": podcast, - "count": podcasts_this_week.get(podcast.id, {}).get( - "count", 0 - ) - + 1, + "count": podcasts_this_week.get(podcast.id, {}).get("count", 0) + 1, } podcasts_this_month = {} @@ -48,9 +45,7 @@ class PodcastListView(generic.ListView): if podcast: podcasts_this_month[podcast.id] = { "podcast": podcast, - "count": podcasts_this_month.get(podcast.id, {}).get( - "count", 0 - ) + "count": podcasts_this_month.get(podcast.id, {}).get("count", 0) + 1, } diff --git a/vrobbler/templates/_scrobblable_list.html b/vrobbler/templates/_scrobblable_list.html index f9c529c..8dde497 100644 --- a/vrobbler/templates/_scrobblable_list.html +++ b/vrobbler/templates/_scrobblable_list.html @@ -6,6 +6,9 @@ Latest Title + {% if podcast_list or object_list.0.podcast %} + Podcast + {% endif %} Scrobbles Start @@ -16,6 +19,9 @@ {{obj.scrobble_set.last.local_timestamp}} {{obj}} + {% if podcast_list or obj.podcast %} + {% if obj.podcast %}{{obj.podcast}}{% endif %} + {% endif %} {% if request.user.is_authenticated %} {{obj.scrobble_count}} Scrobble diff --git a/vrobbler/templates/podcasts/podcast_list.html b/vrobbler/templates/podcasts/podcast_list.html index aec49c4..b86bf93 100644 --- a/vrobbler/templates/podcasts/podcast_list.html +++ b/vrobbler/templates/podcasts/podcast_list.html @@ -52,27 +52,7 @@
- - - - - - - - - - {% for obj in object_list.all %} - {{obj.episodes}} - {% for episode in obj.podcastepisode_set.all %} - - - - - - {% endfor %} - {% endfor %} - -
EpisodePodcastScrobbles
{{episode}}{{obj}}{{episode.scrobble_set.count}}
+ {% include "_scrobblable_list.html" %}