mirror of
https://github.com/django-helpdesk/django-helpdesk.git
synced 2024-12-12 18:00:45 +01:00
Update kb vote function
This commit is contained in:
parent
f710c07927
commit
8d2b09bb11
@ -25,8 +25,8 @@
|
||||
<div class="row">
|
||||
{% if request.user.pk %}
|
||||
<div class="col-sm">
|
||||
<a href='{% url "helpdesk:kb_vote" item.pk %}?vote=up'><div class="btn btn-success btn-circle btn-xl"><i class="fa fa-thumbs-up fa-lg"></i></div></a>
|
||||
<a href='{% url "helpdesk:kb_vote" item.pk %}?vote=down'><div class="btn btn-danger btn-circle btn-xl"><i class="fa fa-thumbs-down fa-lg"></i></div></a>
|
||||
<a href='{% url "helpdesk:kb_vote" item.pk "up" %}'><div class="btn btn-success btn-circle btn-xl"><i class="fa fa-thumbs-up fa-lg"></i></div></a>
|
||||
<a href='{% url "helpdesk:kb_vote" item.pk "down" %}'><div class="btn btn-danger btn-circle btn-xl"><i class="fa fa-thumbs-down fa-lg"></i></div></a>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if staff %}
|
||||
|
@ -67,14 +67,14 @@ class KBTests(TestCase):
|
||||
self.client.login(username=self.user.get_username(),
|
||||
password='password')
|
||||
response = self.client.get(
|
||||
reverse('helpdesk:kb_vote', args=(self.kbitem1.pk,)) + "?vote=up")
|
||||
reverse('helpdesk:kb_vote', args=(self.kbitem1.pk, "up")))
|
||||
cat_url = reverse('helpdesk:kb_category',
|
||||
args=("test_cat",)) + "?kbitem=1"
|
||||
self.assertRedirects(response, cat_url)
|
||||
response = self.client.get(cat_url)
|
||||
self.assertContains(response, '1 people found this answer useful of 1')
|
||||
response = self.client.get(
|
||||
reverse('helpdesk:kb_vote', args=(self.kbitem1.pk,)) + "?vote=down")
|
||||
reverse('helpdesk:kb_vote', args=(self.kbitem1.pk, "down")))
|
||||
self.assertRedirects(response, cat_url)
|
||||
response = self.client.get(cat_url)
|
||||
self.assertContains(response, '0 people found this answer useful of 1')
|
||||
|
@ -251,7 +251,7 @@ if helpdesk_settings.HELPDESK_KB_ENABLED:
|
||||
path("kb/", kb.index, name="kb_index"),
|
||||
re_path(r"^kb/(?P<slug>[A-Za-z0-9_-]+)/$",
|
||||
kb.category, name="kb_category"),
|
||||
path("kb/<int:item>/vote/", kb.vote, name="kb_vote"),
|
||||
path("kb/<int:item>/vote/(?P<vote>up|down)/", kb.vote, name="kb_vote"),
|
||||
re_path(
|
||||
r"^kb_iframe/(?P<slug>[A-Za-z0-9_-]+)/$",
|
||||
kb.category_iframe,
|
||||
|
@ -59,9 +59,8 @@ def category_iframe(request, slug):
|
||||
return category(request, slug, iframe=True)
|
||||
|
||||
|
||||
def vote(request, item):
|
||||
def vote(request, item, vote):
|
||||
item = get_object_or_404(KBItem, pk=item)
|
||||
vote = request.GET.get('vote', None)
|
||||
if vote == 'up':
|
||||
if not item.voted_by.filter(pk=request.user.pk):
|
||||
item.votes += 1
|
||||
|
Loading…
Reference in New Issue
Block a user