- New Features * Introduce CustomUser with role field and admin integration * Add ProjectMembership model linking users to projects * Add Ticket model with status, type, creator, and project relationships * Register CustomUser and ProjectMembership in Django admin with list views * Add URLs and views for account management and ticket CRUD operations - Enhancements * Provide pagination and filtering for ticket listings * Improve admin UI with role‑specific fieldsets - Bug Fixes * Remove obsolete serializers and placeholder files
38 lines
1.1 KiB
Python
38 lines
1.1 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"
|
|
|
|
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",
|
|
)
|
|
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)
|
|
created_at = models.DateTimeField(auto_now_add=True)
|
|
updated_at = models.DateTimeField(auto_now=True)
|
|
|
|
def __str__(self):
|
|
return f"[{self.ticket_type}] {self.title}"
|