diff --git a/playlist/templates/Vote.html b/playlist/templates/Vote.html
index 327b6d6..4bd0b70 100644
--- a/playlist/templates/Vote.html
+++ b/playlist/templates/Vote.html
@@ -1,7 +1,7 @@
{% extends "Base.html" %}
{% block window-title %}
-Stemmen
+Stemmen{% if vote_left or skip_left %}: {{vote_left}}+{{skip_left}} te gaan.{% endif %}
{% endblock %}
{% block main-content %}
diff --git a/playlist/utils.py b/playlist/utils.py
index 1298079..3a61e16 100644
--- a/playlist/utils.py
+++ b/playlist/utils.py
@@ -25,6 +25,17 @@ def get_unvoted(user):
return (Track.objects.get(pk=random_track), skipped)
except IndexError:
return (None, False)
+
+def get_unvoted_count(user):
+ votes = set(Vote.objects.filter(user=user).values_list('track_id', flat=True))
+ tracks = set(Track.objects.filter(banter_done=True).values_list('pk', flat=True))
+ try:
+ queue = list(tracks - votes)
+ skipped = list(Vote.objects.filter(user=user).filter(skipped=True).values_list('track_id', flat=True))
+ return (len(queue), len(skipped))
+ except IndexError:
+ return (0, 0)
+
def track_from_json(json):
"""Creates the track, album and artist from spotify response."""
diff --git a/playlist/views.py b/playlist/views.py
index ecb3220..eb99186 100644
--- a/playlist/views.py
+++ b/playlist/views.py
@@ -11,7 +11,7 @@ from datetime import UTC, datetime
from collections import OrderedDict
from dotenv import load_dotenv
from .models import Track, Artist, Album, Vote, Background, Profile, Playlist
-from .utils import track_from_json, get_unvoted
+from .utils import track_from_json, get_unvoted, get_unvoted_count
from .spotify import spt
from .tasks import get_banter, get_and_dither_image
@@ -27,11 +27,12 @@ class AuthView(View):
class VoteView(LoginRequiredMixin, View):
def get(self, request, undo=None):
(track, skipped) = get_unvoted(request.user)
+ (vote_left, skip_left) = get_unvoted_count(request.user)
if track and not track.album.image:
if not track.album.image_url:
get_and_dither_image("https://picsum.photos/256", track.album, "image")
get_and_dither_image(track.album.image_url, track.album, "image")
- return TemplateResponse(request, "Vote.html", {"track": track, "undo": undo, "skipped": skipped})
+ return TemplateResponse(request, "Vote.html", {"track": track, "undo": undo, "skipped": skipped, "vote_left": vote_left, "skip_left": skip_left})
def post(self, request):
(profile,_) = Profile.objects.get_or_create(user=request.user)
try: