Files
project-managment/apps/kanban/models.py
T
sankalp 3197ef1665 feat(apps): implement priority handling and comment system for kanban cards
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.
2026-05-28 00:27:02 +05:45

101 lines
2.8 KiB
Python

from django.db import models
class BoardQuerySet(models.QuerySet):
def for_user(self, user):
return self.filter(owner=user)
class Board(models.Model):
owner = models.ForeignKey(
"accounts.CustomUser",
on_delete=models.CASCADE,
related_name="boards",
)
project = models.ForeignKey(
"projects.Project",
null=True,
blank=True,
on_delete=models.CASCADE,
related_name="boards",
)
name = models.CharField(max_length=255, default="My Board")
created_at = models.DateTimeField(auto_now_add=True)
objects = BoardQuerySet.as_manager()
def __str__(self):
return f"{self.name} ({self.owner})"
class Column(models.Model):
board = models.ForeignKey(Board, on_delete=models.CASCADE, related_name="columns")
name = models.CharField(max_length=100)
order = models.PositiveIntegerField(default=0)
class Meta:
ordering = ["order"]
def __str__(self):
return f"{self.name}"
class Card(models.Model):
class Priority(models.TextChoices):
LOW = "low", "Low"
MEDIUM = "medium", "Medium"
HIGH = "high", "High"
URGENT = "urgent", "Urgent"
column = models.ForeignKey(Column, on_delete=models.CASCADE, related_name="cards")
title = models.CharField(max_length=255)
description = models.TextField(blank=True)
priority = models.CharField(
max_length=10, choices=Priority.choices, default=Priority.MEDIUM
)
assignee = models.ForeignKey(
"accounts.CustomUser",
null=True,
blank=True,
on_delete=models.SET_NULL,
related_name="assigned_cards",
)
start_date = models.DateField(null=True, blank=True)
end_date = models.DateField(null=True, blank=True)
due_date = models.DateField(null=True, blank=True)
deadline_notification = models.BooleanField(default=False)
order = models.PositiveIntegerField(default=0)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
class Meta:
ordering = ["order"]
def __str__(self):
return self.title
class CardComment(models.Model):
card = models.ForeignKey(Card, on_delete=models.CASCADE, related_name="comments")
author = models.ForeignKey(
"accounts.CustomUser",
on_delete=models.CASCADE,
related_name="card_comments",
)
body = models.TextField()
parent = models.ForeignKey(
"self",
null=True,
blank=True,
on_delete=models.CASCADE,
related_name="replies",
)
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"Comment by {self.author} on {self.card}"