Browse Source

refactoring code using pycharm

blezz-tech 1 month ago
parent
commit
6c8d89e0e8

+ 7 - 5
admin.py

@@ -36,6 +36,7 @@ class TicketAdmin(admin.ModelAdmin):
         "note"
     )
 
+
 class TicketArchiveAdmin(admin.ModelAdmin):
     list_display = (
         "title",
@@ -54,11 +55,11 @@ class TicketArchiveAdmin(admin.ModelAdmin):
         "assigned_to",
         "created_at",
         "updated_at"
-        )
+    )
     search_fields = (
         "title",
         "note"
-        )
+    )
     readonly_fields = (
         "title",
         "ticket_list",
@@ -91,8 +92,9 @@ class AttachmentAdmin(admin.ModelAdmin):
         "timestamp",
         "file"
     )
-    autocomplete_fields = ["added_by",
-    "ticket"
+    autocomplete_fields = [
+        "added_by",
+        "ticket"
     ]
 
 
@@ -100,4 +102,4 @@ admin.site.register(TicketList, TicketListAdmin)
 admin.site.register(Ticket, TicketAdmin)
 admin.site.register(TicketArchive, TicketArchiveAdmin)
 admin.site.register(Comment, CommentAdmin)
-admin.site.register(Attachment, AttachmentAdmin)
+admin.site.register(Attachment, AttachmentAdmin)

+ 1 - 5
api/permissions.py

@@ -1,9 +1,5 @@
-from django.shortcuts import get_object_or_404
-
 from rest_framework import permissions
 
-from tickets.models import Ticket, TicketList
-
 
 class UserCanReadTicketListPermission(permissions.BasePermission):
     def has_object_permission(serf, request, view, obj):
@@ -20,4 +16,4 @@ class UserTicketAccessPermission(permissions.BasePermission):
 
 class UserTicketStatusAccessPermission(permissions.BasePermission):
     def has_object_permission(self, request, view, obj):
-        return request.user.is_superuser or obj.ticket_list.group in request.user.groups.all() or obj.assigned_to == request.user or obj.created_by == request.user
+        return request.user.is_superuser or obj.ticket_list.group in request.user.groups.all() or obj.assigned_to == request.user or obj.created_by == request.user

+ 1 - 1
api/serializers/__init__.py

@@ -1,2 +1,2 @@
 from tickets.api.serializers.ticket import TicketSerializer, TicketDetailSerializer, TicketStatusSerializer
-from tickets.api.serializers.ticket_list import TicketListSerializer
+from tickets.api.serializers.ticket_list import TicketListSerializer

+ 2 - 4
api/serializers/ticket.py

@@ -1,5 +1,3 @@
-from django.shortcuts import get_object_or_404
-
 from rest_framework import serializers
 
 from tickets.models import Ticket, TicketList
@@ -15,7 +13,7 @@ class BaseTicketSerializer(serializers.ModelSerializer):
         if ticket_list:
             if not (user.is_superuser or ticket_list.group in user.groups.all()):
                 raise serializers.ValidationError("You don't have access to this list.")
-        
+
         return data
 
 
@@ -56,4 +54,4 @@ class TicketStatusSerializer(BaseTicketSerializer):
 
     class Meta():
         model = Ticket
-        fields = ["id", "available_statuses", "status"]
+        fields = ["id", "available_statuses", "status"]

+ 1 - 1
api/serializers/ticket_list.py

@@ -6,4 +6,4 @@ from tickets.models import TicketList
 class TicketListSerializer(serializers.ModelSerializer):
     class Meta:
         model = TicketList
-        fields = "__all__"
+        fields = "__all__"

+ 1 - 1
api/views/__init__.py

@@ -1,2 +1,2 @@
+from tickets.api.views.ticket import *
 from tickets.api.views.ticket_list import *
-from tickets.api.views.ticket import *

+ 4 - 5
api/views/ticket.py

@@ -1,10 +1,9 @@
 from rest_framework import generics, permissions, status
-from rest_framework.views import APIView
 from rest_framework.response import Response
 
-from tickets.models import Ticket
-from tickets.api.serializers import TicketDetailSerializer, TicketSerializer, TicketStatusSerializer
 from tickets.api.permissions import UserTicketAccessPermission, UserTicketStatusAccessPermission
+from tickets.api.serializers import TicketDetailSerializer, TicketSerializer, TicketStatusSerializer
+from tickets.models import Ticket
 
 
 class TicketDetailAPIView(generics.RetrieveUpdateDestroyAPIView):
@@ -25,10 +24,10 @@ class TicketCreateAPIView(generics.CreateAPIView):
 
     def perform_create(self, serializer):
         if serializer.is_valid():
-            serializer.save(created_by=self.request.user) 
+            serializer.save(created_by=self.request.user)
 
 
 class TicketStatusAPIView(generics.RetrieveUpdateAPIView):
     queryset = Ticket.objects.all()
     serializer_class = TicketStatusSerializer
-    permission_classes = [permissions.IsAuthenticated & UserTicketStatusAccessPermission]
+    permission_classes = [permissions.IsAuthenticated & UserTicketStatusAccessPermission]

+ 6 - 6
api/views/ticket_list.py

@@ -1,10 +1,9 @@
 from django.shortcuts import get_object_or_404
-
 from rest_framework import generics, permissions
 
-from tickets.models import Ticket, TicketList
-from tickets.api.serializers import TicketListSerializer, TicketSerializer
 from tickets.api.permissions import UserCanReadTicketListPermission
+from tickets.api.serializers import TicketListSerializer, TicketSerializer
+from tickets.models import Ticket, TicketList
 
 
 class TicketListListAPIView(generics.ListAPIView):
@@ -14,12 +13,13 @@ class TicketListListAPIView(generics.ListAPIView):
     def get_queryset(self):
         user = self.request.user
         user_groups_ids = user.groups.all().values_list("pk", flat=True)
-        ticket_lists  = TicketList.objects.select_related("group").order_by("group__name", "name")
+        ticket_lists = TicketList.objects.select_related("group").order_by("group__name", "name")
 
         if not user.is_superuser:
             if user_groups_ids:
                 ticket_lists = ticket_lists.filter(group__id__in=user_groups_ids)
             else:
+                # ERROR:FIXME:NOTE:BUG: NotFound is not declarated. Need import some module
                 raise NotFound("You do not yet belong to any groups. Ask your administrator to add you to one.")
 
         return ticket_lists
@@ -33,7 +33,7 @@ class TicketListDetailAPIView(generics.ListAPIView):
         tickets = Ticket.objects.all()
 
         if self.kwargs.get("my"):
-            tickets = tickets.filter(assigned_to=self.request.user)     
+            tickets = tickets.filter(assigned_to=self.request.user)
         else:
             tickets = tickets.filter(ticket_list=self.get_object())
 
@@ -43,4 +43,4 @@ class TicketListDetailAPIView(generics.ListAPIView):
     def get_object(self):
         obj = get_object_or_404(TicketList.objects.filter(pk=self.kwargs['pk']))
         self.check_object_permissions(self.request, obj)
-        return obj   
+        return obj

+ 1 - 1
apps.py

@@ -3,4 +3,4 @@ from django.apps import AppConfig
 
 class TicketsConfig(AppConfig):
     default_auto_field = "django.db.models.BigAutoField"
-    name = "tickets"
+    name = "tickets"

+ 1 - 1
forms/__init__.py

@@ -1,2 +1,2 @@
+from tickets.forms.ticket import TicketForm
 from tickets.forms.ticket_list import TicketListForm
-from tickets.forms.ticket import TicketForm

+ 3 - 3
forms/ticket.py

@@ -1,6 +1,6 @@
 from django import forms
-from django.contrib.auth.models import Group
 from django.contrib.auth import get_user_model
+from django.contrib.auth.models import Group
 
 from tickets.models import Ticket, TicketList
 
@@ -17,7 +17,7 @@ class TicketForm(forms.ModelForm):
 
         self.fields['assigned_to'].queryset = get_user_model().objects.all().order_by('username')
         self.fields["ticket_list"].queryset = ticket_lists
-        
+
         self.fields["ticket_list"].label_from_instance = lambda obj: f"{obj.group} > {obj}"
 
         if self.instance.pk:
@@ -53,4 +53,4 @@ class TicketForm(forms.ModelForm):
             'priority': forms.NumberInput(attrs={
                 'class': 'form-control',
             }),
-        }
+        }

