|
@@ -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)
|