Skip to content

Commit

Permalink
Add new REPLACED status for SignedAgreements
Browse files Browse the repository at this point in the history
This status indicates CDSAs that were replaced by newer agreements.
We do not maintain a link to the CDSA that it is replacing in django;
that is handled in outside pre-tracking.
  • Loading branch information
amstilp committed Jan 18, 2024
1 parent 6975fc0 commit 948b3fd
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 15 deletions.
46 changes: 46 additions & 0 deletions primed/cdsa/migrations/0011_signedagreement_add_replaced_status.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Generated by Django 4.2.8 on 2024-01-18 23:49

from django.db import migrations
import model_utils.fields


class Migration(migrations.Migration):

dependencies = [
("cdsa", "0010_alter_historicalsignedagreement_status_and_more"),
]

operations = [
migrations.AlterField(
model_name="historicalsignedagreement",
name="status",
field=model_utils.fields.StatusField(
choices=[
("active", "Active"),
("withdrawn", "Withdrawn"),
("lapsed", "Lapsed"),
("replaced", "Replaced"),
],
default="active",
max_length=100,
no_check_for_status=True,
verbose_name="status",
),
),
migrations.AlterField(
model_name="signedagreement",
name="status",
field=model_utils.fields.StatusField(
choices=[
("active", "Active"),
("withdrawn", "Withdrawn"),
("lapsed", "Lapsed"),
("replaced", "Replaced"),
],
default="active",
max_length=100,
no_check_for_status=True,
verbose_name="status",
),
),
]
3 changes: 3 additions & 0 deletions primed/cdsa/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ class StatusChoices(models.TextChoices):
LAPSED = "lapsed", "Lapsed"
"""SignedAgreements from a AgreementMajorVersion that is no longer valid."""

REPLACED = "replaced", "Replaced"
"""SignedAgreements that have been replaced by a newer version."""

STATUS = StatusChoices.choices


Expand Down
20 changes: 5 additions & 15 deletions primed/cdsa/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,21 +209,6 @@ def test_get_absolute_url(self):
instance.signed_agreement.get_absolute_url(), instance.get_absolute_url()
)

def test_statuses(self):
"""All allowed statuses."""
instance = factories.SignedAgreementFactory.create(
status=models.SignedAgreement.StatusChoices.ACTIVE
)
instance.full_clean()
instance = factories.SignedAgreementFactory.create(
status=models.SignedAgreement.StatusChoices.WITHDRAWN
)
instance.full_clean()
instance = factories.SignedAgreementFactory.create(
status=models.SignedAgreement.StatusChoices.LAPSED
)
instance.full_clean()

def test_member_choices(self):
"""Can create instances with all of the member choices."""
instance = factories.SignedAgreementFactory.create(
Expand Down Expand Up @@ -319,6 +304,11 @@ def test_status_field(self):
)
self.assertEqual(instance.status, instance.StatusChoices.LAPSED)
instance.full_clean()
instance = factories.SignedAgreementFactory.create(
status=models.SignedAgreement.StatusChoices.REPLACED
)
self.assertEqual(instance.status, instance.StatusChoices.REPLACED)
instance.full_clean()

# not allowed
instance = factories.SignedAgreementFactory.create(status="foo")
Expand Down

0 comments on commit 948b3fd

Please sign in to comment.