+ 2 - 2
forms/ticket_list.py

@@ -16,7 +16,7 @@ class TicketListForm(forms.ModelForm):
     class Meta:
         model = TicketList
         fields = "__all__"
-        
+
         labels = {
             'name': 'List Name',
             'group': 'Group',
@@ -31,4 +31,4 @@ class TicketListForm(forms.ModelForm):
             'group': forms.Select(attrs={
                 'class': 'form-control',
             }),
-        }
+        }

+ 1 - 1
models/__init__.py

@@ -1,4 +1,4 @@
 from tickets.models.attachment import *
 from tickets.models.comment import *
+from tickets.models.ticket import *
 from tickets.models.ticket_list import *
-from tickets.models.ticket import *

+ 2 - 2
models/attachment.py

@@ -1,7 +1,7 @@
 import os
 
-from django.db import models
 from django.contrib.auth import get_user_model
+from django.db import models
 
 from tickets.models.ticket import Ticket
 
@@ -24,4 +24,4 @@ class Attachment(models.Model):
         return extension
 
     def __str__(self):
-        return f"{self.ticket.pk} - {self.file.name}"
+        return f"{self.ticket.pk} - {self.file.name}"

+ 2 - 2
models/comment.py

@@ -1,7 +1,7 @@
 import textwrap
 
