votes left count

This commit is contained in:
2024-08-05 20:54:46 +02:00
parent ce788a545c
commit 8c9d97c317
3 changed files with 15 additions and 3 deletions
+3 -2
View File
@@ -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: