Added models for swim-lanes, labels, and boards

This commit is contained in:
Charlie Crossley 2023-12-21 10:37:22 +00:00
parent 822cc71fef
commit 8fc629eb2f

View File

@ -4,31 +4,93 @@ import uuid
class Status(models.Model): class Status(models.Model):
status = models.CharField( """
Defines statuses which are used as columns on a board
"""
# Metadata
order_key = models.SmallIntegerField(
default=0,
)
class Meta:
ordering = ["order_key", "name"]
verbose_name_plural = "statuses"
# Data
name = models.CharField(
max_length=16, max_length=16,
unique=True,
)
class Label(models.Model):
"""
Defines labels which are inter-board groupings for tickets
"""
# Metadata
class Meta:
ordering = ["name"]
# Data
name = models.CharField(
max_length=64,
unique=True,
)
class Lane(models.Model):
"""
Defines "swim-lanes" which are intra-board groupings for tickets
"""
# Metadata
order_key = models.SmallIntegerField(
default=0,
)
class Meta:
ordering = ["order_key", "name"]
# Data
name = models.CharField(
max_length=16,
unique=True,
)
class Board(models.Model):
"""
Defines boards which are the default way of grouping tickets
"""
# Metadata
id = models.UUIDField(
primary_key=True, primary_key=True,
editable=False,
default=uuid.uuid4,
) )
order_key = models.SmallIntegerField( order_key = models.SmallIntegerField(
default=0, default=0,
) )
class Meta: class Meta:
ordering = ["order_key", "status"] ordering = ["order_key", "name"]
verbose_name_plural = "statuses"
# Data
name = models.CharField(
max_length=16,
unique=True,
)
class Card(models.Model): class Ticket(models.Model):
"""
Tickets are the atomic unit of the Kanban boards.
"""
# Metadata
id = models.UUIDField( id = models.UUIDField(
primary_key=True, primary_key=True,
editable=False, editable=False,
default=uuid.uuid4, default=uuid.uuid4,
) )
title = models.CharField(
max_length=64,
)
details = models.TextField(
blank=True,
)
created_datetime = models.DateTimeField( created_datetime = models.DateTimeField(
editable=False, editable=False,
auto_now_add=True, auto_now_add=True,
@ -38,29 +100,66 @@ class Card(models.Model):
on_delete=models.SET_NULL, on_delete=models.SET_NULL,
editable=False, editable=False,
null=True, null=True,
related_name="created_cards", related_name="created_tickets",
) )
order_key = models.SmallIntegerField(
default=0,
)
visible = models.BooleanField(
default=True,
)
class Meta:
get_latest_by = "created_date"
order_with_respect_to = "parent"
ordering = ["order_key", "title"]
# Data
title = models.CharField(
max_length=64,
)
details = models.TextField(
blank=True,
)
users = models.ManyToManyField( users = models.ManyToManyField(
get_user_model(), get_user_model(),
blank=True, blank=True,
) )
start_datetime = models.DateTimeField(
blank=True,
)
end_datetime = models.DateTimeField(
blank=True,
)
# Context Data
parent = models.ForeignKey( parent = models.ForeignKey(
# Optional parent ticket allows (infinite) heirarchy
# Should tickets be able to have parents from different boards?
"self", "self",
on_delete=models.CASCADE, on_delete=models.CASCADE,
blank=True, blank=True,
null=True, null=True,
related_name="children", related_name="children",
) )
relations = models.ManyToManyField(
"self",
blank=True,
)
status = models.ForeignKey( status = models.ForeignKey(
Status, Status,
on_delete=models.SET_NULL, on_delete=models.SET_NULL,
null=True, null=True,
) )
labels = models.ManyToManyField(
class Meta: Label,
get_latest_by = "created_date" on_delete=models.SET_NULL,
order_with_respect_to = "parent" blank=True,
null=True,
)
lane = models.ForeignKey(
Lane,
on_delete=models.SET_NULL,
null=True,
)
board = models.ForeignKey(
Board,
on_delete=models.CASCADE,
)