-from django.db import models
 from django.contrib.auth import get_user_model
+from django.db import models
 
 from tickets.models.ticket import Ticket
 
@@ -36,4 +36,4 @@ class Comment(models.Model):
         return "{author} - {snippet}...".format(author=self.author_text, snippet=body_snippet)
 
     def __str__(self):
-        return self.snippet
+        return self.snippet

+ 32 - 8
models/ticket.py

@@ -1,7 +1,6 @@
+from django.contrib.auth import get_user_model
 from django.db import models, transaction
 from django.urls import reverse
-from django.contrib.auth import get_user_model
-from django.core.exceptions import ValidationError
 
 from tickets.models.ticket_list import TicketList
 
@@ -85,8 +84,20 @@ class Ticket(models.Model):
     created_at = models.DateTimeField(auto_now_add=True, editable=False)
     updated_at = models.DateTimeField(auto_now=True)
     due_date = models.DateField()
-    created_by = models.ForeignKey(get_user_model(), on_delete=models.SET_NULL, null=True, related_name="created_by", editable=False)
-    assigned_to = models.ForeignKey(get_user_model(), on_delete=models.SET_NULL, null=True, blank=True, related_name="assigned_to")
+    created_by = models.ForeignKey(
+        get_user_model(),
+        on_delete=models.SET_NULL,
+        null=True,
+        related_name="created_by",
+        editable=False
+    )
+    assigned_to = models.ForeignKey(
+        get_user_model(),
+        on_delete=models.SET_NULL,
+        null=True,
+        blank=True,
+        related_name="assigned_to"
+    )
     note = models.TextField(blank=True, null=True)
     json = models.TextField(blank=True, null=True)
     priority = models.PositiveSmallIntegerField(default=0)
@@ -134,7 +145,7 @@ class Ticket(models.Model):
     def save(self, *args, **kwargs):
         if not self.status:
             self.set_first_status()
-        
+
         super(Ticket, self).save(*args, **kwargs)
 
     def get_absolute_url(self):
@@ -152,9 +163,22 @@ class TicketArchive(models.Model):
     created_at = models.DateTimeField(editable=False)
     updated_at = models.DateTimeField(auto_now_add=True, editable=False)
     due_date = models.DateField(editable=False)
-    created_by = models.ForeignKey(get_user_model(), on_delete=models.SET_NULL, null=True, related_name="ticket_archive_created_by", editable=False)
-    assigned_to = models.ForeignKey(get_user_model(), on_delete=models.SET_NULL, null=True, blank=True, related_name="ticket_archive_assigned_to", editable=False)
+    created_by = models.ForeignKey(
+        get_user_model(),
+        on_delete=models.SET_NULL,
+        null=True,
+        related_name="ticket_archive_created_by",
+        editable=False
+    )
+    assigned_to = models.ForeignKey(
+        get_user_model(),
+        on_delete=models.SET_NULL,
+        null=True,
+        blank=True,
+        related_name="ticket_archive_assigned_to",
+        editable=False
+    )
     note = models.TextField(blank=True, null=True, editable=False)
 
     def get_status_display(self):
