123456789101112131415161718192021 |
- from django.contrib.auth.mixins import LoginRequiredMixin
- from django.contrib import messages
- from django.urls import reverse_lazy
- from django.shortcuts import redirect
- from django.views import View
- from tickets.forms import TicketListForm
- from tickets.utils import SuperuserStaffRequiredMixin
- class TicketListCreateView(LoginRequiredMixin, SuperuserStaffRequiredMixin, View):
- def post(self, request):
- form = TicketListForm(request.user, request.POST)
- if form.is_valid():
- new_ticket_list = form.save()
- messages.success(self.request, f'The "{new_ticket_list.name}" list has been successfully created in {new_ticket_list.group}.')
- else:
- messages.error(self.request, "Failed to create the list. Maybe you specified an already existing list name in the group?")
- return redirect(reverse_lazy('tickets:ticket_list_list'))
|