diff --git a/backend/src/openarchiefbeheer/destruction/api/serializers.py b/backend/src/openarchiefbeheer/destruction/api/serializers.py index 8e4fb1b3d..177c053b8 100644 --- a/backend/src/openarchiefbeheer/destruction/api/serializers.py +++ b/backend/src/openarchiefbeheer/destruction/api/serializers.py @@ -125,4 +125,5 @@ class Meta: "items", "status", "created", + "status_changed", ) diff --git a/backend/src/openarchiefbeheer/destruction/migrations/0003_destructionlist_status_changed.py b/backend/src/openarchiefbeheer/destruction/migrations/0003_destructionlist_status_changed.py new file mode 100644 index 000000000..1b5b5c059 --- /dev/null +++ b/backend/src/openarchiefbeheer/destruction/migrations/0003_destructionlist_status_changed.py @@ -0,0 +1,23 @@ +# Generated by Django 4.2.11 on 2024-05-23 09:14 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("destruction", "0002_destructionlistassignee"), + ] + + operations = [ + migrations.AddField( + model_name="destructionlist", + name="status_changed", + field=models.DateTimeField( + blank=True, + help_text="Tracks when the status was changed.", + null=True, + verbose_name="status changed", + ), + ), + ] diff --git a/backend/src/openarchiefbeheer/destruction/models.py b/backend/src/openarchiefbeheer/destruction/models.py index fb5e12093..8d7a8b029 100644 --- a/backend/src/openarchiefbeheer/destruction/models.py +++ b/backend/src/openarchiefbeheer/destruction/models.py @@ -56,6 +56,12 @@ class DestructionList(models.Model): choices=ListStatus.choices, max_length=80, ) + status_changed = models.DateTimeField( + _("status changed"), + help_text=_("Tracks when the status was changed."), + blank=True, + null=True, + ) zaak_destruction_report_url = models.URLField( _("zaak destruction report URL"), help_text=_( @@ -75,6 +81,11 @@ def __str__(self): def assign(assignee: "DestructionListAssignee") -> None: assignee.assign() + def set_status(self, status: str) -> None: + self.status = status + self.status_changed = timezone.now() + self.save() + class DestructionListItem(models.Model): destruction_list = models.ForeignKey(