-        return Ticket.TICKET_STATUSES_NAMES.get(self.status)
+        return Ticket.TICKET_STATUSES_NAMES.get(self.status)

+ 1 - 1
models/ticket_list.py

@@ -11,4 +11,4 @@ class TicketList(models.Model):
 
     class Meta:
         ordering = ["group__name", "name"]
-        unique_together = ("group", "name")
+        unique_together = ("group", "name")

+ 3 - 4
urls.py

@@ -1,8 +1,7 @@
 from django.urls import path
 
-from tickets.views import *
 from tickets.api import views as apiviews
-
+from tickets.views import *
 
 app_name = "tickets"
 
@@ -14,7 +13,7 @@ urlpatterns = [
 
     path("<int:pk>/", ticket_list_detail, name="ticket_list_detail"),
     path("<int:pk>/ticket_create/", TicketCreateView.as_view(), name="ticket_create"),
-    
+
     path("ticket/<int:pk>/", TicketDetailView.as_view(), name="ticket_detail"),
     path("ticket/<int:pk>/edit", TicketEditView.as_view(), name="ticket_edit"),
     path("ticket/<int:pk>/delete", TicketDeleteView.as_view(), name="ticket_delete"),
@@ -27,4 +26,4 @@ urlpatterns = [
     path("api/ticket/", apiviews.TicketCreateAPIView.as_view()),
     path("api/ticket/<int:pk>", apiviews.TicketDetailAPIView.as_view()),
     path("api/ticket/<int:pk>/status", apiviews.TicketStatusAPIView.as_view()),
-]
+]

+ 5 - 4
utils.py

@@ -1,12 +1,10 @@
 import logging
-import os
 
 from django.contrib.auth.mixins import UserPassesTestMixin
 from django.shortcuts import get_object_or_404
 
 from tickets.models import *
 
-
 log = logging.getLogger(__name__)
 
 
@@ -23,7 +21,10 @@ class UserCanReadTicketListMixin(UserPassesTestMixin):
 
 class UserCanReadTicketMixin(UserPassesTestMixin):
     def test_func(self):
-        ticket = get_object_or_404(Ticket.objects.select_related('ticket_list', 'ticket_list__group'), pk=self.kwargs.get('pk'))
+        ticket = get_object_or_404(
+            Ticket.objects.select_related('ticket_list', 'ticket_list__group'),
+            pk=self.kwargs.get('pk')
+        )
         return ticket.ticket_list.group in self.request.user.groups.all() or ticket.assigned_to == self.request.user
 
 
@@ -46,4 +47,4 @@ def remove_attachment_file(attachment_id: int) -> bool:
 
     except Attachment.DoesNotExist:
         log.info(f"Attachment {attachment_id} not found.")
-        return False
+        return False

+ 5 - 5
views/__init__.py

@@ -1,8 +1,8 @@
-from tickets.views.ticket_list_list import TicketListView
+from tickets.views.attachment_remove import remove_attachment
 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
+from tickets.views.ticket_create import TicketCreateView
+from tickets.views.ticket_detail import TicketDetailView
 from tickets.views.ticket_edit import TicketEditView
-from tickets.views.attachment_remove import remove_attachment
-from tickets.views.ticket_detail import TicketDetailView
+from tickets.views.ticket_list_detail import ticket_list_detail
+from tickets.views.ticket_list_list import TicketListView

+ 2 - 1
views/attachment_remove.py

@@ -13,7 +13,8 @@ def remove_attachment(request, attachment_id):
     if request.method == "POST":
         attachment = get_object_or_404(Attachment, pk=attachment_id)
 
-        if not (attachment.added_by == request.user or attachment.ticket.created_by == request.user) and (attachment.ticket.list.group in request.user.groups.all()):
+        if not (attachment.added_by == request.user or attachment.ticket.created_by == request.user) and (
+                attachment.ticket.list.group in request.user.groups.all()):
             raise PermissionDenied
 
         if remove_attachment_file(attachment.id):

+ 5 - 5
views/delete.py

@@ -1,10 +1,10 @@
-from django.views import View
-from django.contrib.auth.mixins import LoginRequiredMixin
 from django.contrib import messages
