diff --git a/helpdesk/templates/helpdesk/kb_category_base.html b/helpdesk/templates/helpdesk/kb_category_base.html index e1ce3d2f..4b276f0e 100644 --- a/helpdesk/templates/helpdesk/kb_category_base.html +++ b/helpdesk/templates/helpdesk/kb_category_base.html @@ -25,8 +25,8 @@
{% if request.user.pk %}
-
-
+
+
{% endif %} {% if staff %} diff --git a/helpdesk/tests/test_kb.py b/helpdesk/tests/test_kb.py index 23525586..ab90ca3b 100644 --- a/helpdesk/tests/test_kb.py +++ b/helpdesk/tests/test_kb.py @@ -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') diff --git a/helpdesk/urls.py b/helpdesk/urls.py index 48eab200..dc3f0eef 100644 --- a/helpdesk/urls.py +++ b/helpdesk/urls.py @@ -251,7 +251,7 @@ if helpdesk_settings.HELPDESK_KB_ENABLED: path("kb/", kb.index, name="kb_index"), re_path(r"^kb/(?P[A-Za-z0-9_-]+)/$", kb.category, name="kb_category"), - path("kb//vote/", kb.vote, name="kb_vote"), + path("kb//vote/(?Pup|down)/", kb.vote, name="kb_vote"), re_path( r"^kb_iframe/(?P[A-Za-z0-9_-]+)/$", kb.category_iframe, diff --git a/helpdesk/views/kb.py b/helpdesk/views/kb.py index 1f619a65..cd1983ef 100644 --- a/helpdesk/views/kb.py +++ b/helpdesk/views/kb.py @@ -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