Merge branch 'master' into custom-staff-filter

Conflicts:
	docs/settings.rst
	helpdesk/views/staff.py
This commit is contained in:
Stefano Brentegani 2014-07-22 06:47:50 +02:00
commit fb6b35a724
9 changed files with 124 additions and 78 deletions

View File

@ -36,32 +36,14 @@ These changes are visible throughout django-helpdesk
**Default:** ``HELPDESK_REDIRECT_TO_LOGIN_BY_DEFAULT = False``
- **HELPDESK_PREPEND_ORG_NAME** Customize helpdesk name on a few pages, i.e., your organization.
**Default:** ``HELPDESK_PREPEND_ORG_NAME = False``
- **HELPDESK_KB_ENABLED** show knowledgebase links?
**Default:** ``HELPDESK_KB_ENABLED = True``
- **HELDPESK_KB_ENABLED_STAFF** Show knowledgebase links for staff users?
**Default:** ``HELPDESK_KB_ENABLED_STAFF = False``
- **HELPDESK_NAVIGATION_ENABLED** Show extended navigation by default, to all users, irrespective of staff status?
**Default:** ``HELPDESK_NAVIGATION_ENABLED = False``
- **HELPDESK_NAVIGATION_STATS_ENABLED** Show 'stats' link in navigation bar for staff users?
**Default:** ``HELPDESK_NAVIGATION_STATS_ENABLED = True``
- **HELPDESK_SUPPORT_PERSON** Set this to an email address inside your organization and a footer below
the 'Powered by django-helpdesk' will be shown, telling the user whom to contact
in case they have technical problems.
**Default:** ``HELPDESK_SUPPORT_PERSON = ""``
- **HELPDESK_TRANSLATE_TICKET_COMMENTS** Show dropdown list of languages that ticket comments can be translated into via Google Translate?
**Default:** ``HELPDESK_TRANSLATE_TICKET_COMMENTS = False``
@ -78,15 +60,11 @@ These changes are visible throughout django-helpdesk
**Default:** ``HELPDESK_FOLLOWUP_MOD = False``
- **HELPDESK_CUSTOM_WELCOME** Show custom welcome message in dashboard?
**Default:** ``HELPDESK_CUSTOM_WELCOME = False``
- **HELPDESK_AUTO_SUBSCRIBE_ON_TICKET_RESPONSE ** Auto-subscribe user to ticket as a 'CC' if (s)he responds to a ticket?
- **HELPDESK_AUTO_SUBSCRIBE_ON_TICKET_RESPONSE** Auto-subscribe user to ticket as a 'CC' if (s)he responds to a ticket?
**Default:** ``HELPDESK_AUTO_SUBSCRIBE_ON_TICKET_RESPONSE = False``
- **HELPDESK_EMAIL_SUBJECT_TEMPLATE ** Subject template for templated emails. ``%(subject)s`` represents the subject wording from the email template (e.g. "(Closed)").
- **HELPDESK_EMAIL_SUBJECT_TEMPLATE** Subject template for templated emails. ``%(subject)s`` represents the subject wording from the email template (e.g. "(Closed)").
**Default:** ``HELPDESK_EMAIL_SUBJECT_TEMPLATE = "{{ ticket.ticket }} {{ ticket.title|safe }} %(subject)s"``
@ -104,10 +82,6 @@ These options only change display of items on public-facing pages, not staff pag
**Default:** ``HELPDESK_SUBMIT_A_TICKET_PUBLIC = True``
- **HELPDESK_SHOW_KB_ON_HOMEPAGE** Should we should the KB categories on the homepage?
**Default:** ``HELPDESK_SHOW_KB_ON_HOMEPAGE = False``
Options that change ticket updates
----------------------------------
@ -132,21 +106,9 @@ Options that change ticket updates
**Default:** ``HELPDESK_SHOW_DELETE_BUTTON_SUPERUSER_FOLLOW_UP = False``
- **HELPDESK_SHOW_EDIT_BUTTON_TICKET_TOP** Show ticket edit button on top of ticket description?
**Default:** ``HELPDESK_SHOW_EDIT_BUTTON_TICKET_TOP = True``
- **HELPDESK_SHOW_DELETE_BUTTON_TICKET_TOP** Show ticket delete button on top of ticket description?
**Default:** ``HELPDESK_SHOW_DELETE_BUTTON_TICKET_TOP = True``
- **HELPDESK_SHOW_HOLD_BUTTON_TICKET_TOP** Show hold / unhold button on top of ticket description?
**Default:** ``HELPDESK_SHOW_HOLD_BUTTON_TICKET_TOP = True``
- **HELPDESK_UPDATE_PUBLIC_DEFAULT** Make all updates public by default? This will hide the 'is this update public' checkbox.
**Default:** ``HELPDESK_UPDATE_PUBLIC_DEFAULT = True``
**Default:** ``HELPDESK_UPDATE_PUBLIC_DEFAULT = False``
- **HELPDESK_STAFF_ONLY_TICKET_OWNERS** Only show staff users in ticket owner drop-downs?
@ -204,3 +166,26 @@ The following settings default to ``None`` but can be set as defaults, rather th
- ``QUEUE_EMAIL_BOX_HOST````
- ``QUEUE_EMAIL_BOX_USER``
- ``QUEUE_EMAIL_BOX_PASSWORD``
Discontinued Settings
---------------------
The following settings were defined in previous versions and are no longer supported.
- **HELPDESK_CUSTOM_WELCOME**
- **HELDPESK_KB_ENABLED_STAFF** Now always True
- **HELPDESK_NAVIGATION_STATS_ENABLED** Now always True
- **HELPDESK_PREPEND_ORG_NAME** Please customise your local `helpdesk/base.html` template if needed
- **HELPDESK_SHOW_DELETE_BUTTON_TICKET_TOP** Button is always shown
- **HELPDESK_SHOW_EDIT_BUTTON_TICKET_TOP** Button is always shown
- **HELPDESK_SHOW_HOLD_BUTTON_TICKET_TOP** Button is always shown
- **HELPDESK_SHOW_KB_ON_HOMEPAGE** KB categories are always shown on the homepage
- **HELPDESK_SUPPORT_PERSON** Please customise your local `helpdesk/attribution.html` template if needed