+from django.contrib.auth.mixins import LoginRequiredMixin
 from django.shortcuts import get_object_or_404, redirect
+from django.views import View
 
-from tickets.models import TicketList, Ticket
-from tickets.utils import UserCanReadTicketListMixin, UserCanReadTicketMixin, UserCanWriteTicketMixin
+from tickets.models import Ticket
+from tickets.utils import UserCanWriteTicketMixin
 
 
 class BaseDeleteView(LoginRequiredMixin, View):
@@ -14,7 +14,7 @@ class BaseDeleteView(LoginRequiredMixin, View):
 
     def post(self, request, pk):
         object = get_object_or_404(self.model, pk=pk)
-        
+
         if self.success_message:
             messages.success(self.request, self.success_message.format(object))
 

+ 2 - 3
views/search.py

@@ -1,7 +1,6 @@
 from django.contrib.auth.decorators import login_required
 from django.db.models import Q, F
 from django.shortcuts import render
-from django.db.models.functions import Concat
 
 from tickets.models import Ticket
 
@@ -10,7 +9,7 @@ from tickets.models import Ticket
 def search(request):
     found_tickets = None
     query_string = ""
-    
+
     if request.GET:
         if ("search" in request.GET) and request.GET["search"].strip():
             query_string = request.GET["search"]
@@ -19,7 +18,7 @@ def search(request):
                 Q(ticket_list__group__in=request.user.groups.all())
                 | Q(assigned_to=request.user)
             )
-            
+
             found_tickets = found_tickets.annotate(created_by_username=F("created_by__username"))
             found_tickets = found_tickets.annotate(assigned_to_username=F("assigned_to__username"))
 

+ 7 - 5
views/ticket_create.py

@@ -1,9 +1,8 @@
 import bleach
-
-from django.contrib.auth.mixins import LoginRequiredMixin
 from django.contrib import messages
-from django.urls import reverse_lazy
+from django.contrib.auth.mixins import LoginRequiredMixin
 from django.shortcuts import redirect
+from django.urls import reverse_lazy
 from django.views import View
 
 from tickets.forms import TicketForm
@@ -20,8 +19,11 @@ class TicketCreateView(LoginRequiredMixin, UserCanReadTicketListMixin, View):
             new_ticket.note = bleach.clean(form.cleaned_data["note"], strip=True)
             new_ticket.save()
 
-            messages.success(self.request, f'The "{new_ticket.title}" ticket has been successfully created in {new_ticket.ticket_list.group} > {new_ticket.ticket_list}.')
+            messages.success(
+                self.request,
+                f'The "{new_ticket.title}" ticket has been successfully created in {new_ticket.ticket_list.group} > {new_ticket.ticket_list}.'
+            )
         else:
             messages.error(self.request, "Failed to create the ticket.")
 
-        return redirect(reverse_lazy('tickets:ticket_list_detail', kwargs={'pk': pk}))
+        return redirect(reverse_lazy('tickets:ticket_list_detail', kwargs={'pk': pk}))

+ 4 - 4
views/ticket_detail.py

@@ -1,10 +1,10 @@
-import bleach
 import os
 
+import bleach
 from django.contrib import messages
 from django.contrib.auth.mixins import LoginRequiredMixin
-from django.shortcuts import redirect
 from django.db.models import F
+from django.shortcuts import redirect
 from django.views.generic import DetailView
 
 from tickets.forms import TicketForm
@@ -28,7 +28,7 @@ class TicketDetailView(LoginRequiredMixin, UserCanReadTicketMixin, DetailView):
             author_username=F("author__username"), author_email=F("author__email")
         )
         context['attachments'] = Attachment.objects.filter(ticket=self.object.pk).select_related("added_by")
-        
+
         # List with statuses codes & their names
         available_statuses_with_names = []
         available_statuses = self.object.get_available_statuses()
@@ -45,7 +45,7 @@ class TicketDetailView(LoginRequiredMixin, UserCanReadTicketMixin, DetailView):
 
         if request.POST.get("ticket-status"):
             status = request.POST.get("ticket-status")
-            
+
             if int(status) in ticket.get_available_statuses():
                 ticket.status = int(status)
                 ticket.save()

+ 8 - 6
views/ticket_edit.py

@@ -1,14 +1,13 @@
 import bleach
