From b20f600db2e6de87b73d5fffd11a267c098807ee Mon Sep 17 00:00:00 2001 From: Timothy Hobbs Date: Wed, 8 Jan 2020 22:57:08 +0100 Subject: [PATCH] KB UX improvements --- helpdesk/models.py | 3 +++ .../templates/helpdesk/kb_category_base.html | 22 ++++++++++++++----- helpdesk/views/kb.py | 2 ++ 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/helpdesk/models.py b/helpdesk/models.py index 84dcead7..12d316c5 100644 --- a/helpdesk/models.py +++ b/helpdesk/models.py @@ -1323,6 +1323,9 @@ class KBItem(models.Model): from django.urls import reverse return str(reverse('helpdesk:list')) + "?kbitem=" + str(self.pk) + def num_open_tickets(self): + return Ticket.objects.filter(kbitem=self, status__in=(1, 2)).count() + def get_markdown(self): return get_markdown(self.answer) diff --git a/helpdesk/templates/helpdesk/kb_category_base.html b/helpdesk/templates/helpdesk/kb_category_base.html index 9ab29eca..b8bb973f 100644 --- a/helpdesk/templates/helpdesk/kb_category_base.html +++ b/helpdesk/templates/helpdesk/kb_category_base.html @@ -17,15 +17,23 @@

{{ item.get_markdown }}

{% if request.user.pk %} -
+
-
-
- {% blocktrans with recommendations=item.recommendations votes=item.votes %}{{ recommendations }} people found this answer useful of {{votes}}. {% endblocktrans %} {% endif %} - + {% if staff %} + + + + + {% endif %} + + + +
+
+ {% blocktrans with recommendations=item.recommendations votes=item.votes %}{{ recommendations }} people found this answer useful of {{votes}}{% endblocktrans %}
@@ -34,5 +42,7 @@ {% endfor %} {% if category.queue %} - + + + {% endif %} diff --git a/helpdesk/views/kb.py b/helpdesk/views/kb.py index 78943850..ee164ea9 100644 --- a/helpdesk/views/kb.py +++ b/helpdesk/views/kb.py @@ -40,6 +40,7 @@ def category(request, slug, iframe=False): template = 'helpdesk/kb_category.html' if iframe: template = 'helpdesk/kb_category_iframe.html' + staff = request.user.is_authenticated and request.user.is_staff return render(request, template, { 'category': category, 'items': items, @@ -47,6 +48,7 @@ def category(request, slug, iframe=False): 'query_param_string': qparams.urlencode(), 'helpdesk_settings': helpdesk_settings, 'iframe': iframe, + 'staff': staff, })