mirror of
https://github.com/django-helpdesk/django-helpdesk.git
synced 2024-12-12 18:00:45 +01:00
Adds pre-defined values for public tickets
This commit adds three new settings that allow the operator to pre-define the `queue`, `priority` and `due_date` fields for public tickets. If one of these settings are present the corresponding input field is hidden from the form. The settings are the following: HELPDESK_PUBLIC_TICKET_QUEUE = 'website' HELPDESK_PUBLIC_TICKET_PRIORITY = 2 HELPDESK_PUBLIC_TICKET_DUE_DATE = '' If the due date is set to the empty string, no due date is saved in the ticket (analogously to the form). The other settings should be self-explanatory.
This commit is contained in:
parent
e83b64c973
commit
f3e52a2f12
@ -368,6 +368,14 @@ class PublicTicketForm(AbstractTicketForm):
|
||||
Add any (non-staff) custom fields that are defined to the form
|
||||
"""
|
||||
super(PublicTicketForm, self).__init__(*args, **kwargs)
|
||||
|
||||
if hasattr(settings, 'HELPDESK_PUBLIC_TICKET_QUEUE'):
|
||||
self.fields['queue'].widget = forms.HiddenInput()
|
||||
if hasattr(settings, 'HELPDESK_PUBLIC_TICKET_PRIORITY'):
|
||||
self.fields['priority'].widget = forms.HiddenInput()
|
||||
if hasattr(settings, 'HELPDESK_PUBLIC_TICKET_DUE_DATE'):
|
||||
self.fields['due_date'].widget = forms.HiddenInput()
|
||||
|
||||
self._add_form_custom_fields(False)
|
||||
|
||||
def save(self):
|
||||
|
@ -8,10 +8,11 @@ views/public.py - All public facing views, eg non-staff (no authentication
|
||||
"""
|
||||
from django.core.exceptions import ObjectDoesNotExist
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.http import HttpResponseRedirect
|
||||
from django.http import HttpResponseRedirect, HttpResponse
|
||||
from django.shortcuts import render
|
||||
from django.utils.http import urlquote
|
||||
from django.utils.translation import ugettext as _
|
||||
from django.conf import settings
|
||||
|
||||
from helpdesk import settings as helpdesk_settings
|
||||
from helpdesk.decorators import protect_view
|
||||
@ -58,6 +59,19 @@ def homepage(request):
|
||||
except Queue.DoesNotExist:
|
||||
queue = None
|
||||
initial_data = {}
|
||||
|
||||
# add pre-defined data for public ticket
|
||||
if hasattr(settings, 'HELPDESK_PUBLIC_TICKET_QUEUE'):
|
||||
# get the requested queue; return an error if queue not found
|
||||
try:
|
||||
queue = Queue.objects.get(slug=settings.HELPDESK_PUBLIC_TICKET_QUEUE)
|
||||
except Queue.DoesNotExist:
|
||||
return HttpResponse(status=500)
|
||||
if hasattr(settings, 'HELPDESK_PUBLIC_TICKET_PRIORITY'):
|
||||
initial_data['priority'] = settings.HELPDESK_PUBLIC_TICKET_PRIORITY
|
||||
if hasattr(settings, 'HELPDESK_PUBLIC_TICKET_DUE_DATE'):
|
||||
initial_data['due_date'] = settings.HELPDESK_PUBLIC_TICKET_DUE_DATE
|
||||
|
||||
if queue:
|
||||
initial_data['queue'] = queue.id
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user