mirror of
https://gitea.mueller.network/extern/django-helpdesk.git
synced 2024-11-22 07:53:19 +01:00
Merge pull request #230 from brente/navigation-nokb
exclude KB from navigation if HELPDESK_KB_ENABLED is False
This commit is contained in:
commit
ef84c90732
@ -17,7 +17,9 @@
|
||||
<li><a href='{% url 'helpdesk_list' %}'><span class="glyphicon glyphicon-tags"></span> <span class="nav-text">{% trans "Tickets" %}</span></a></li>
|
||||
<li><a href='{% url 'helpdesk_submit' %}'><span class="glyphicon glyphicon-plus"></span> <span class="nav-text">{% trans "New Ticket" %}</span></a></li>
|
||||
<li><a href='{% url 'helpdesk_report_index' %}'><span class="glyphicon glyphicon-stats"></span><span class="nav-text"> {% trans "Stats" %}</span></a></li>
|
||||
{% if helpdesk_settings.HELPDESK_KB_ENABLED %}
|
||||
<li><a href='{% url 'helpdesk_kb_index' %}'><span class="glyphicon glyphicon-tree-deciduous"></span><span class="nav-text">{% trans "Knowledgebase" %}</span></a></li>
|
||||
{% endif %}
|
||||
{% if user_saved_queries_ %}
|
||||
<li class="headerlink dropdown"><a class="dropdown-toggle" data-toggle="dropdown" href="#"><span class="glyphicon glyphicon-filter"></span><span class="nav-text"> {% trans "Saved Query" %} <b class="caret"></b></span></a>
|
||||
<ul class="dropdown-menu">
|
||||
|
@ -1,2 +1,3 @@
|
||||
from helpdesk.tests.ticket_submission import *
|
||||
from helpdesk.tests.public_actions import *
|
||||
from helpdesk.tests.navigation import *
|
33
helpdesk/tests/helpers.py
Normal file
33
helpdesk/tests/helpers.py
Normal file
@ -0,0 +1,33 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import sys
|
||||
try:
|
||||
from django.contrib.auth import get_user_model
|
||||
except ImportError:
|
||||
from django.contrib.auth.models import User
|
||||
else:
|
||||
User = get_user_model()
|
||||
|
||||
|
||||
def get_staff_user(username='helpdesk.staff', password='password'):
|
||||
try:
|
||||
user = User.objects.get(username=username)
|
||||
except User.DoesNotExist:
|
||||
user = User.objects.create_user(username=username, password=password, email='staff@example.com')
|
||||
user.is_staff = True
|
||||
user.save()
|
||||
else:
|
||||
user.set_password(password)
|
||||
user.save()
|
||||
return user
|
||||
|
||||
|
||||
def reload_urlconf(urlconf=None):
|
||||
if urlconf is None:
|
||||
from django.conf import settings
|
||||
|
||||
urlconf = settings.ROOT_URLCONF
|
||||
if urlconf in sys.modules:
|
||||
from django.core.urlresolvers import clear_url_caches
|
||||
|
||||
reload(sys.modules[urlconf])
|
||||
clear_url_caches()
|
38
helpdesk/tests/navigation.py
Normal file
38
helpdesk/tests/navigation.py
Normal file
@ -0,0 +1,38 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.test import TestCase
|
||||
|
||||
from helpdesk.tests.helpers import get_staff_user, reload_urlconf
|
||||
|
||||
|
||||
class TestKBDisabled(TestCase):
|
||||
def setUp(self):
|
||||
from helpdesk import settings
|
||||
|
||||
self.HELPDESK_KB_ENABLED = settings.HELPDESK_KB_ENABLED
|
||||
if self.HELPDESK_KB_ENABLED:
|
||||
settings.HELPDESK_KB_ENABLED = False
|
||||
reload_urlconf()
|
||||
|
||||
def tearDown(self):
|
||||
from helpdesk import settings
|
||||
|
||||
if self.HELPDESK_KB_ENABLED:
|
||||
settings.HELPDESK_KB_ENABLED = True
|
||||
reload_urlconf()
|
||||
|
||||
def test_navigation(self):
|
||||
"""Test proper rendering of navigation.html by accessing the dashboard"""
|
||||
from django.core.urlresolvers import NoReverseMatch
|
||||
|
||||
self.client.login(username=get_staff_user().username, password='password')
|
||||
self.assertRaises(NoReverseMatch, reverse, 'helpdesk_kb_index')
|
||||
try:
|
||||
response = self.client.get(reverse('helpdesk_dashboard'))
|
||||
except NoReverseMatch, e:
|
||||
if 'helpdesk_kb_index' in e.message:
|
||||
self.fail("Please verify any unchecked references to helpdesk_kb_index (start with navigation.html)")
|
||||
else:
|
||||
raise
|
||||
else:
|
||||
self.assertEqual(response.status_code, 200)
|
Loading…
Reference in New Issue
Block a user