Skip to content

Commit ab94f0a

Browse files
Merge pull request #295 from OpenSPP/fix/mis-demo-v2-reland-76-compat
fix(spp_mis_demo_v2): adapt demo data to re-landed spp_demo/spp_gis_report schemas (#277, #280)
2 parents 9f7dd29 + 1caf794 commit ab94f0a

7 files changed

Lines changed: 89 additions & 18 deletions

File tree

spp_mis_demo_v2/README.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,14 @@ Dependencies
161161
Changelog
162162
=========
163163

164+
19.0.2.1.3
165+
~~~~~~~~~~
166+
167+
- fix: PHL story registrants map to the curated PSGC p-code area
168+
external IDs introduced by the re-landed spp_demo geodata
169+
(``STORY_AREA_MAP`` still referenced the removed named IDs, silently
170+
dropping area assignments).
171+
164172
19.0.2.1.2
165173
~~~~~~~~~~
166174

spp_mis_demo_v2/__manifest__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"name": "OpenSPP MIS Demo V2",
55
"summary": "Demo Generator V2 for SP-MIS programs with fixed stories and volume generation",
66
"category": "OpenSPP",
7-
"version": "19.0.2.1.2",
7+
"version": "19.0.2.1.3",
88
"sequence": 1,
99
"author": "OpenSPP.org",
1010
"website": "https://github.com/OpenSPP/OpenSPP2",
@@ -20,6 +20,8 @@
2020
"spp_demo",
2121
# GIS Reports for geographic visualization
2222
"spp_gis_report",
23+
# Demographic dimensions referenced by demo GIS report disaggregation
24+
"spp_metric_service",
2325
# Registrant GPS coordinates for QGIS plugin demo
2426
"spp_registrant_gis",
2527
# Indicators and analytics for demo indicators

spp_mis_demo_v2/models/mis_demo_generator.py

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4000,72 +4000,79 @@ def _load_geographic_data(self, stats):
40004000
# Keys: story_id -> {locale: area_xmlid}
40014001
STORY_AREA_MAP = {
40024002
"juan_dela_cruz": {
4003-
"fil_PH": "spp_demo.area_phl_calamba",
4003+
"fil_PH": "spp_demo.area_phl_ph0403405", # City of Calamba, Laguna
40044004
"fr_TG": "spp_demo.area_tgo_lome_tokoin",
40054005
"si_LK": "spp_demo.area_lka_moratuwa",
40064006
},
40074007
"maria_santos": {
4008-
"fil_PH": "spp_demo.area_phl_santa_rosa",
4008+
"fil_PH": "spp_demo.area_phl_ph0403428", # City of Santa Rosa, Laguna
40094009
"fr_TG": "spp_demo.area_tgo_aflao",
40104010
"si_LK": "spp_demo.area_lka_kolonnawa",
40114011
},
40124012
"jose_reyes_multigenerational": {
4013-
"fil_PH": "spp_demo.area_phl_san_pablo",
4013+
"fil_PH": "spp_demo.area_phl_ph0403424", # San Pablo City, Laguna
40144014
"fr_TG": "spp_demo.area_tgo_kpalime",
40154015
"si_LK": "spp_demo.area_lka_kandy_ds",
40164016
},
40174017
"ibrahim_hassan": {
4018-
"fil_PH": "spp_demo.area_phl_antipolo",
4018+
"fil_PH": "spp_demo.area_phl_ph0405802", # City of Antipolo, Rizal
40194019
"fr_TG": "spp_demo.area_tgo_sokode",
40204020
"si_LK": "spp_demo.area_lka_galle_ds",
40214021
},
40224022
"david_sofia_martinez": {
4023-
"fil_PH": "spp_demo.area_phl_makati",
4023+
"fil_PH": "spp_demo.area_phl_ph1307602", # City of Makati, NCR
40244024
"fr_TG": "spp_demo.area_tgo_lome",
40254025
"si_LK": "spp_demo.area_lka_dehiwala",
40264026
},
40274027
"rosa_garcia": {
4028-
"fil_PH": "spp_demo.area_phl_quezon_city",
4028+
"fil_PH": "spp_demo.area_phl_ph1307404", # Quezon City, NCR
40294029
"fr_TG": "spp_demo.area_tgo_lome_be",
40304030
"si_LK": "spp_demo.area_lka_colombo_fort",
40314031
},
40324032
"mary_johnson": {
4033-
"fil_PH": "spp_demo.area_phl_pasig",
4033+
"fil_PH": "spp_demo.area_phl_ph1307403", # City of Pasig, NCR
40344034
"fr_TG": "spp_demo.area_tgo_lome_nyekonakpoe",
40354035
"si_LK": "spp_demo.area_lka_colombo_pettah",
40364036
},
40374037
"ahmed_said": {
4038-
"fil_PH": "spp_demo.area_phl_taguig",
4038+
"fil_PH": "spp_demo.area_phl_ph1307607", # Taguig City, NCR
40394039
"fr_TG": "spp_demo.area_tgo_lome_adidogome",
40404040
"si_LK": "spp_demo.area_lka_dehiwala_gn",
40414041
},
40424042
"nguyen_extended_family": {
4043-
"fil_PH": "spp_demo.area_phl_bacoor",
4043+
# Bacoor is not in the curated PSGC dataset; Imus is the nearest available city in Cavite.
4044+
"fil_PH": "spp_demo.area_phl_ph0402109", # Imus City, Cavite
40444045
"fr_TG": "spp_demo.area_tgo_baguida_centre",
40454046
"si_LK": "spp_demo.area_lka_hikkaduwa",
40464047
},
40474048
"amina_osman_household": {
4048-
"fil_PH": "spp_demo.area_phl_manila",
4049+
"fil_PH": "spp_demo.area_phl_ph1303901", # City of Manila, NCR
40494050
"fr_TG": "spp_demo.area_tgo_kpalime_centre",
40504051
"si_LK": "spp_demo.area_lka_mount_lavinia_gn",
40514052
},
40524053
"carlos_elena_morales": {
4053-
"fil_PH": "spp_demo.area_phl_dasmarinas",
4054+
"fil_PH": "spp_demo.area_phl_ph0402106", # City of Dasmariñas, Cavite
40544055
"fr_TG": "spp_demo.area_tgo_kpalime_tove",
40554056
"si_LK": "spp_demo.area_lka_galle_fort",
40564057
},
40574058
"chen_large_family": {
4058-
"fil_PH": "spp_demo.area_phl_qc_commonwealth",
4059+
# Commonwealth barangay (Quezon City) is not in the municipality-level dataset;
4060+
# assigned a distinct NCR city to keep areas spread across the demo map.
4061+
"fil_PH": "spp_demo.area_phl_ph1307501", # Caloocan City, NCR
40594062
"fr_TG": "spp_demo.area_tgo_zio",
40604063
"si_LK": "spp_demo.area_lka_gampaha",
40614064
},
40624065
"grace_okonkwo": {
4063-
"fil_PH": "spp_demo.area_phl_makati_poblacion",
4066+
# Poblacion barangay (Makati) is not in the municipality-level dataset;
4067+
# assigned a distinct NCR city to keep areas spread across the demo map.
4068+
"fil_PH": "spp_demo.area_phl_ph1307603", # City of Muntinlupa, NCR
40644069
"fr_TG": "spp_demo.area_tgo_ogou",
40654070
"si_LK": "spp_demo.area_lka_kalutara",
40664071
},
40674072
"luis_fernandez": {
4068-
"fil_PH": "spp_demo.area_phl_calamba_real",
4073+
# Real barangay (Calamba) is not in the municipality-level dataset;
4074+
# assigned a distinct Laguna city to keep areas spread across the demo map.
4075+
"fil_PH": "spp_demo.area_phl_ph0403403", # City of Biñan, Laguna
40694076
"fr_TG": "spp_demo.area_tgo_lacs",
40704077
"si_LK": "spp_demo.area_lka_matara",
40714078
},

spp_mis_demo_v2/readme/HISTORY.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
### 19.0.2.1.3
2+
3+
- fix: PHL story registrants map to the curated PSGC p-code area external IDs introduced by the re-landed spp_demo geodata (`STORY_AREA_MAP` still referenced the removed named IDs, silently dropping area assignments).
4+
15
### 19.0.2.1.2
26

37
- fix: demo GIS reports use `dimension_ids` + `member_expansion` instead of the removed `disaggregate_by_*` boolean fields (ported from #295, credit @kneckinator; required in lockstep with the spp_gis_report dimension change).

spp_mis_demo_v2/static/description/index.html

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,15 @@ <h2><a class="toc-backref" href="#toc-entry-1">Changelog</a></h2>
531531
</div>
532532
</div>
533533
<div class="section" id="section-1">
534+
<h1>19.0.2.1.3</h1>
535+
<ul class="simple">
536+
<li>fix: PHL story registrants map to the curated PSGC p-code area
537+
external IDs introduced by the re-landed spp_demo geodata
538+
(<tt class="docutils literal">STORY_AREA_MAP</tt> still referenced the removed named IDs, silently
539+
dropping area assignments).</li>
540+
</ul>
541+
</div>
542+
<div class="section" id="section-2">
534543
<h1>19.0.2.1.2</h1>
535544
<ul class="simple">
536545
<li>fix: demo GIS reports use <tt class="docutils literal">dimension_ids</tt> + <tt class="docutils literal">member_expansion</tt>
@@ -539,15 +548,15 @@ <h1>19.0.2.1.2</h1>
539548
spp_gis_report dimension change).</li>
540549
</ul>
541550
</div>
542-
<div class="section" id="section-2">
551+
<div class="section" id="section-3">
543552
<h1>19.0.2.1.1</h1>
544553
<ul class="simple">
545554
<li>feat(demo): adapt the change-request demo generator to the redesigned
546555
CR flows — Add Member selects an existing individual (#871) and Change
547556
Head of Household uses per-member role lines (#873) (#242)</li>
548557
</ul>
549558
</div>
550-
<div class="section" id="section-3">
559+
<div class="section" id="section-4">
551560
<h1>19.0.2.1.0</h1>
552561
<ul class="simple">
553562
<li>feat(demo): seed country-appropriate CR document types (≥5 per country
@@ -556,7 +565,7 @@ <h1>19.0.2.1.0</h1>
556565
files to a change request without defining them manually (#1102)</li>
557566
</ul>
558567
</div>
559-
<div class="section" id="section-4">
568+
<div class="section" id="section-5">
560569
<h1>19.0.2.0.0</h1>
561570
<ul class="simple">
562571
<li>Initial migration to OpenSPP2</li>

spp_mis_demo_v2/tests/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@
1111
from . import test_mis_demo_generator
1212
from . import test_registry_variables
1313
from . import test_demo_statistics
14+
from . import test_story_area_map
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Part of OpenSPP. See LICENSE file for full copyright and licensing details.
2+
from odoo.tests.common import TransactionCase
3+
4+
5+
class TestStoryAreaMapIntegrity(TransactionCase):
6+
"""Every STORY_AREA_MAP external ID must resolve once its country's areas load.
7+
8+
The map is consumed with ``raise_if_not_found=False``, so a renamed area
9+
external ID silently drops story area assignments instead of failing (this
10+
regressed once, when the PHL areas moved to curated PSGC p-codes). This
11+
guard turns any future rename into a loud test failure.
12+
"""
13+
14+
_LOCALE_COUNTRY = {"fil_PH": "phl", "fr_TG": "tgo", "si_LK": "lka"}
15+
16+
def test_all_story_area_xmlids_resolve(self):
17+
generator_model = self.env["spp.mis.demo.generator"]
18+
loader = self.env["spp.demo.area.loader"]
19+
for country in sorted(set(self._LOCALE_COUNTRY.values())):
20+
loader.load_country_areas(country, load_shapes=False)
21+
22+
missing = []
23+
unknown_locales = []
24+
for story_id, locales in generator_model.STORY_AREA_MAP.items():
25+
for locale, xmlid in locales.items():
26+
if locale not in self._LOCALE_COUNTRY:
27+
unknown_locales.append((story_id, locale))
28+
continue
29+
if not self.env.ref(xmlid, raise_if_not_found=False):
30+
missing.append((story_id, locale, xmlid))
31+
32+
self.assertFalse(
33+
unknown_locales,
34+
f"STORY_AREA_MAP locales without a country mapping in this test: {unknown_locales}",
35+
)
36+
self.assertFalse(
37+
missing,
38+
"STORY_AREA_MAP references unresolvable area external IDs "
39+
f"(story registrants would silently lose their area): {missing}",
40+
)

0 commit comments

Comments
 (0)