mirror of
https://github.com/django-helpdesk/django-helpdesk.git
synced 2025-05-20 01:10:45 +02:00
Merge pull request #583 from arnuschky/feature-public-ticket-defaults
Adds pre-defined values for public tickets
This commit is contained in:
commit
a957e74853
@ -105,6 +105,22 @@ These options only change display of items on public-facing pages, not staff pag
|
|||||||
**Default:** ``HELPDESK_SUBMIT_A_TICKET_PUBLIC = True``
|
**Default:** ``HELPDESK_SUBMIT_A_TICKET_PUBLIC = True``
|
||||||
|
|
||||||
|
|
||||||
|
Options for public ticket submission form
|
||||||
|
-----------------------------------------
|
||||||
|
|
||||||
|
- **HELPDESK_PUBLIC_TICKET_QUEUE** Sets the queue for tickets submitted through the public form. If defined, the matching form field will be hidden. This cannot be `None` but must be set to a valid queue slug.
|
||||||
|
|
||||||
|
**Default:** Not defined
|
||||||
|
|
||||||
|
- **HELPDESK_PUBLIC_TICKET_PRIORITY** Sets the priority for tickets submitted through the public form. If defined, the matching form field will be hidden. Must be set to a valid integer priority.
|
||||||
|
|
||||||
|
**Default:** Not defined
|
||||||
|
|
||||||
|
- **HELPDESK_PUBLIC_TICKET_DUE_DATE** Sets the due date for tickets submitted through the public form. If defined, the matching form field will be hidden. Set to `None` if you want to hide the form field but do not want to define a value.
|
||||||
|
|
||||||
|
**Default:** Not defined
|
||||||
|
|
||||||
|
|
||||||
Options that change ticket updates
|
Options that change ticket updates
|
||||||
----------------------------------
|
----------------------------------
|
||||||
|
|
||||||
|
@ -368,6 +368,14 @@ class PublicTicketForm(AbstractTicketForm):
|
|||||||
Add any (non-staff) custom fields that are defined to the form
|
Add any (non-staff) custom fields that are defined to the form
|
||||||
"""
|
"""
|
||||||
super(PublicTicketForm, self).__init__(*args, **kwargs)
|
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)
|
self._add_form_custom_fields(False)
|
||||||
|
|
||||||
def save(self):
|
def save(self):
|
||||||
|
@ -7,11 +7,12 @@ views/public.py - All public facing views, eg non-staff (no authentication
|
|||||||
required) views.
|
required) views.
|
||||||
"""
|
"""
|
||||||
from django.core.exceptions import ObjectDoesNotExist
|
from django.core.exceptions import ObjectDoesNotExist
|
||||||
from django.urls import reverse
|
from django.core.urlresolvers import reverse
|
||||||
from django.http import HttpResponseRedirect
|
from django.http import HttpResponseRedirect, HttpResponse
|
||||||
from django.shortcuts import render
|
from django.shortcuts import render
|
||||||
from django.utils.http import urlquote
|
from django.utils.http import urlquote
|
||||||
from django.utils.translation import ugettext as _
|
from django.utils.translation import ugettext as _
|
||||||
|
from django.conf import settings
|
||||||
|
|
||||||
from helpdesk import settings as helpdesk_settings
|
from helpdesk import settings as helpdesk_settings
|
||||||
from helpdesk.decorators import protect_view
|
from helpdesk.decorators import protect_view
|
||||||
@ -58,6 +59,19 @@ def homepage(request):
|
|||||||
except Queue.DoesNotExist:
|
except Queue.DoesNotExist:
|
||||||
queue = None
|
queue = None
|
||||||
initial_data = {}
|
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:
|
if queue:
|
||||||
initial_data['queue'] = queue.id
|
initial_data['queue'] = queue.id
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user