mirror of
https://github.com/django-helpdesk/django-helpdesk.git
synced 2025-08-16 02:48:00 +02:00
feat(forms): Ability to provide custom public ticket form
This commit is contained in:
@ -7,6 +7,7 @@ views/public.py - All public facing views, eg non-staff (no authentication
|
||||
required) views.
|
||||
"""
|
||||
import logging
|
||||
from importlib import import_module
|
||||
|
||||
from django.core.exceptions import (
|
||||
ObjectDoesNotExist, PermissionDenied, ImproperlyConfigured,
|
||||
@ -26,7 +27,6 @@ from helpdesk import settings as helpdesk_settings
|
||||
from helpdesk.decorators import protect_view, is_helpdesk_staff
|
||||
import helpdesk.views.staff as staff
|
||||
import helpdesk.views.abstract_views as abstract_views
|
||||
from helpdesk.forms import PublicTicketForm
|
||||
from helpdesk.lib import text_is_spam
|
||||
from helpdesk.models import CustomField, Ticket, Queue, UserSettings, KBCategory, KBItem
|
||||
from helpdesk.user import huser_from_request
|
||||
@ -42,7 +42,17 @@ def create_ticket(request, *args, **kwargs):
|
||||
|
||||
|
||||
class BaseCreateTicketView(abstract_views.AbstractCreateTicketMixin, FormView):
|
||||
form_class = PublicTicketForm
|
||||
|
||||
def get_form_class(self):
|
||||
try:
|
||||
the_module, the_form_class = helpdesk_settings.HELPDESK_PUBLIC_TICKET_FORM_CLASS.rsplit(".", 1)
|
||||
the_module = import_module(the_module)
|
||||
the_form_class = getattr(the_module, the_form_class)
|
||||
except Exception as e:
|
||||
raise ImproperlyConfigured(
|
||||
f"Invalid custom form class {helpdesk_settings.HELPDESK_PUBLIC_TICKET_FORM_CLASS}"
|
||||
) from e
|
||||
return the_form_class
|
||||
|
||||
def dispatch(self, *args, **kwargs):
|
||||
request = self.request
|
||||
|
Reference in New Issue
Block a user