New Features: - Add `Priority` enum and `priority` field to `Card` model. - Add `TicketComment` model and `TicketCommentCreateView` with inline comment support. - Introduce templatetag filters `add_class`, `field_type`, and `render_markdown`. Enhancements: - Extend `CustomUser.is_admin()` to recognise superusers. - Populate `KanbanConfig.ready()` to import signals for proper initialization. - Expand ticket views and URLs to include assignee, priority, and comment handling. Bug Fixes: - None.
67 lines
2.0 KiB
Python
67 lines
2.0 KiB
Python
from django.db import models
|
|
|
|
|
|
class Ticket(models.Model):
|
|
class TicketType(models.TextChoices):
|
|
BUG = "bug"
|
|
FEATURE = "feature_request"
|
|
SUPPORT = "support"
|
|
|
|
class Status(models.TextChoices):
|
|
NEW = "new"
|
|
ACKNOWLEDGED = "acknowledged"
|
|
IN_PROGRESS = "in_progress"
|
|
DONE = "done"
|
|
REJECTED = "rejected"
|
|
|
|
class Priority(models.TextChoices):
|
|
LOW = "low"
|
|
MEDIUM = "medium"
|
|
HIGH = "high"
|
|
|
|
creator = models.ForeignKey(
|
|
"accounts.CustomUser",
|
|
on_delete=models.CASCADE,
|
|
related_name="created_tickets",
|
|
)
|
|
project = models.ForeignKey(
|
|
"projects.Project",
|
|
null=True,
|
|
blank=True,
|
|
on_delete=models.CASCADE,
|
|
related_name="tickets",
|
|
)
|
|
assignee = models.ForeignKey(
|
|
"accounts.CustomUser",
|
|
null=True,
|
|
blank=True,
|
|
on_delete=models.SET_NULL,
|
|
related_name="assigned_tickets",
|
|
)
|
|
title = models.CharField(max_length=255)
|
|
description = models.TextField(blank=True)
|
|
ticket_type = models.CharField(max_length=30, choices=TicketType.choices, default=TicketType.SUPPORT)
|
|
status = models.CharField(max_length=30, choices=Status.choices, default=Status.NEW)
|
|
priority = models.CharField(max_length=20, choices=Priority.choices, default=Priority.MEDIUM)
|
|
created_at = models.DateTimeField(auto_now_add=True)
|
|
updated_at = models.DateTimeField(auto_now=True)
|
|
|
|
class Meta:
|
|
ordering = ["-created_at"]
|
|
|
|
def __str__(self):
|
|
return f"[{self.ticket_type}] {self.title}"
|
|
|
|
|
|
class TicketComment(models.Model):
|
|
ticket = models.ForeignKey(Ticket, on_delete=models.CASCADE, related_name="comments")
|
|
author = models.ForeignKey("accounts.CustomUser", on_delete=models.CASCADE)
|
|
body = models.TextField()
|
|
created_at = models.DateTimeField(auto_now_add=True)
|
|
|
|
class Meta:
|
|
ordering = ["created_at"]
|
|
|
|
def __str__(self):
|
|
return f"Comment by {self.author} on {self.ticket}"
|