fix public homepage with kb_category but without kb disabled

This commit is contained in:
Cedric Carrard 2019-03-15 13:57:43 +01:00
parent c314d515c1
commit e4d6a54659
2 changed files with 13 additions and 1 deletions

View File

@ -2,6 +2,7 @@
from django.urls import reverse from django.urls import reverse
from django.test import TestCase from django.test import TestCase
from helpdesk.models import KBCategory
from helpdesk.tests.helpers import get_staff_user, reload_urlconf from helpdesk.tests.helpers import get_staff_user, reload_urlconf
@ -36,3 +37,11 @@ class TestKBDisabled(TestCase):
raise raise
else: else:
self.assertEqual(response.status_code, 200) self.assertEqual(response.status_code, 200)
def test_public_homepage_with_kb_category(self):
KBCategory.objects.create(title="KB Cat 1",
slug="kbcat1",
description="Some category of KB info")
response = self.client.get(reverse('helpdesk:home'))
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, 'helpdesk/public_homepage.html')

View File

@ -87,7 +87,10 @@ def homepage(request):
form.fields['queue'].choices = [('', '--------')] + [ form.fields['queue'].choices = [('', '--------')] + [
(q.id, q.title) for q in Queue.objects.filter(allow_public_submission=True)] (q.id, q.title) for q in Queue.objects.filter(allow_public_submission=True)]
knowledgebase_categories = KBCategory.objects.all() knowledgebase_categories = None
if helpdesk_settings.HELPDESK_KB_ENABLED:
knowledgebase_categories = KBCategory.objects.all()
return render(request, 'helpdesk/public_homepage.html', { return render(request, 'helpdesk/public_homepage.html', {
'form': form, 'form': form,