diff --git a/plugins/polio/api/campaigns/subactivities.py b/plugins/polio/api/campaigns/subactivities.py index 4b80e42317..ec13175cd7 100644 --- a/plugins/polio/api/campaigns/subactivities.py +++ b/plugins/polio/api/campaigns/subactivities.py @@ -34,6 +34,10 @@ class Meta: "age_unit", "age_min", "age_max", + "lqas_ended_at", + "lqas_started_at", + "im_ended_at", + "im_started_at", ] def create(self, validated_data): diff --git a/plugins/polio/migrations/0209_subactivity_im_ended_at_subactivity_im_started_at_and_more.py b/plugins/polio/migrations/0209_subactivity_im_ended_at_subactivity_im_started_at_and_more.py new file mode 100644 index 0000000000..4938de7de9 --- /dev/null +++ b/plugins/polio/migrations/0209_subactivity_im_ended_at_subactivity_im_started_at_and_more.py @@ -0,0 +1,32 @@ +# Generated by Django 4.2.17 on 2024-12-11 14:19 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ("polio", "0208_migrate_vrf_orpg_fields"), + ] + + operations = [ + migrations.AddField( + model_name="subactivity", + name="im_ended_at", + field=models.DateField(blank=True, null=True), + ), + migrations.AddField( + model_name="subactivity", + name="im_started_at", + field=models.DateField(blank=True, null=True), + ), + migrations.AddField( + model_name="subactivity", + name="lqas_ended_at", + field=models.DateField(blank=True, null=True), + ), + migrations.AddField( + model_name="subactivity", + name="lqas_started_at", + field=models.DateField(blank=True, null=True), + ), + ] diff --git a/plugins/polio/models/base.py b/plugins/polio/models/base.py index 6ab4d5c94c..d3bfb3c833 100644 --- a/plugins/polio/models/base.py +++ b/plugins/polio/models/base.py @@ -288,6 +288,10 @@ class SubActivity(models.Model): age_max = models.IntegerField(null=True, blank=True) start_date = models.DateField(null=True, blank=True) end_date = models.DateField(null=True, blank=True) + im_started_at = models.DateField(null=True, blank=True) + im_ended_at = models.DateField(null=True, blank=True) + lqas_started_at = models.DateField(null=True, blank=True) + lqas_ended_at = models.DateField(null=True, blank=True) class Meta: verbose_name_plural = "subactivities" diff --git a/plugins/polio/tests/test_subactivities.py b/plugins/polio/tests/test_subactivities.py index 5226b9c885..fc5c713aa2 100644 --- a/plugins/polio/tests/test_subactivities.py +++ b/plugins/polio/tests/test_subactivities.py @@ -90,12 +90,20 @@ def test_update_sub_activity(self): "name": "Updated SubActivity", "start_date": "2022-03-01", "end_date": "2022-03-31", + "im_started_at": "2022-04-30", + "im_ended_at": "2022-05-01", + "lqas_started_at": "2022-04-29", + "lqas_ended_at": "2022-05-02", "scopes": [{"group": {"name": "Updated Group", "org_units": [self.org_unit.id]}, "vaccine": "mOPV2"}], } self.client.force_authenticate(self.user) response = self.client.put(BASE_URL + str(self.sub_activity.id) + "/", data, format="json") self.assertEqual(response.status_code, 200) self.assertEqual(SubActivity.objects.get(id=self.sub_activity.id).name, "Updated SubActivity") + self.assertEqual(SubActivity.objects.get(id=self.sub_activity.id).im_started_at, datetime.date(2022, 4, 30)) + self.assertEqual(SubActivity.objects.get(id=self.sub_activity.id).im_ended_at, datetime.date(2022, 5, 1)) + self.assertEqual(SubActivity.objects.get(id=self.sub_activity.id).lqas_started_at, datetime.date(2022, 4, 29)) + self.assertEqual(SubActivity.objects.get(id=self.sub_activity.id).lqas_ended_at, datetime.date(2022, 5, 2)) def test_anonymous_user_cannot_delete_sub_activity(self): self.client.force_authenticate(self.anon)