nomination quota

This commit is contained in:
2024-02-26 22:51:35 +01:00
parent 2861c856af
commit 4df913c7fe
5 changed files with 59 additions and 3 deletions
+7
View File
@@ -47,8 +47,13 @@ class VoteView(LoginRequiredMixin, View):
class NominateView(LoginRequiredMixin, View):
def get(self, request):
(profile,_) = Profile.objects.get_or_create(user=request.user)
profile.update_quota()
return TemplateResponse(request, "Nominate.html", {})
def post(self, request):
(profile,_) = Profile.objects.get_or_create(user=request.user)
if profile.quota < 1:
return TemplateResponse(request, "Nominate.html", {"error": "Nee nee nee, dat gaan we dus even niet doen."})
try:
spotify_link = self.request.POST['spotify_link']
@@ -115,6 +120,8 @@ class NominateView(LoginRequiredMixin, View):
track.album = album
track.save()
get_banter.delay(track.id)
profile.quota -= 1
profile.save()
return TemplateResponse(request, "Nominate.html", {"nominated": track})