Skip to content

Commit

Permalink
feat: add lqas, im fields to SubActivity model
Browse files Browse the repository at this point in the history
  • Loading branch information
quang-le authored Jan 7, 2025
2 parents 282cc6c + e031972 commit a03a99c
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 0 deletions.
4 changes: 4 additions & 0 deletions plugins/polio/api/campaigns/subactivities.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
Original file line number Diff line number Diff line change
@@ -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),
),
]
4 changes: 4 additions & 0 deletions plugins/polio/models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
8 changes: 8 additions & 0 deletions plugins/polio/tests/test_subactivities.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit a03a99c

Please sign in to comment.