mirror of
https://github.com/django-helpdesk/django-helpdesk.git
synced 2025-08-09 16:15:12 +02:00
add a new field to KBItem model to keep track of all users who voted, and make changes to the vote function so that it checks whether a user has already votred
This commit is contained in:
@ -46,9 +46,11 @@ def vote(request, item):
|
||||
item = get_object_or_404(KBItem, pk=item)
|
||||
vote = request.GET.get('vote', None)
|
||||
if vote in ('up', 'down'):
|
||||
item.votes += 1
|
||||
if vote == 'up':
|
||||
item.recommendations += 1
|
||||
item.save()
|
||||
if request.user not in item.voted_by:
|
||||
|
||||
item.votes += 1
|
||||
if vote == 'up':
|
||||
item.recommendations += 1
|
||||
item.save()
|
||||
|
||||
return HttpResponseRedirect(item.get_absolute_url())
|
||||
|
Reference in New Issue
Block a user