From 14af749bfa4b237c87febc998986dbfd103807bb Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sat, 11 May 2013 01:31:59 +0200 Subject: [PATCH] Store year and party as a tuple. --- data/views.py | 10 +++++----- templates/home.html | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/data/views.py b/data/views.py index bb3b52c..3a08a7a 100644 --- a/data/views.py +++ b/data/views.py @@ -7,13 +7,13 @@ from DemosceneMusic.data.models import Track def home(request): tracks = Track.objects.all().annotate().order_by('releases__party', 'trackartist__artist__name', 'name', 'remix') - partyCompoTracks = defaultdict(lambda: defaultdict(list)) + partyYearCompoTracks = defaultdict(lambda: defaultdict(list)) for track in tracks: for release in track.releases.all(): - partyCompoTracks[release.party][release.compo].append(track) - for party, compoTracks in partyCompoTracks.iteritems(): - partyCompoTracks[party] = dict(compoTracks) - return render_to_response('templates/home.html', {'partyTracks': dict(partyCompoTracks)}) + partyYearCompoTracks[(release.party, release.year)][release.compo].append(track) + for partyYear, compoTracks in partyYearCompoTracks.iteritems(): + partyYearCompoTracks[partyYear] = dict(compoTracks) + return render_to_response('templates/home.html', {'partyTracks': dict(partyYearCompoTracks)}) def track(request, trackId): return HttpResponse('Track: %s' % trackId) diff --git a/templates/home.html b/templates/home.html index 3353229..7f0d87e 100644 --- a/templates/home.html +++ b/templates/home.html @@ -8,7 +8,7 @@ {% for party, compoTracks in partyTracks.items %}
-

{{ party }}

+

{{ party.0 }} {{ party.1 }}

{% for compo, tracks in compoTracks.items %}

{{ compo }}