diff --git a/helpdesk/forms.py b/helpdesk/forms.py index 7ab2024f..613f21b7 100644 --- a/helpdesk/forms.py +++ b/helpdesk/forms.py @@ -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): diff --git a/helpdesk/views/public.py b/helpdesk/views/public.py index 9227e83d..72410755 100644 --- a/helpdesk/views/public.py +++ b/helpdesk/views/public.py @@ -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