mirror of
https://github.com/Sosokker/ku-polls.git
synced 2025-12-19 05:24:05 +01:00
Add success message when vote again/ delete participate in admin
This commit is contained in:
parent
50874dbf40
commit
e733fac7aa
@ -14,7 +14,6 @@ class QuestionAdmin(admin.ModelAdmin):
|
||||
("Published date", {"fields": ["pub_date"], "classes": ["collapse"]}),
|
||||
("End date", {"fields": ["end_date"], "classes": ["collapse"]}),
|
||||
("Sentiment Vote count", {"fields": ["up_vote_count", "down_vote_count"]}),
|
||||
("Participant count", {"fields": ["participant_count"]}),
|
||||
]
|
||||
list_display = ["question_text", "pub_date", "end_date", "was_published_recently", "can_vote"]
|
||||
inlines = [ChoiceInline]
|
||||
|
||||
@ -82,7 +82,7 @@
|
||||
<div class="relative">
|
||||
<!-- INFO -->
|
||||
<div class="rounded-lg bg-white p-4 shadow-md border-solid border-2 border-yellow-500 relative z-10 transform translate-y-0 hover:translate-y-1 transition-transform">
|
||||
<h2 class="mb-2 text-xl font-bold">{{ question.question_text }}</h2>
|
||||
<h2 class="mb-2 text-xl font-bold truncate">{{ question.question_text }}</h2>
|
||||
<hr class="h-px my-2 bg-gray-200 border-0 dark:bg-gray-400" />
|
||||
<p class="mb-2 text-gray-600">{{ question.short_description }}</p>
|
||||
<div class="mb-2 flex items-center text-gray-600">
|
||||
@ -128,7 +128,7 @@
|
||||
<div class="relative">
|
||||
<!-- INFO -->
|
||||
<div class="rounded-lg bg-white p-4 shadow-md border-solid border-2 border-neutral-500 relative z-10 transform translate-y-0 hover:translate-y-1 transition-transform">
|
||||
<h2 class="mb-2 text-xl font-semibold">{{ question.question_text }}</h2>
|
||||
<h2 class="mb-2 text-xl font-semibold truncate">{{ question.question_text }}</h2>
|
||||
<hr class="h-px my-2 bg-gray-200 border-0 dark:bg-gray-400" />
|
||||
<p class="mb-2 text-gray-600">{{ question.short_description }}</p>
|
||||
<div class="mb-2 flex items-center text-gray-600">
|
||||
|
||||
@ -112,7 +112,9 @@ def vote(request, question_id):
|
||||
messages.success(request, "You vote successfully🥳")
|
||||
return HttpResponseRedirect(reverse("polls:results", args=(question.id,)))
|
||||
else:
|
||||
messages.success(request, "You vote successfully🥳")
|
||||
Vote.objects.create(choice=selected_choice, user=request.user, question=question).save()
|
||||
return HttpResponseRedirect(reverse("polls:results", args=(question.id,)))
|
||||
else:
|
||||
messages.error(request, "You cannot vote by typing the URL.")
|
||||
return render(request, "polls/detail.html", {"question": question})
|
||||
|
||||
Loading…
Reference in New Issue
Block a user