From cdddc7999830e323f2769dc2ca7db24cac732448 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Dlouh=C3=BD?= Date: Tue, 25 Feb 2020 14:26:03 +0100 Subject: [PATCH 01/10] make Knowledge Base templates more flexibly overidable --- helpdesk/templates/helpdesk/kb_category_base.html | 12 +++++++++--- .../helpdesk/public_create_ticket_base.html | 2 ++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/helpdesk/templates/helpdesk/kb_category_base.html b/helpdesk/templates/helpdesk/kb_category_base.html index 5b449b7f..8ca89bd7 100644 --- a/helpdesk/templates/helpdesk/kb_category_base.html +++ b/helpdesk/templates/helpdesk/kb_category_base.html @@ -1,6 +1,8 @@ {% load i18n %} -

{% trans 'Knowledgebase Category' %}:{% blocktrans with category.title as kbcat %}{{ kbcat }}{% endblocktrans %}

-

{{ category.description }}

+{% block header %} +

{% blocktrans with category.title as kbcat %}{{ kbcat }}{% endblocktrans %}

+

{{ category.description|linebreaks }}

+{% endblock %}
{% for item in items %}
@@ -43,8 +45,12 @@
{% endfor %}
+{% block footer %} +{% endblock %} {% if category.queue %} + {% block submit_button %} + {% endblock %} {% endif %} diff --git a/helpdesk/templates/helpdesk/public_create_ticket_base.html b/helpdesk/templates/helpdesk/public_create_ticket_base.html index 82cf375b..45325642 100644 --- a/helpdesk/templates/helpdesk/public_create_ticket_base.html +++ b/helpdesk/templates/helpdesk/public_create_ticket_base.html @@ -3,7 +3,9 @@ {% with request|load_helpdesk_settings as helpdesk_settings %} {% if helpdesk_settings.HELPDESK_SUBMIT_A_TICKET_PUBLIC %} +{% block form_header %}

{% trans "Unless otherwise stated, all fields are required." %} {% trans "Please provide as descriptive a title and description as possible." %}

