Added background colour for priorities and tags
This commit is contained in:
parent
8a6bddeb97
commit
b3b8d481fa
@ -1,4 +1,4 @@
|
||||
# Generated by Django 3.2.16 on 2024-01-05 15:18
|
||||
# Generated by Django 3.2.16 on 2024-01-07 18:40
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
@ -22,6 +22,7 @@ class Migration(migrations.Migration):
|
||||
('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
|
||||
('title', models.CharField(max_length=32)),
|
||||
('colour', models.CharField(max_length=7)),
|
||||
('backgroundcolour', models.CharField(max_length=7)),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
@ -30,6 +31,7 @@ class Migration(migrations.Migration):
|
||||
('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
|
||||
('title', models.CharField(max_length=32)),
|
||||
('colour', models.CharField(max_length=7)),
|
||||
('backgroundcolour', models.CharField(max_length=7)),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
|
@ -13,14 +13,14 @@ def create_priorities(app, schema_editor):
|
||||
TicketPriority = apps.get_model("home", "TicketPriority")
|
||||
|
||||
data = [
|
||||
{"title": "Urgent", "colour": "#FF0000"},
|
||||
{"title": "High", "colour": "#FFA500"},
|
||||
{"title": "Normal", "colour": "#FFFF00"},
|
||||
{"title": "Low", "colour": "#008000"}
|
||||
{"title": "Urgent", "colour": "#FFFFFF", "backgroundcolour": "#FF4D4D"},
|
||||
{"title": "High", "colour": "#FFFFFF", "backgroundcolour": "#FF884D"},
|
||||
{"title": "Normal", "colour": "#FFFFFF", "backgroundcolour": "#66CC66"},
|
||||
{"title": "Low", "colour": "#FFFFFF", "backgroundcolour": "#66DD66"}
|
||||
]
|
||||
|
||||
for item in data:
|
||||
priority = TicketPriority.objects.create(title=item["title"], colour=item["colour"])
|
||||
priority = TicketPriority.objects.create(title=item["title"], colour=item["colour"], backgroundcolour=item["backgroundcolour"])
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
@ -13,16 +13,16 @@ def create_tags(app, schema_editor):
|
||||
TicketTag = apps.get_model("home", "TicketTag")
|
||||
|
||||
data = [
|
||||
{"title": "Network", "colour": "#0000FF"},
|
||||
{"title": "Software", "colour": "#FFA500"},
|
||||
{"title": "Hardware", "colour": "#808080"},
|
||||
{"title": "Question", "colour": "#FFFF00"},
|
||||
{"title": "Requires Help", "colour": "#00FF00"},
|
||||
{"title": "Issue", "colour": "#FF0000"}
|
||||
{"title": "Network", "colour": "#000000", "backgroundcolour": "#BFD3C1"},
|
||||
{"title": "Software", "colour": "#000000", "backgroundcolour": "#FED8B1"},
|
||||
{"title": "Hardware", "colour": "#FFFFFF", "backgroundcolour": "#CCCCCC"},
|
||||
{"title": "Question", "colour": "#000000", "backgroundcolour": "#FFFCB1"},
|
||||
{"title": "Requires Help", "colour": "#000000", "backgroundcolour": "#B2E57C"},
|
||||
{"title": "Issue", "colour": "#000000", "backgroundcolour": "#FFB2B2"}
|
||||
]
|
||||
|
||||
for item in data:
|
||||
priority = TicketTag.objects.create(title=item["title"], colour=item["colour"])
|
||||
priority = TicketTag.objects.create(title=item["title"], colour=item["colour"], backgroundcolour=item["backgroundcolour"])
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
@ -15,6 +15,7 @@ class TicketPriority(models.Model):
|
||||
|
||||
title = models.CharField(max_length=32)
|
||||
colour = models.CharField(max_length=7)
|
||||
backgroundcolour = models.CharField(max_length=7)
|
||||
|
||||
def __str__(self):
|
||||
return self.title
|
||||
@ -23,7 +24,8 @@ class TicketPriority(models.Model):
|
||||
return {
|
||||
"id": self.id,
|
||||
"title": self.title,
|
||||
"colour": self.colour
|
||||
"colour": self.colour,
|
||||
"backgroundcolour": self.backgroundcolour
|
||||
}
|
||||
|
||||
|
||||
@ -32,6 +34,7 @@ class TicketTag(models.Model):
|
||||
|
||||
title = models.CharField(max_length=32)
|
||||
colour = models.CharField(max_length=7)
|
||||
backgroundcolour = models.CharField(max_length=7)
|
||||
|
||||
def __str__(self):
|
||||
return self.title
|
||||
@ -40,7 +43,8 @@ class TicketTag(models.Model):
|
||||
return {
|
||||
"id": self.id,
|
||||
"title": self.title,
|
||||
"colour": self.colour
|
||||
"colour": self.colour,
|
||||
"backgroundcolour": self.backgroundcolour
|
||||
}
|
||||
|
||||
|
||||
@ -104,7 +108,7 @@ class Ticket(models.Model):
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
self.description = self.clean_description()
|
||||
self.edit_timestamp = timezone.now()
|
||||
# self.edit_timestamp = timezone.now() ## TEMP COMMENT, UNCOMMENT LATER !!
|
||||
super().save(*args, **kwargs)
|
||||
|
||||
@property
|
||||
@ -133,6 +137,22 @@ class Ticket(models.Model):
|
||||
dayago = timezone.now() - timedelta(hours=24)
|
||||
return self.timestamp <= dayago
|
||||
|
||||
@property
|
||||
def was_yesterday(self) -> bool:
|
||||
"""_summary_
|
||||
|
||||
Returns
|
||||
-------
|
||||
bool
|
||||
_description_
|
||||
"""
|
||||
|
||||
now = timezone.now()
|
||||
midnight_today = now - timedelta(hours=now.hour, minutes=now.minute, seconds=now.second, microseconds=now.microsecond)
|
||||
|
||||
return self.timestamp < midnight_today
|
||||
|
||||
|
||||
@property
|
||||
def timestamp(self) -> datetime:
|
||||
"""Returns `self.edit_timestamp` if `self.is_edited` is True, otherwise
|
||||
@ -155,6 +175,7 @@ class Ticket(models.Model):
|
||||
"create_timestamp": self.create_timestamp,
|
||||
"edit_timestamp": self.edit_timestamp,
|
||||
"is_edited": self.is_edited,
|
||||
"was_yesterday": self.was_yesterday,
|
||||
"is_older_than_day": self.is_older_than_day,
|
||||
"timestamp": self.timestamp,
|
||||
"priority": self.priority.serialize(),
|
||||
|
Loading…
x
Reference in New Issue
Block a user