View File

@ -54,6 +54,7 @@ def send_templated_mail(template_name, email_context, recipients, sender=None, b
from django.template import loader, Context
from helpdesk.models import EmailTemplate
from helpdesk.settings import HELPDESK_EMAIL_SUBJECT_TEMPLATE
import os
context = Context(email_context)
@ -104,7 +105,7 @@ def send_templated_mail(template_name, email_context, recipients, sender=None, b
).render(context)
subject_part = loader.get_template_from_string(
settings.HELPDESK_EMAIL_SUBJECT_TEMPLATE % {
HELPDESK_EMAIL_SUBJECT_TEMPLATE % {
"subject": t.subject,
}).render(context)

View File

@ -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">

View File

@ -8,12 +8,12 @@
<p>The following items can be maintained by you or other superusers:</p>{% endblocktrans %}
<ul>
<li><a href='../ignore/'>{% trans "E-Mail Ignore list" %}</a></li>
<li><a href='{{ ADMIN_URL }}helpdesk/queue/'>{% trans "Maintain Queues" %}</a></li>
<li><a href='{{ ADMIN_URL }}helpdesk/presetreply/'>{% trans "Maintain Pre-Set Replies" %}</a></li>
<li><a href='{{ ADMIN_URL }}helpdesk/kbcategory/'>{% trans "Maintain Knowledgebase Categories" %}</a></li>
<li><a href='{{ ADMIN_URL }}helpdesk/kbitem/'>{% trans "Maintain Knowledgebase Items" %}</a></li>
<li><a href='{{ ADMIN_URL }}helpdesk/emailtemplate/'>{% trans "Maintain E-Mail Templates" %}</a></li>
<li><a href='{{ ADMIN_URL }}auth/user/'>{% trans "Maintain Users" %}</a></li>
<li><a href='{% url 'helpdesk_email_ignore' %}'>{% trans "E-Mail Ignore list" %}</a></li>
<li><a href='{% url 'admin:helpdesk_queue_changelist' %}'>{% trans "Maintain Queues" %}</a></li>
<li><a href='{% url 'admin:helpdesk_presetreply_changelist' %}'>{% trans "Maintain Pre-Set Replies" %}</a></li>
<li><a href='{% url 'admin:helpdesk_kbcategory_changelist' %}'>{% trans "Maintain Knowledgebase Categories" %}</a></li>
<li><a href='{% url 'admin:helpdesk_kbitem_changelist' %}'>{% trans "Maintain Knowledgebase Items" %}</a></li>
<li><a href='{% url 'admin:helpdesk_emailtemplate_changelist' %}'>{% trans "Maintain E-Mail Templates" %}</a></li>
<li><a href='{% url 'admin:auth_user_changelist' %}'>{% trans "Maintain Users" %}</a></li>
</ul>
{% endblock %}

View File

@ -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
View 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()

View 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)

View File

@ -99,7 +99,7 @@ urlpatterns = patterns('helpdesk.views.staff',
url(r'^tickets/(?P<ticket_id>[0-9]+)/dependency/delete/(?P<dependency_id>[0-9]+)/$',
'ticket_dependency_del',
name='helpdesk_ticket_dependency_del'),
url(r'^tickets/(?P<ticket_id>[0-9]+)/attachment_delete/(?P<attachment_id>[0-9]+)/$',
'attachment_del',
name='helpdesk_attachment_del'),
@ -156,7 +156,7 @@ urlpatterns += patterns('helpdesk.views.public',
url(r'^change_language/$',
'change_language',
name='helpdesk_public_change_language'),
name='helpdesk_public_change_language'),
)
urlpatterns += patterns('',
@ -203,7 +203,7 @@ if helpdesk_settings.HELPDESK_KB_ENABLED:
urlpatterns += patterns('helpdesk.views.kb',
url(r'^kb/$',
'index', name='helpdesk_kb_index'),
url(r'^kb/(?P<item>[0-9]+)/$',
'item', name='helpdesk_kb_item'),
@ -215,13 +215,12 @@ if helpdesk_settings.HELPDESK_KB_ENABLED:
)
urlpatterns += patterns('',
url(r'^api/$',TemplateView.as_view(template_name='helpdesk/help_api.html'),
url(r'^api/$', TemplateView.as_view(template_name='helpdesk/help_api.html'),
name='helpdesk_api_help'),
url(r'^help/context/$',TemplateView.as_view(template_name='helpdesk/help_context.html'),
url(r'^help/context/$', TemplateView.as_view(template_name='helpdesk/help_context.html'),
name='helpdesk_help_context'),
url(r'^system_settings/$',DirectTemplateView.as_view(template_name='helpdesk/system_settings.html',
extra_context={'ADMIN_URL': getattr(settings, 'ADMIN_URL', '/admin/')}),
name='helpdesk_system_settings'),
url(r'^system_settings/$', DirectTemplateView.as_view(template_name='helpdesk/system_settings.html'),
name='helpdesk_system_settings'),
)

View File

@ -26,6 +26,7 @@ from django.db.models import Q
from django.http import HttpResponseRedirect, Http404, HttpResponse, HttpResponseForbidden
from django.shortcuts import render_to_response, get_object_or_404
from django.template import loader, Context, RequestContext
from django.utils.dates import MONTHS_3
from django.utils.translation import ugettext as _
from django.utils.html import escape
from django import forms
@ -980,21 +981,7 @@ def run_report(request, report):
# a second table for more complex queries
summarytable2 = defaultdict(int)
months = (
_('Jan'),
_('Feb'),
_('Mar'),
_('Apr'),
_('May'),
_('Jun'),
_('Jul'),
_('Aug'),
_('Sep'),
_('Oct'),
_('Nov'),
_('Dec'),
)
month_name = lambda m: MONTHS_3[m].title()
first_ticket = Ticket.objects.all().order_by('created')[0]
first_month = first_ticket.created.month
@ -1007,7 +994,7 @@ def run_report(request, report):
periods = []
year, month = first_year, first_month
working = True
periods.append("%s %s" % (months[month - 1], year))
periods.append("%s %s" % (month_name(month), year))
while working:
month += 1
@ -1016,7 +1003,7 @@ def run_report(request, report):
month = 1
if (year > last_year) or (month > last_month and year >= last_year):
working = False
periods.append("%s %s" % (months[month - 1], year))
periods.append("%s %s" % (month_name(month), year))
if report == 'userpriority':
title = _('User by Priority')
@ -1082,7 +1069,7 @@ def run_report(request, report):
elif report == 'usermonth':
metric1 = u'%s' % ticket.get_assigned_to
metric2 = u'%s %s' % (months[ticket.created.month - 1], ticket.created.year)
metric2 = u'%s %s' % (month_name(ticket.created.month), ticket.created.year)
elif report == 'queuepriority':
metric1 = u'%s' % ticket.queue.title
@ -1094,11 +1081,11 @@ def run_report(request, report):
elif report == 'queuemonth':
metric1 = u'%s' % ticket.queue.title
metric2 = u'%s %s' % (months[ticket.created.month - 1], ticket.created.year)
metric2 = u'%s %s' % (month_name(ticket.created.month), ticket.created.year)
elif report == 'daysuntilticketclosedbymonth':
metric1 = u'%s' % ticket.queue.title
metric2 = u'%s %s' % (months[ticket.created.month - 1], ticket.created.year)
metric2 = u'%s %s' % (month_name(ticket.created.month), ticket.created.year)
metric3 = ticket.modified - ticket.created
metric3 = metric3.days