From: David ‘Bombe’ Roden Date: Fri, 10 May 2013 23:31:59 +0000 (+0200) Subject: Store year and party as a tuple. X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=14af749bfa4b237c87febc998986dbfd103807bb;p=demoscenemusic.git Store year and party as a tuple. --- 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 }}