Răsfoiți Sursa

Removed the ability to create and delete lists with tickets via the web interface

TonyKurts 1 săptămână în urmă
părinte
comite
f2b915eea4

+ 1 - 38
templates/tickets/ticket_list_detail.html

@@ -13,46 +13,9 @@
       <button type="button" data-bs-toggle="modal" data-bs-target="#ticket-create-modal" class="btn btn-primary">
         <i class="fa-solid fa-plus pe-1"></i>
         New Ticket
-      </button>
-      {% if user.is_staff or user.is_superuser %}
-        <button type="button" class="btn btn-outline-danger" data-bs-toggle="modal" data-bs-target="#ticket_list-delete-modal">
-          <i class="fa-solid fa-trash-can"></i>
-        </button>  
-      {% endif %}    
+      </button> 
     </div>
 
-    {% if user.is_staff or user.is_superuser %}
-      <!--List delete modal-->
-      <div class="modal fade" id="ticket_list-delete-modal" tabindex="-1">
-        <div class="modal-dialog modal-dialog-centered">
-          <div class="modal-content">
-            <div class="modal-header">
-              <h1 class="modal-title fs-5">
-                <i class="fa-solid fa-trash-can pe-1"></i>
-                Delete List
-              </h1>
-            </div>
-            <div class="modal-body">
-              Are you sure you want to delete the list "{{ ticket_list.name }}"? All related tickets will also be deleted.
-            </div>
-            <div class="modal-footer">
-              <button type="button" class="btn btn-primary" data-bs-dismiss="modal">
-                <i class="fa-solid fa-xmark pe-1"></i>
-                Close
-              </button>
-              <form action="{% url 'tickets:ticket_list_delete' ticket_list.pk %}" method="post">
-                {% csrf_token %}
-                <button class="btn btn-outline-danger" type="submit">
-                  <i class="fa-solid fa-check pe-1"></i>
-                  Confirm
-                </button>
-              </form>
-            </div>
-          </div>
-        </div>
-      </div>
-    {% endif %}
-
     <!--ticket create modal-->
     <div class="modal fade" id="ticket-create-modal" tabindex="-1">
       <div class="modal-dialog modal-dialog-centered">

+ 0 - 36
templates/tickets/ticket_list_list.html

@@ -3,42 +3,6 @@
 {% block content %}
   <h1 class="fw-bold">Lists</h1>
 
-  {% if user.is_staff or user.is_superuser %}
-    <button type="button" data-bs-toggle="modal" data-bs-target="#ticket_list-create-modal" class="btn btn-primary">
-      <i class="fa-solid fa-plus pe-1"></i>
-      New List
-    </button>
-    <hr>
-
-    <!--List create modal-->
-    <div class="modal fade" id="ticket_list-create-modal" tabindex="-1">
-      <div class="modal-dialog modal-dialog-centered">
-        <div class="modal-content">
-          <div class="modal-header">
-            <h1 class="modal-title fs-5">
-              <i class="fa-solid fa-plus pe-1"></i>
-              New List
-          </div>
-          <div class="modal-body">
-            <form id="ticket_list-create-form" action="{% url 'tickets:ticket_list_create' %}" method="post">
-              {% include 'tickets/include/form.html' %}
-            </form>
-          </div>
-          <div class="modal-footer">
-            <button type="button" class="btn btn-outline-secondary" data-bs-dismiss="modal">
-              <i class="fa-solid fa-xmark pe-1"></i>
-              Close
-            </button>
-            <button class="btn btn-primary" type="submit" form="ticket_list-create-form">
-              <i class="fa-solid fa-check pe-1"></i>
-              Confirm
-            </button>
-          </div>
-        </div>
-      </div>
-    </div>
-  {% endif %}
-
   {% if ticket_lists %}
     {% regroup ticket_lists by group as section_ticket_list %}
     {% for group in section_ticket_list %}

+ 0 - 2
urls.py

@@ -9,13 +9,11 @@ app_name = "tickets"
 urlpatterns = [
     path("", TicketListView.as_view(), name="ticket_list_list"),
     path("search/", search, name="search"),
-    path("ticket_list_create/", TicketListCreateView.as_view(), name="ticket_list_create"),
     path("my_tickets/", ticket_list_detail, {"my_tickets": True}, name="my_tickets"),
     path("assignments/", ticket_list_detail, {"assignments": True}, name="assignments"),
 
     path("<int:pk>/", ticket_list_detail, name="ticket_list_detail"),
     path("<int:pk>/ticket_create/", TicketCreateView.as_view(), name="ticket_create"),
-    path("<int:pk>/delete", TicketListDeleteView.as_view(), name="ticket_list_delete"),
     
     path("ticket/<int:pk>/", TicketDetailView.as_view(), name="ticket_detail"),
     path("ticket/<int:pk>/edit", TicketEditView.as_view(), name="ticket_edit"),

+ 1 - 2
views/__init__.py

@@ -1,6 +1,5 @@
 from tickets.views.ticket_list_list import TicketListView
-from tickets.views.ticket_list_create import TicketListCreateView
-from tickets.views.delete import TicketDeleteView, TicketListDeleteView
+from tickets.views.delete import TicketDeleteView
 from tickets.views.ticket_list_detail import ticket_list_detail
 from tickets.views.ticket_create import TicketCreateView
 from tickets.views.search import search

+ 1 - 7
views/delete.py

@@ -4,7 +4,7 @@ from django.contrib import messages
 from django.shortcuts import get_object_or_404, redirect
 
 from tickets.models import TicketList, Ticket
-from tickets.utils import SuperuserStaffRequiredMixin, UserCanReadTicketListMixin, UserCanReadTicketMixin, UserCanWriteTicketMixin
+from tickets.utils import UserCanReadTicketListMixin, UserCanReadTicketMixin, UserCanWriteTicketMixin
 
 
 class BaseDeleteView(LoginRequiredMixin, View):
@@ -22,12 +22,6 @@ class BaseDeleteView(LoginRequiredMixin, View):
         return redirect(self.redirect_url)
 
 
-class TicketListDeleteView(BaseDeleteView, SuperuserStaffRequiredMixin):
-    model = TicketList
-    success_message = 'The "{0.name}" list has been successfully deleted from "{0.group.name}" group.'
-    redirect_url = "tickets:ticket_list_list"
-
-
 class TicketDeleteView(BaseDeleteView, UserCanWriteTicketMixin):
     model = Ticket
     success_message = 'The "{0.title}" ticket has been successfully deleted from {0.ticket_list} > {0.ticket_list.group}.'

+ 0 - 21
views/ticket_list_create.py

@@ -1,21 +0,0 @@
-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'))