From 7bbf314108bcf266846d2b8b9bd152197ae122f2 Mon Sep 17 00:00:00 2001 From: Jeenyhus Date: Tue, 24 Oct 2023 14:10:36 +0200 Subject: [PATCH 1/5] Archive feature for admin or super admin to archive support tickets from the system --- techsupport/models.py | 28 ++++- techsupport/templates/base.html | 30 +++--- techsupport/templates/dashboard.html | 49 +++++---- .../templates/support_ticket/all_tickets.html | 4 +- techsupport/templatetags/custom_filters.py | 6 +- techsupport/urls.py | 9 ++ techsupport/views.py | 102 ++++++++++++++++-- 7 files changed, 184 insertions(+), 44 deletions(-) diff --git a/techsupport/models.py b/techsupport/models.py index d881541..7289497 100644 --- a/techsupport/models.py +++ b/techsupport/models.py @@ -363,6 +363,7 @@ class Priority(models.TextChoices): blank=True, ) resolution_notes = models.TextField(blank=True) + id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) assigned_to = models.ForeignKey( User, @@ -372,7 +373,18 @@ class Priority(models.TextChoices): blank=True, related_name="assigned_tickets", ) - + archived = models.BooleanField(default=False, verbose_name=_("archived")) + date_archived = models.DateTimeField( + null=True, blank=True, verbose_name=_("date archived") + ) + previous_status = models.CharField( + max_length=30, + verbose_name=_("previous status"), + choices=Status.choices, + null=True, + blank=True, + ) + def save(self, *args, **kwargs): """ Override the save method to set the ticket number and support description. @@ -414,3 +426,17 @@ def ticket_age(self): return f"{hours} hrs ago" else: return f"{minutes} mins ago" + +class ArchivedSupportTicket(BaseModel): + support_ticket = models.OneToOneField( + SupportTicket, + on_delete=models.CASCADE, + related_name="archived_ticket", + verbose_name=_("support ticket"), + ) + + def unarchive(self): + self.support_ticket.status = SupportTicket.Status.OPEN + self.support_ticket.date_resolved = None + self.support_ticket.save() + self.delete() \ No newline at end of file diff --git a/techsupport/templates/base.html b/techsupport/templates/base.html index 1f1bfe6..56636d4 100644 --- a/techsupport/templates/base.html +++ b/techsupport/templates/base.html @@ -64,6 +64,12 @@
Technical Support
Profile + {% if user.is_admin or user.is_superuser %} + + + Archive + + {% endif %} @@ -75,20 +81,20 @@
Technical Support
- -
-
-
- {% if messages %} - {% for message in messages %} - - {% endfor %} - {% endif %} + +
+
+
+ {% if messages %} + {% for message in messages %} + + {% endfor %} + {% endif %}
-
+
+