Overview page

Met klassiek onbruikbare interface dit jaar.
This commit is contained in:
2024-02-26 17:41:10 +01:00
parent 7f199b6886
commit 51085beba3
6 changed files with 61 additions and 4 deletions
+18 -4
View File
@@ -75,9 +75,6 @@ class NominateView(LoginRequiredMixin, View):
json = spt.get_song_info(spotify_id)
except:
return TemplateResponse(request, "Nominate.html", {"error": "Fout bij het ophalen van het liedje."})
print(json)
print("hey")
# Album artists
album_artists = []
@@ -153,4 +150,21 @@ class UndoView(LoginRequiredMixin, View):
except Vote.DoesNotExist:
raise Exception(f"{request.user} did not vote for {track}")
vote.delete()
return HttpResponseRedirect('/vote/')
return HttpResponseRedirect('/vote/')
class OverView(LoginRequiredMixin, View):
def get(self, request):
votes = Vote.objects.select_related().distinct()
artists = {}
for vote in votes:
for artist in vote.track.artists.all():
if not artists.get(artist.name):
artists[artist.name] = {}
for artist in vote.track.album.artists.all():
if not artists[artist.name].get(vote.track.album.name):
artists[artist.name][vote.track.album.name] = []
artists[artist.name][vote.track.album.name] += [vote.track]
context = {
"artists": artists
}
return TemplateResponse(request, "Overview.html", context)