From ce085394d038662bec1a71887c992a632abc8bcf Mon Sep 17 00:00:00 2001 From: Domenico DiNicola Date: Wed, 6 Nov 2024 11:55:38 +0100 Subject: [PATCH 1/2] generic-import-admin-area-fix --- .../services/generic_registration_service.py | 21 +++---------------- 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/src/hct_mis_api/contrib/aurora/services/generic_registration_service.py b/src/hct_mis_api/contrib/aurora/services/generic_registration_service.py index e32cb53369..c2acbd85a7 100644 --- a/src/hct_mis_api/contrib/aurora/services/generic_registration_service.py +++ b/src/hct_mis_api/contrib/aurora/services/generic_registration_service.py @@ -115,24 +115,9 @@ def _create_household_dict(cls, data_dict: Dict, mapping_dict: Dict) -> Dict: my_dict.update(cls._create_household_dict(data_dict[key], mapping_dict[key])) # update admin areas values - admin2 = cls.get(data_dict, "admin2_h_c") - admin3 = cls.get(data_dict, "admin3_h_c") - admin4 = cls.get(data_dict, "admin4_h_c") - - my_dict["admin2"] = str(Area.objects.get(p_code=admin2).id) if admin2 else None - my_dict["admin3"] = str(Area.objects.get(p_code=admin3).id) if admin3 else None - my_dict["admin4"] = str(Area.objects.get(p_code=admin4).id) if admin4 else None - - if admin2 and Area.objects.filter(p_code=admin2).exists(): - my_dict["admin1"] = str(Area.objects.get(p_code=admin2).parent.id) - - if admin4 and Area.objects.filter(p_code=admin4).exists(): - my_dict["admin_area"] = str(Area.objects.get(p_code=admin4).id) - elif admin3 and Area.objects.filter(p_code=admin3).exists(): - my_dict["admin_area"] = str(Area.objects.get(p_code=admin3).id) - elif admin2 and Area.objects.filter(p_code=admin2).exists(): - my_dict["admin_area"] = str(Area.objects.get(p_code=admin2).id) - + for key in ["admin1", "admin2", "admin3", "admin4"]: + if key in my_dict and Area.objects.filter(p_code=my_dict[key]).exists(): + my_dict[key] = str(Area.objects.get(p_code=my_dict[key]).id) return my_dict @staticmethod From 723c3c19d27e3b5f904ec7d545427eadb3684d06 Mon Sep 17 00:00:00 2001 From: Domenico DiNicola Date: Wed, 6 Nov 2024 11:56:43 +0100 Subject: [PATCH 2/2] generic-import-admin-area-fix --- src/frontend/package.json | 2 +- .../contrib/aurora/services/generic_registration_service.py | 1 + .../registration_datahub/test_generic_registration_service.py | 2 -- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/frontend/package.json b/src/frontend/package.json index c5e62b840d..f47e5fe04c 100644 --- a/src/frontend/package.json +++ b/src/frontend/package.json @@ -1,6 +1,6 @@ { "name": "frontend", - "version": "2.12.1", + "version": "2.12.3", "private": true, "type": "module", "scripts": { diff --git a/src/hct_mis_api/contrib/aurora/services/generic_registration_service.py b/src/hct_mis_api/contrib/aurora/services/generic_registration_service.py index c2acbd85a7..9549e40f71 100644 --- a/src/hct_mis_api/contrib/aurora/services/generic_registration_service.py +++ b/src/hct_mis_api/contrib/aurora/services/generic_registration_service.py @@ -216,6 +216,7 @@ def create_individuals( program=household.program, first_registration_date=record.timestamp, last_registration_date=record.timestamp, + detail_id=record.source_id, ) record_data_dict = record.get_data() diff --git a/tests/unit/apps/registration_datahub/test_generic_registration_service.py b/tests/unit/apps/registration_datahub/test_generic_registration_service.py index cd9bd3127d..25eb77a20f 100644 --- a/tests/unit/apps/registration_datahub/test_generic_registration_service.py +++ b/tests/unit/apps/registration_datahub/test_generic_registration_service.py @@ -257,8 +257,6 @@ def test_import_data_to_datahub( self.assertEqual(PendingIndividualRoleInHousehold.objects.filter(role=ROLE_PRIMARY).count(), 1) self.assertEqual(PendingIndividualRoleInHousehold.objects.filter(role=ROLE_ALTERNATE).count(), 1) - self.assertEqual(pending_household.admin_area.p_code, self.household[0][admin_area_field]) - def test_import_data_to_datahub_household_individual(self) -> None: records = [ Record(