+{% endblock %}
{{ form|bootstrap4form }} From 07d6ee7f87d6170e35bc74f060df343dc2573d12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Dlouh=C3=BD?= Date: Tue, 25 Feb 2020 14:25:52 +0100 Subject: [PATCH 02/10] fix typo --- helpdesk/forms.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helpdesk/forms.py b/helpdesk/forms.py index 74002389..37c08c07 100644 --- a/helpdesk/forms.py +++ b/helpdesk/forms.py @@ -183,7 +183,7 @@ class AbstractTicketForm(CustomFieldMixin, forms.Form): self.fields['kbitem'] = forms.ChoiceField( widget=forms.Select(attrs={'class': 'form-control'}), required=False, - label=_('Knowedge Base Item'), + label=_('Knowledge Base Item'), choices=[(kbi.pk, kbi.title) for kbi in KBItem.objects.filter(category=kbcategory.pk)], ) From 5a594b7436228544efd0f49ccf6371001d090393 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Dlouh=C3=BD?= Date: Tue, 25 Feb 2020 14:25:24 +0100 Subject: [PATCH 03/10] add KBCategory.name, improve KBCategory admin --- helpdesk/admin.py | 6 +++- .../migrations/0030_add_kbcategory_name.py | 33 +++++++++++++++++++ helpdesk/models.py | 9 +++-- 3 files changed, 45 insertions(+), 3 deletions(-) create mode 100644 helpdesk/migrations/0030_add_kbcategory_name.py diff --git a/helpdesk/admin.py b/helpdesk/admin.py index 5530aa51..88086130 100644 --- a/helpdesk/admin.py +++ b/helpdesk/admin.py @@ -93,6 +93,10 @@ class IgnoreEmailAdmin(admin.ModelAdmin): list_display = ('name', 'queue_list', 'email_address', 'keep_in_mailbox') +@admin.register(KBCategory) +class KBCategoryAdmin(admin.ModelAdmin): + list_display = ('name', 'title', 'slug', ) + + admin.site.register(PreSetReply) admin.site.register(EscalationExclusion) -admin.site.register(KBCategory) diff --git a/helpdesk/migrations/0030_add_kbcategory_name.py b/helpdesk/migrations/0030_add_kbcategory_name.py new file mode 100644 index 00000000..908fdf17 --- /dev/null +++ b/helpdesk/migrations/0030_add_kbcategory_name.py @@ -0,0 +1,33 @@ +# Generated by Django 2.2.10 on 2020-02-25 11:21 + +from django.db import migrations, models + +def copy_title(apps, schema_editor): + KBCategory = apps.get_model("helpdesk", "KBCategory") + KBCategory.objects.update(name=models.F('title')) + + +class Migration(migrations.Migration): + + dependencies = [ + ('helpdesk', '0029_kbcategory_public'), + ] + + operations = [ + migrations.AddField( + model_name='kbcategory', + name='name', + field=models.CharField(blank=True, max_length=100, null=True, verbose_name='Name of the category'), + ), + migrations.AlterField( + model_name='kbcategory', + name='title', + field=models.CharField(max_length=100, verbose_name='Title on knowledgebase page'), + ), + migrations.RunPython(copy_title, migrations.RunPython.noop), + migrations.AlterField( + model_name='kbcategory', + name='name', + field=models.CharField(blank=False, max_length=100, null=False, verbose_name='Name of the category'), + ), + ] diff --git a/helpdesk/models.py b/helpdesk/models.py index a36c5a78..409721f7 100644 --- a/helpdesk/models.py +++ b/helpdesk/models.py @@ -1215,8 +1215,13 @@ class KBCategory(models.Model): listing of questions & answers. """ + name = models.CharField( + _('Name of the category'), + max_length=100, + ) + title = models.CharField( - _('Title'), + _('Title on knowledgebase page'), max_length=100, ) @@ -1242,7 +1247,7 @@ class KBCategory(models.Model): ) def __str__(self): - return '%s' % self.title + return '%s' % self.name class Meta: ordering = ('title',) From d0aafd61359d82a3351e5a8de55384f8a97d49dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Dlouh=C3=BD?= Date: Tue, 25 Feb 2020 14:43:10 +0100 Subject: [PATCH 04/10] add KBitem.order to allow ordering items --- helpdesk/admin.py | 2 +- .../migrations/0031_auto_20200225_1440.py | 22 +++++++++++++++++++ helpdesk/models.py | 8 ++++++- 3 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 helpdesk/migrations/0031_auto_20200225_1440.py diff --git a/helpdesk/admin.py b/helpdesk/admin.py index 88086130..8b1dedf9 100644 --- a/helpdesk/admin.py +++ b/helpdesk/admin.py @@ -70,7 +70,7 @@ class FollowUpAdmin(admin.ModelAdmin): @admin.register(KBItem) class KBItemAdmin(admin.ModelAdmin): - list_display = ('category', 'title', 'last_updated', 'team', ) + list_display = ('category', 'title', 'last_updated', 'team', 'order') inlines = [KBIAttachmentInline] readonly_fields = ('voted_by', 'downvoted_by') diff --git a/helpdesk/migrations/0031_auto_20200225_1440.py b/helpdesk/migrations/0031_auto_20200225_1440.py new file mode 100644 index 00000000..c287f06f --- /dev/null +++ b/helpdesk/migrations/0031_auto_20200225_1440.py @@ -0,0 +1,22 @@ +# Generated by Django 2.2.10 on 2020-02-25 13:40 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('helpdesk', '0030_add_kbcategory_name'), + ] + + operations = [ + migrations.AlterModelOptions( + name='kbitem', + options={'ordering': ('order', 'title'), 'verbose_name': 'Knowledge base item', 'verbose_name_plural': 'Knowledge base items'}, + ), + migrations.AddField( + model_name='kbitem', + name='order', + field=models.PositiveIntegerField(blank=True, null=True, verbose_name='Order'), + ), + ] diff --git a/helpdesk/models.py b/helpdesk/models.py index 409721f7..15465160 100644 --- a/helpdesk/models.py +++ b/helpdesk/models.py @@ -1317,6 +1317,12 @@ class KBItem(models.Model): null=True, ) + order = models.PositiveIntegerField( + _('Order'), + blank=True, + null=True, + ) + def save(self, *args, **kwargs): if not self.last_updated: self.last_updated = timezone.now() @@ -1333,7 +1339,7 @@ class KBItem(models.Model): return '%s: %s' % (self.category.title, self.title) class Meta: - ordering = ('title',) + ordering = ('order', 'title',) verbose_name = _('Knowledge base item') verbose_name_plural = _('Knowledge base items') From 93e82f546982ac12d6852974349a0a9eaa1354e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Dlouh=C3=BD?= Date: Tue, 25 Feb 2020 14:46:21 +0100 Subject: [PATCH 05/10] allow KBItems to be disabled for users --- helpdesk/admin.py | 2 +- helpdesk/migrations/0032_kbitem_enabled.py | 18 ++++++++++++++++++ helpdesk/models.py | 5 +++++ helpdesk/views/kb.py | 2 +- 4 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 helpdesk/migrations/0032_kbitem_enabled.py diff --git a/helpdesk/admin.py b/helpdesk/admin.py index 8b1dedf9..301a9c43 100644 --- a/helpdesk/admin.py +++ b/helpdesk/admin.py @@ -70,7 +70,7 @@ class FollowUpAdmin(admin.ModelAdmin): @admin.register(KBItem) class KBItemAdmin(admin.ModelAdmin): - list_display = ('category', 'title', 'last_updated', 'team', 'order') + list_display = ('category', 'title', 'last_updated', 'team', 'order', 'enabled') inlines = [KBIAttachmentInline] readonly_fields = ('voted_by', 'downvoted_by') diff --git a/helpdesk/migrations/0032_kbitem_enabled.py b/helpdesk/migrations/0032_kbitem_enabled.py new file mode 100644 index 00000000..7868bfe1 --- /dev/null +++ b/helpdesk/migrations/0032_kbitem_enabled.py @@ -0,0 +1,18 @@ +# Generated by Django 2.2.10 on 2020-02-25 13:44 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('helpdesk', '0031_auto_20200225_1440'), + ] + + operations = [ + migrations.AddField( + model_name='kbitem', + name='enabled', + field=models.BooleanField(default=True, verbose_name='Enabled to display to users'), + ), + ] diff --git a/helpdesk/models.py b/helpdesk/models.py index 15465160..7e4b61c5 100644 --- a/helpdesk/models.py +++ b/helpdesk/models.py @@ -1323,6 +1323,11 @@ class KBItem(models.Model): null=True, ) + enabled = models.BooleanField( + _('Enabled to display to users'), + default=True, + ) + def save(self, *args, **kwargs): if not self.last_updated: self.last_updated = timezone.now() diff --git a/helpdesk/views/kb.py b/helpdesk/views/kb.py index a1bead71..55b3424d 100644 --- a/helpdesk/views/kb.py +++ b/helpdesk/views/kb.py @@ -30,7 +30,7 @@ def category(request, slug, iframe=False): category = get_object_or_404(KBCategory, slug__iexact=slug) if not user.huser_from_request(request).can_access_kbcategory(category): raise Http404 - items = category.kbitem_set.all() + items = category.kbitem_set.filter(enabled=True) selected_item = request.GET.get('kbitem', None) try: selected_item = int(selected_item) From e448491bf1374e617f8eb5c5d0d54663c41664f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Dlouh=C3=BD?= Date: Wed, 26 Feb 2020 10:23:11 +0100 Subject: [PATCH 06/10] more blocks to the KB_category_base template, HTML validity fixes --- .../templates/helpdesk/kb_category_base.html | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/helpdesk/templates/helpdesk/kb_category_base.html b/helpdesk/templates/helpdesk/kb_category_base.html index 8ca89bd7..418e35c3 100644 --- a/helpdesk/templates/helpdesk/kb_category_base.html +++ b/helpdesk/templates/helpdesk/kb_category_base.html @@ -1,37 +1,40 @@ {% load i18n %} {% block header %}

