[podcasts] Add aggregation to templates
This commit is contained in:
@ -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,
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user