summaryrefslogtreecommitdiffstats
path: root/engagements/models.py
diff options
context:
space:
mode:
authorMatthew Lemon <y@yulqen.org>2024-09-10 14:08:35 +0100
committerMatthew Lemon <y@yulqen.org>2024-09-10 14:08:35 +0100
commit15eceda8c762c3e3890f2c160d1c89c36a7b398b (patch)
treea7765189c59d81cdf1368b7989d2ed22c404cbc5 /engagements/models.py
parentc4fd33fce3dbef280657c150a7658462c80da877 (diff)
ES basically done
Diffstat (limited to 'engagements/models.py')
-rw-r--r--engagements/models.py28
1 files changed, 26 insertions, 2 deletions
diff --git a/engagements/models.py b/engagements/models.py
index 8876d91..45d8e69 100644
--- a/engagements/models.py
+++ b/engagements/models.py
@@ -5,6 +5,8 @@ from django.utils.text import slugify
from myuser.models import TeamUser
+ES_YEAR_LENGTH = 3
+
class Common(models.Model):
date_created = models.DateTimeField(auto_now_add=True)
@@ -263,11 +265,33 @@ class EngagementStrategy(Common):
("REJECTED", "Rejected"),
)
- name = models.CharField(max_length=128, null=False, blank=False)
organisation = models.ForeignKey(Organisation, on_delete=models.CASCADE)
start_year = models.ForeignKey(RegulatoryCycle, on_delete=models.CASCADE, related_name="start_year")
end_year = models.ForeignKey(RegulatoryCycle, on_delete=models.CASCADE, related_name="end_year")
- description = models.TextField(max_length=1024)
+ description = models.TextField(max_length=1024, null=True, blank=True)
inspector_sign_off = models.DateField(null=True, blank=True)
+ owned_by = models.ForeignKey(
+ settings.AUTH_USER_MODEL, on_delete=models.CASCADE, related_name="owned_engagement_strategies"
+ )
+ reviewed_by = models.ForeignKey(
+ settings.AUTH_USER_MODEL,
+ null=True,
+ blank=True,
+ on_delete=models.CASCADE,
+ related_name="reviewed_engagement_strategies",
+ )
management_sign_off = models.DateField(null=True, blank=True)
status = models.CharField(max_length=32, choices=STATUS, default=STATUS[0][0])
+
+ def get_end_year(self) -> int:
+ return self.start_year.start_date.year + (ES_YEAR_LENGTH - 1)
+
+ def __str__(self):
+ return (
+ f"Engagement Strategy ({self.start_year.start_date.year}-{self.get_end_year()}) - {self.organisation.name}"
+ )
+
+ class Meta:
+ ordering = ("start_year",)
+ unique_together = ("start_year", "organisation")
+ verbose_name_plural = "Engagement Strategies"