{% blocktrans with category.title as kbcat %}{{ kbcat }}{% endblocktrans %}

-

{{ category.description|linebreaks }}

+{{ category.description|linebreaks }} {% endblock %} + +{% block item_list %}
{% for item in items %}
- -
+
+
+ {% block card_body %}

{{ item.question }}

-

{{ item.get_markdown }}

+ {{ item.get_markdown }}
@@ -41,16 +44,18 @@
+ {% endblock %}
{% endfor %}
+{% endblock %} {% block footer %} {% endblock %} {% if category.queue %} {% block submit_button %} - +
{% trans 'Contact a human' %}
{% endblock %}
{% endif %} From 64db14148f30b4a309bf65309a5066f8de729e9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Dlouh=C3=BD?= Date: Wed, 26 Feb 2020 10:24:07 +0100 Subject: [PATCH 07/10] add KBCategory.public in admin list_display --- helpdesk/admin.py | 2 +- helpdesk/templates/helpdesk/base_js.html | 3 +++ helpdesk/templates/helpdesk/kb_category_base.html | 4 +++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/helpdesk/admin.py b/helpdesk/admin.py index 301a9c43..9d18007e 100644 --- a/helpdesk/admin.py +++ b/helpdesk/admin.py @@ -95,7 +95,7 @@ class IgnoreEmailAdmin(admin.ModelAdmin): @admin.register(KBCategory) class KBCategoryAdmin(admin.ModelAdmin): - list_display = ('name', 'title', 'slug', ) + list_display = ('name', 'title', 'slug', 'public') admin.site.register(PreSetReply) diff --git a/helpdesk/templates/helpdesk/base_js.html b/helpdesk/templates/helpdesk/base_js.html index b337fd36..d7bcdecc 100644 --- a/helpdesk/templates/helpdesk/base_js.html +++ b/helpdesk/templates/helpdesk/base_js.html @@ -27,3 +27,6 @@ + +{% block js_bottom %} +{% endblock %} diff --git a/helpdesk/templates/helpdesk/kb_category_base.html b/helpdesk/templates/helpdesk/kb_category_base.html index 418e35c3..8eb8dd20 100644 --- a/helpdesk/templates/helpdesk/kb_category_base.html +++ b/helpdesk/templates/helpdesk/kb_category_base.html @@ -19,7 +19,9 @@ {% block card_body %}

