summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Lemon <y@yulqen.org>2024-09-10 12:34:49 +0100
committerMatthew Lemon <y@yulqen.org>2024-09-10 12:34:49 +0100
commitc4fd33fce3dbef280657c150a7658462c80da877 (patch)
treecb366d210edc4bd8d40ea8e6f3af3e1cdd59d6b8
parent5fb0621c53967bf24f4411f579712223e96b296a (diff)
wip: implementing EngagementStrategy
Diffstat (limited to '')
-rw-r--r--engagements/migrations/0005_engagementstrategy.py62
-rw-r--r--engagements/models.py22
-rw-r--r--engagements/tests/conftest.py25
-rw-r--r--engagements/tests/test_models.py6
4 files changed, 103 insertions, 12 deletions
diff --git a/engagements/migrations/0005_engagementstrategy.py b/engagements/migrations/0005_engagementstrategy.py
new file mode 100644
index 0000000..213499d
--- /dev/null
+++ b/engagements/migrations/0005_engagementstrategy.py
@@ -0,0 +1,62 @@
+# Generated by Django 5.0.4 on 2024-09-10 11:24
+
+import django.db.models.deletion
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ("engagements", "0004_regulatorycycle_alter_engagementeffort_effort_type"),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name="EngagementStrategy",
+ fields=[
+ ("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
+ ("date_created", models.DateTimeField(auto_now_add=True)),
+ ("last_modified", models.DateTimeField(auto_now=True)),
+ ("name", models.CharField(max_length=128)),
+ ("description", models.TextField(max_length=1024)),
+ ("inspector_sign_off", models.DateField(blank=True, null=True)),
+ ("management_sign_off", models.DateField(blank=True, null=True)),
+ (
+ "status",
+ models.CharField(
+ choices=[
+ ("DRAFT", "Draft"),
+ ("SUBMITTED", "Submitted"),
+ ("APPROVED", "Approved"),
+ ("REJECTED", "Rejected"),
+ ],
+ default="DRAFT",
+ max_length=32,
+ ),
+ ),
+ (
+ "end_year",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="end_year",
+ to="engagements.regulatorycycle",
+ ),
+ ),
+ (
+ "organisation",
+ models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="engagements.organisation"),
+ ),
+ (
+ "start_year",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="start_year",
+ to="engagements.regulatorycycle",
+ ),
+ ),
+ ],
+ options={
+ "abstract": False,
+ },
+ ),
+ ]
diff --git a/engagements/models.py b/engagements/models.py
index ef0aee3..8876d91 100644
--- a/engagements/models.py
+++ b/engagements/models.py
@@ -255,9 +255,19 @@ class RegulatoryCycle(Common):
return f"Regulatory Cycle: {self.get_year()}"
-# class EngagementStrategy(Common):
-# name = models.CharField(max_length=128, null=False, blank=False)
-# start_date = models.DateField(null=False, blank=False)
-# end_date
-# description = models.TextField(max_length=1024)
-# engagement = models.ForeignKey(Engagement, on_delete=models.CASCADE)
+class EngagementStrategy(Common):
+ STATUS = (
+ ("DRAFT", "Draft"),
+ ("SUBMITTED", "Submitted"),
+ ("APPROVED", "Approved"),
+ ("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)
+ inspector_sign_off = models.DateField(null=True, blank=True)
+ management_sign_off = models.DateField(null=True, blank=True)
+ status = models.CharField(max_length=32, choices=STATUS, default=STATUS[0][0])
diff --git a/engagements/tests/conftest.py b/engagements/tests/conftest.py
index 72f1c11..b74feb5 100644
--- a/engagements/tests/conftest.py
+++ b/engagements/tests/conftest.py
@@ -1,8 +1,8 @@
-import pytest
-
from datetime import date
-from engagements.models import EngagementType, Organisation, Engagement, RegulatoryCycle
+import pytest
+
+from engagements.models import Engagement, EngagementStrategy, EngagementType, Organisation, RegulatoryCycle
from myuser.models import TeamUser
@@ -14,6 +14,25 @@ def regulatory_cycles():
@pytest.fixture
+def org():
+ return Organisation.objects.create(name="MOD", is_regulated_entity=False)
+
+
+@pytest.fixture
+def engagement_strategy(regulatory_cycles, org):
+ es = EngagementStrategy.objects.create(
+ name="ES1",
+ description="ES1 description",
+ start_year=RegulatoryCycle.objects.get(start_date="2022-01-01"),
+ end_year=RegulatoryCycle.objects.get(start_date="2024-01-01"),
+ organisation=org,
+ management_sign_off="2022-02-10",
+ inspector_sign_off="2022-01-10",
+ status="DRAFT",
+ )
+
+
+@pytest.fixture
def engagement():
data = {
"proposed_start_date": "2022-10-01",
diff --git a/engagements/tests/test_models.py b/engagements/tests/test_models.py
index d7aa458..426d728 100644
--- a/engagements/tests/test_models.py
+++ b/engagements/tests/test_models.py
@@ -1,7 +1,7 @@
import pytest
from engagements.utils import populate_database
-from engagements.models import RegulatoryCycle
+from engagements.models import RegulatoryCycle, EngagementStrategy
pytestmark = pytest.mark.django_db
@@ -39,5 +39,5 @@ def test_regulatory_cycle_model(regulatory_cycles):
assert str(rc2023) == "Regulatory Cycle: 2023"
-# def test_engagement_strategy_model(data):
-# assert EngagementStrategy.objects.first()
+def test_engagement_strategy_model(engagement_strategy):
+ assert EngagementStrategy.objects.first()