-
-from django.contrib.auth.mixins import LoginRequiredMixin
 from django.contrib import messages
-from django.urls import reverse_lazy
+from django.contrib.auth.mixins import LoginRequiredMixin
 from django.shortcuts import redirect, get_object_or_404
+from django.urls import reverse_lazy
 from django.views import View
 
 from tickets.forms import TicketForm
-from tickets.utils import UserCanWriteTicketMixin
 from tickets.models import Ticket
+from tickets.utils import UserCanWriteTicketMixin
 
 
 class TicketEditView(LoginRequiredMixin, UserCanWriteTicketMixin, View):
@@ -21,8 +20,11 @@ class TicketEditView(LoginRequiredMixin, UserCanWriteTicketMixin, View):
             ticket.note = bleach.clean(form.cleaned_data["note"], strip=True)
             ticket.save()
 
-            messages.success(self.request, f'The "{ticket.title}" ticket has been successfully edited in {ticket.ticket_list.group} > {ticket.ticket_list}.')
+            messages.success(
+                self.request,
+                f'The "{ticket.title}" ticket has been successfully edited in {ticket.ticket_list.group} > {ticket.ticket_list}.'
+            )
         else:
             messages.error(self.request, "Failed to edit the ticket.")
 
-        return redirect(reverse_lazy('tickets:ticket_detail', kwargs={'pk': pk}))
+        return redirect(reverse_lazy('tickets:ticket_detail', kwargs={'pk': pk}))

+ 7 - 7
views/ticket_list_detail.py

@@ -1,8 +1,8 @@
-from django.contrib import messages
+from django.contrib.auth.decorators import login_required
 from django.contrib.auth.decorators import login_required
 from django.core.exceptions import PermissionDenied
-from django.shortcuts import get_object_or_404, redirect, render
-from django.db.models import F, Count
+from django.db.models import F
+from django.shortcuts import get_object_or_404, render
 
 from tickets.forms import TicketForm
 from tickets.models import Ticket, TicketList
@@ -12,9 +12,9 @@ from tickets.models import Ticket, TicketList
 def ticket_list_detail(request, pk=None, my_tickets=False, assignments=False):
     form = None
     ticket_list = None
-    
+
     if my_tickets:
-        tickets = Ticket.objects.filter(assigned_to=request.user) 
+        tickets = Ticket.objects.filter(assigned_to=request.user)
     elif assignments:
         tickets = Ticket.objects.filter(created_by=request.user)
     else:
@@ -30,10 +30,10 @@ def ticket_list_detail(request, pk=None, my_tickets=False, assignments=False):
                 "ticket_list": ticket_list
             }
         )
-    
+
     tickets = tickets.annotate(created_by_username=F("created_by__username"))
     tickets = tickets.annotate(assigned_to_username=F("assigned_to__username"))
-    
+
     context = {
         "ticket_list": ticket_list,
         "tickets": tickets,

+ 8 - 6
views/ticket_list_list.py

@@ -1,10 +1,9 @@
 from django.contrib import messages
 from django.contrib.auth.mixins import LoginRequiredMixin
-from django.db.models import Count, Sum, Q
 from django.views.generic import ListView
 
-from tickets.models import TicketList
 from tickets.forms import TicketListForm
+from tickets.models import TicketList
 
 
 class TicketListView(LoginRequiredMixin, ListView):
@@ -15,16 +14,19 @@ class TicketListView(LoginRequiredMixin, ListView):
     def get_queryset(self):
         user = self.request.user
         user_groups_ids = user.groups.all().values_list("pk", flat=True)
-        ticket_lists  = TicketList.objects.select_related("group").order_by("group__name", "name")
-    
+        ticket_lists = TicketList.objects.select_related("group").order_by("group__name", "name")
+
         if user_groups_ids:
             ticket_lists = ticket_lists.filter(group__id__in=user_groups_ids)
         else:
-            messages.warning(self.request, "You do not yet belong to any groups. Ask your administrator to add you to one.")
+            messages.warning(
+                self.request,
+                "You do not yet belong to any groups. Ask your administrator to add you to one."
+            )
             ticket_lists = TicketList.objects.none()
 
         return ticket_lists
-    
+
     def get_context_data(self, **kwargs):
         context = super().get_context_data(**kwargs)
         context["form"] = TicketListForm(self.request.user)