Merge pull request #743 from CedricCarrard/fix/public_homepage_kbdisabled

Fix error 500 public homepage when objects kb_category
This commit is contained in:
Garret Wassermann 2019-03-15 15:10:24 -04:00 committed by GitHub
commit eaba30dd65
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 1 deletions

View File

@ -2,6 +2,7 @@
from django.urls import reverse
from django.test import TestCase
from helpdesk.models import KBCategory
from helpdesk.tests.helpers import get_staff_user, reload_urlconf
@ -36,3 +37,11 @@ class TestKBDisabled(TestCase):
raise
else:
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,6 +87,9 @@ def homepage(request):
form.fields['queue'].choices = [('', '--------')] + [
(q.id, q.title) for q in Queue.objects.filter(allow_public_submission=True)]
knowledgebase_categories = None
if helpdesk_settings.HELPDESK_KB_ENABLED:
knowledgebase_categories = KBCategory.objects.all()
return render(request, 'helpdesk/public_homepage.html', {