Overview page
Met klassiek onbruikbare interface dit jaar.
This commit is contained in:
@@ -26,6 +26,10 @@ class Track(models.Model):
|
|||||||
def name_sanitized(self):
|
def name_sanitized(self):
|
||||||
return re.match("[^\-\(]*\w", self.name)[0]
|
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):
|
def is_duplicate_of(self):
|
||||||
tracks = Track.objects.exclude(id=self.id).filter(name__startswith=self.name_sanitized)
|
tracks = Track.objects.exclude(id=self.id).filter(name__startswith=self.name_sanitized)
|
||||||
artists = [artist.name for artist in self.artists.all()]
|
artists = [artist.name for artist in self.artists.all()]
|
||||||
|
|||||||
@@ -46,6 +46,11 @@ input#spotify-input + input[type=submit]{
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.tree-view.overview {
|
||||||
|
height: 400px;
|
||||||
|
overflow-y: scroll;
|
||||||
|
}
|
||||||
|
|
||||||
#bsod, .hide {
|
#bsod, .hide {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,9 @@
|
|||||||
<li role="tab" {% if request.path == '/track/' %}aria-selected="true" {% endif %}>
|
<li role="tab" {% if request.path == '/track/' %}aria-selected="true" {% endif %}>
|
||||||
<a href="{% url 'nominate' %}">Nomineren</a>
|
<a href="{% url 'nominate' %}">Nomineren</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li role="tab" {% if request.path == '/overview/' %}aria-selected="true" {% endif %}>
|
||||||
|
<a href="{% url 'overview' %}">Overzicht</a>
|
||||||
|
</li>
|
||||||
<li role="tab" {% if request.path == '/settings/' %}aria-selected="true" {% endif %}>
|
<li role="tab" {% if request.path == '/settings/' %}aria-selected="true" {% endif %}>
|
||||||
<a href="{% url 'settings' %}">Instellingen</a>
|
<a href="{% url 'settings' %}">Instellingen</a>
|
||||||
</li>
|
</li>
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
{% extends "Base.html" %}
|
||||||
|
|
||||||
|
{% block main-content %}
|
||||||
|
<p>Onderstaand alle nummers waar je al op gestemd hebt.</p>
|
||||||
|
<ul class="tree-view overview">
|
||||||
|
{% for artist, albums in artists.items %}
|
||||||
|
<li>
|
||||||
|
<details>
|
||||||
|
<summary>{{artist}}</summary>
|
||||||
|
<ul>
|
||||||
|
{% for album, tracks in albums.items %}
|
||||||
|
<li>
|
||||||
|
<details>
|
||||||
|
<summary>{{album}}</summary>
|
||||||
|
<ul>
|
||||||
|
{% for track in tracks %}
|
||||||
|
<li>
|
||||||
|
<a href="{{track.link}}" target="_blank">{{track.name}}</a>
|
||||||
|
</li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
</details>
|
||||||
|
</li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
</details>
|
||||||
|
</li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
{% endblock %}
|
||||||
@@ -8,5 +8,6 @@ urlpatterns = [
|
|||||||
path('vote/', views.VoteView.as_view(), name="vote"),
|
path('vote/', views.VoteView.as_view(), name="vote"),
|
||||||
path('vote/undo', views.UndoView.as_view(), name="undo"),
|
path('vote/undo', views.UndoView.as_view(), name="undo"),
|
||||||
path('settings/', views.SettingsView.as_view(), name="settings"),
|
path('settings/', views.SettingsView.as_view(), name="settings"),
|
||||||
|
path('overview/', views.OverView.as_view(), name="overview"),
|
||||||
path('', views.AuthView.as_view()),
|
path('', views.AuthView.as_view()),
|
||||||
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
||||||
|
|||||||
+17
-3
@@ -75,9 +75,6 @@ class NominateView(LoginRequiredMixin, View):
|
|||||||
json = spt.get_song_info(spotify_id)
|
json = spt.get_song_info(spotify_id)
|
||||||
except:
|
except:
|
||||||
return TemplateResponse(request, "Nominate.html", {"error": "Fout bij het ophalen van het liedje."})
|
return TemplateResponse(request, "Nominate.html", {"error": "Fout bij het ophalen van het liedje."})
|
||||||
print(json)
|
|
||||||
print("hey")
|
|
||||||
|
|
||||||
|
|
||||||
# Album artists
|
# Album artists
|
||||||
album_artists = []
|
album_artists = []
|
||||||
@@ -154,3 +151,20 @@ class UndoView(LoginRequiredMixin, View):
|
|||||||
raise Exception(f"{request.user} did not vote for {track}")
|
raise Exception(f"{request.user} did not vote for {track}")
|
||||||
vote.delete()
|
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)
|
||||||
Reference in New Issue
Block a user