@@ -391,19 +391,21 @@ class Sector(models.IntegerChoices):
391391 ENVIRONMENT_SUSTAINABILITY = 111 , _ ("Environment Sustainability" )
392392 COMMUNITY_ENGAGEMENT_AND_ACCOUNTABILITY = 112 , _ ("Community Engagement And Accountability" )
393393
394- # NOTE: Use integer values directly in APCode rather than referencing `Sector` directly
395- class APCode (models .IntegerChoices ):
396- SHELTER_SETTLEMENT_AND_HOUSING = 101 , _ ("AP101, AP103, AP104" )
397- LIVELIHOODS = 102 , _ ("AP007" )
398- PROTECTION_GENDER_AND_INCLUSION = 103 , _ ("AP114, AP116, AP117" )
399- HEALTH_AND_CARE = 104 , _ ("AP107, AP108, AP109" )
400- RISK_REDUCTION_CLIMATE_ADAPTATION_AND_RECOVERY = 105 , _ ("AP101, AP103, AP104, AP105, AP106" )
401- MULTIPURPOSE_CASH = 106 , _ ("AP081" )
402- WATER_SANITATION_AND_HYGIENE = 107 , _ ("AP110, AP111" )
403- EDUCATION = 109 , _ ("AP115" )
404- MIGRATION = 110 , _ ("AP112, AP113" )
405- ENVIRONMENT_SUSTAINABILITY = 111 , _ ("AP102" )
406- COMMUNITY_ENGAGEMENT_AND_ACCOUNTABILITY = 112 , _ ("AP129" )
394+ @classmethod
395+ def get_sector_ap_codes (cls ) -> dict [int , list [str ]]:
396+ return {
397+ cls .SHELTER_SETTLEMENT_AND_HOUSING : ["AP101" , "AP103" , "AP104" ],
398+ cls .LIVELIHOODS : ["AP007" ],
399+ cls .PROTECTION_GENDER_AND_INCLUSION : ["AP114" , "AP116" , "AP117" ],
400+ cls .HEALTH_AND_CARE : ["AP107" , "AP108" , "AP109" ],
401+ cls .RISK_REDUCTION_CLIMATE_ADAPTATION_AND_RECOVERY : ["AP101" , "AP103" , "AP104" , "AP105" , "AP106" ],
402+ cls .MULTIPURPOSE_CASH : ["AP081" ],
403+ cls .WATER_SANITATION_AND_HYGIENE : ["AP110" , "AP111" ],
404+ cls .EDUCATION : ["AP115" ],
405+ cls .MIGRATION : ["AP112" , "AP113" ],
406+ cls .ENVIRONMENT_SUSTAINABILITY : ["AP102" ],
407+ cls .COMMUNITY_ENGAGEMENT_AND_ACCOUNTABILITY : ["AP129" ],
408+ }
407409
408410 sector = models .IntegerField (choices = Sector .choices , verbose_name = _ ("sector" ))
409411 people_targeted = models .IntegerField (verbose_name = _ ("People Targeted" ))
@@ -451,14 +453,21 @@ class Approach(models.IntegerChoices):
451453 NATIONAL_SOCIETY_STRENGTHENING = 20 , _ ("National Society Strengthening" )
452454 PARTNERSHIP_AND_COORDINATION = 30 , _ ("Partnership And Coordination" )
453455
454- # NOTE: AP Codes are read only in EAP forms and passed through ENUMS for now.
455- # They are not stored in the database but are derived from the Approach field. Make sure to keep them in sync.
456- class APCode (models .IntegerChoices ):
457- SECRETARIAT_SERVICES = 10 , _ ("AP122" )
458- NATIONAL_SOCIETY_STRENGTHENING = 20 , _ ("AP124, AP125, AP126" )
459- PARTNERSHIP_AND_COORDINATION = 30 , _ (
460- "AP049, AP118, AP119, AP120, AP121, AP127, AP128"
461- )
456+ @classmethod
457+ def get_approach_ap_codes (cls ) -> dict [int , list [str ]]:
458+ return {
459+ cls .SECRETARIAT_SERVICES : ["AP122" ],
460+ cls .NATIONAL_SOCIETY_STRENGTHENING : ["AP124" , "AP125" , "AP126" ],
461+ cls .PARTNERSHIP_AND_COORDINATION : [
462+ "AP049" ,
463+ "AP118" ,
464+ "AP119" ,
465+ "AP120" ,
466+ "AP121" ,
467+ "AP127" ,
468+ "AP128" ,
469+ ],
470+ }
462471
463472 approach = models .IntegerField (choices = Approach .choices , verbose_name = _ ("Approach" ))
464473 budget_per_approach = models .IntegerField (verbose_name = _ ("Budget per approach (CHF)" ))
0 commit comments