diff --git a/playlist/models/track.py b/playlist/models/track.py
index eb0b74d..d12c6d4 100644
--- a/playlist/models/track.py
+++ b/playlist/models/track.py
@@ -26,6 +26,10 @@ class Track(models.Model):
def name_sanitized(self):
return re.match("[^\-\(]*\w", self.name)[0]
+ @property
+ def link(self):
+ return f'https://open.spotify.com/track/{self.id}'
+
def is_duplicate_of(self):
tracks = Track.objects.exclude(id=self.id).filter(name__startswith=self.name_sanitized)
artists = [artist.name for artist in self.artists.all()]
diff --git a/playlist/static/style.css b/playlist/static/style.css
index 1b64d84..ed64511 100644
--- a/playlist/static/style.css
+++ b/playlist/static/style.css
@@ -46,6 +46,11 @@ input#spotify-input + input[type=submit]{
}
+.tree-view.overview {
+ height: 400px;
+ overflow-y: scroll;
+}
+
#bsod, .hide {
display: none;
}
diff --git a/playlist/templates/Base.html b/playlist/templates/Base.html
index be308ae..78cf566 100644
--- a/playlist/templates/Base.html
+++ b/playlist/templates/Base.html
@@ -25,6 +25,9 @@
Nomineren
+
+ Overzicht
+
Instellingen
diff --git a/playlist/templates/Overview.html b/playlist/templates/Overview.html
new file mode 100644
index 0000000..c67975e
--- /dev/null
+++ b/playlist/templates/Overview.html
@@ -0,0 +1,30 @@
+{% extends "Base.html" %}
+
+{% block main-content %}
+Onderstaand alle nummers waar je al op gestemd hebt.
+
+ {% for artist, albums in artists.items %}
+ -
+
+ {{artist}}
+
+ {% for album, tracks in albums.items %}
+ -
+
+ {{album}}
+
+
+
+ {% endfor %}
+
+
+
+ {% endfor %}
+
+{% endblock %}
diff --git a/playlist/urls.py b/playlist/urls.py
index aa08631..140d926 100644
--- a/playlist/urls.py
+++ b/playlist/urls.py
@@ -8,5 +8,6 @@ urlpatterns = [
path('vote/', views.VoteView.as_view(), name="vote"),
path('vote/undo', views.UndoView.as_view(), name="undo"),
path('settings/', views.SettingsView.as_view(), name="settings"),
+ path('overview/', views.OverView.as_view(), name="overview"),
path('', views.AuthView.as_view()),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
diff --git a/playlist/views.py b/playlist/views.py
index f0af297..422dfc0 100644
--- a/playlist/views.py
+++ b/playlist/views.py
@@ -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/')
\ No newline at end of file
+ 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)
\ No newline at end of file