{{ item.question }}

- {{ item.get_markdown }} +
+ {{ item.get_markdown }} +
{% if request.user.pk %}
From 782dd8668030ef0777070eb99cf2b2c920036038 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Dlouh=C3=BD?= Date: Wed, 26 Feb 2020 10:29:53 +0100 Subject: [PATCH 08/10] add doctype to iframes --- helpdesk/templates/helpdesk/kb_category_iframe.html | 1 + helpdesk/templates/helpdesk/public_create_ticket_iframe.html | 1 + 2 files changed, 2 insertions(+) diff --git a/helpdesk/templates/helpdesk/kb_category_iframe.html b/helpdesk/templates/helpdesk/kb_category_iframe.html index ee57022e..6a64940a 100644 --- a/helpdesk/templates/helpdesk/kb_category_iframe.html +++ b/helpdesk/templates/helpdesk/kb_category_iframe.html @@ -1,5 +1,6 @@ {% load i18n %} {% load saved_queries %} + {% include 'helpdesk/base-head.html' %} {% block helpdesk_head %}{% endblock %} diff --git a/helpdesk/templates/helpdesk/public_create_ticket_iframe.html b/helpdesk/templates/helpdesk/public_create_ticket_iframe.html index a20f0722..3b1fe30b 100644 --- a/helpdesk/templates/helpdesk/public_create_ticket_iframe.html +++ b/helpdesk/templates/helpdesk/public_create_ticket_iframe.html @@ -1,5 +1,6 @@ {% load i18n %} {% load saved_queries %} + {% include 'helpdesk/base-head.html' %} From 29e73158b4becbece238eec06367ea18084e9bc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Dlouh=C3=BD?= Date: Wed, 26 Feb 2020 10:49:08 +0100 Subject: [PATCH 09/10] make question stronger --- helpdesk/static/helpdesk/css/sb-admin.css | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/helpdesk/static/helpdesk/css/sb-admin.css b/helpdesk/static/helpdesk/css/sb-admin.css index f015c714..cad0a66e 100644 --- a/helpdesk/static/helpdesk/css/sb-admin.css +++ b/helpdesk/static/helpdesk/css/sb-admin.css @@ -242,6 +242,10 @@ body.fixed-nav.sidebar-toggled #content-wrapper { overflow-y: auto; } +.card-text { + font-weight: bold; +} + .card-body-icon { position: absolute; z-index: 0; From 81f835b77b9bad1d55c009f18dbfeb7437309948 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Dlouh=C3=BD?= Date: Thu, 27 Feb 2020 11:54:04 +0100 Subject: [PATCH 10/10] fix KBItem choose form --- helpdesk/forms.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helpdesk/forms.py b/helpdesk/forms.py index 37c08c07..09c3e5bf 100644 --- a/helpdesk/forms.py +++ b/helpdesk/forms.py @@ -184,7 +184,7 @@ class AbstractTicketForm(CustomFieldMixin, forms.Form): widget=forms.Select(attrs={'class': 'form-control'}), required=False, label=_('Knowledge Base Item'), - choices=[(kbi.pk, kbi.title) for kbi in KBItem.objects.filter(category=kbcategory.pk)], + choices=[(kbi.pk, kbi.title) for kbi in KBItem.objects.filter(category=kbcategory.pk, enabled=True)], ) def _add_form_custom_fields(self, staff_only_filter=None):