mirror of
https://gitea.mueller.network/extern/django-helpdesk.git
synced 2024-12-18 12:40:40 +01:00
Forcing POST urls for votes
This commit is contained in:
parent
a2bf156d59
commit
5ae1c1fdcb
@ -61,21 +61,22 @@ def category_iframe(request, slug):
|
|||||||
|
|
||||||
def vote(request, item, vote):
|
def vote(request, item, vote):
|
||||||
item = get_object_or_404(KBItem, pk=item)
|
item = get_object_or_404(KBItem, pk=item)
|
||||||
if vote == 'up':
|
if request.method == "POST":
|
||||||
if not item.voted_by.filter(pk=request.user.pk):
|
if vote == 'up':
|
||||||
item.votes += 1
|
if not item.voted_by.filter(pk=request.user.pk):
|
||||||
item.voted_by.add(request.user.pk)
|
item.votes += 1
|
||||||
item.recommendations += 1
|
item.voted_by.add(request.user.pk)
|
||||||
if item.downvoted_by.filter(pk=request.user.pk):
|
item.recommendations += 1
|
||||||
item.votes -= 1
|
if item.downvoted_by.filter(pk=request.user.pk):
|
||||||
item.downvoted_by.remove(request.user.pk)
|
item.votes -= 1
|
||||||
if vote == 'down':
|
item.downvoted_by.remove(request.user.pk)
|
||||||
if not item.downvoted_by.filter(pk=request.user.pk):
|
if vote == 'down':
|
||||||
item.votes += 1
|
if not item.downvoted_by.filter(pk=request.user.pk):
|
||||||
item.downvoted_by.add(request.user.pk)
|
item.votes += 1
|
||||||
item.recommendations -= 1
|
item.downvoted_by.add(request.user.pk)
|
||||||
if item.voted_by.filter(pk=request.user.pk):
|
item.recommendations -= 1
|
||||||
item.votes -= 1
|
if item.voted_by.filter(pk=request.user.pk):
|
||||||
item.voted_by.remove(request.user.pk)
|
item.votes -= 1
|
||||||
item.save()
|
item.voted_by.remove(request.user.pk)
|
||||||
|
item.save()
|
||||||
return HttpResponseRedirect(item.get_absolute_url())
|
return HttpResponseRedirect(item.get_absolute_url())
|
||||||
|
Loading…
Reference in New Issue
Block a user