[charts] Clean up how they're displayed
This commit is contained in:
@ -14,13 +14,6 @@ class TrackListView(ScrobbleableListView):
|
||||
class TrackDetailView(ScrobbleableDetailView):
|
||||
model = Track
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context_data = super().get_context_data(**kwargs)
|
||||
context_data["charts"] = ChartRecord.objects.filter(
|
||||
track=self.object, rank__in=[1, 2, 3]
|
||||
)
|
||||
return context_data
|
||||
|
||||
|
||||
class ArtistListView(generic.ListView):
|
||||
model = Artist
|
||||
@ -57,9 +50,16 @@ class ArtistDetailView(generic.DetailView):
|
||||
]
|
||||
|
||||
context_data["tracks_ranked"] = tracks_ranked
|
||||
context_data["charts"] = ChartRecord.objects.filter(
|
||||
|
||||
charts_qs = ChartRecord.objects.filter(
|
||||
artist=self.object, rank__in=[1, 2, 3]
|
||||
)
|
||||
).exclude(day__isnull=False)
|
||||
from collections import OrderedDict
|
||||
|
||||
grouped = OrderedDict()
|
||||
for chart in charts_qs:
|
||||
grouped.setdefault(chart.period_type, []).append(chart)
|
||||
context_data["charts"] = grouped
|
||||
|
||||
from scrobbles.models import Scrobble
|
||||
|
||||
|
||||
Reference in New Issue
Block a user