@@ -345,41 +345,6 @@ class Meta:
345345 ]
346346
347347
348- # @TODO Decide whether to change the name of this model when we review the
349- # LIAS and finalize models for expandability and coping. Ideally we want to be
350- # able to identify Livelihood Activities that are produce staple foods, and/or
351- # are part of the different baskets.
352- class LivelihoodProductCategory (common_models .Model ):
353- """
354- The usage category of the Product in the Livelihood Zone, such as staple food or livelihood protection.
355- """
356-
357- class ProductBasket (models .IntegerChoices ):
358- MAIN_STAPLE = 1 , _ ("Main Staple" )
359- OTHER_STAPLE = 2 , _ ("Other Staple" )
360- SURVIVAL_NON_FOOD = 3 , _ ("Non-food survival" )
361- LIVELIHOODS_PROTECTION = 4 , _ ("Livelihoods Protection" )
362-
363- livelihood_zone_baseline = models .ForeignKey (
364- LivelihoodZoneBaseline ,
365- on_delete = models .RESTRICT ,
366- related_name = "staple_foods" ,
367- verbose_name = _ ("Livelihood Zone Baseline" ),
368- )
369- product = models .ForeignKey (
370- ClassifiedProduct ,
371- db_column = "product_code" ,
372- on_delete = models .RESTRICT ,
373- related_name = "staple_foods" ,
374- verbose_name = _ ("Product" ),
375- )
376- basket = models .PositiveSmallIntegerField (choices = ProductBasket .choices , verbose_name = _ ("Product Basket" ))
377-
378- class Meta :
379- verbose_name = _ ("Livelihood Product Category" )
380- verbose_name_plural = _ ("Livelihood Product Categories" )
381-
382-
383348class CommunityManager (common_models .IdentifierManager ):
384349 def get_by_natural_key (self , code : str , reference_year_end_date : str , full_name : str ):
385350 try :
@@ -1400,6 +1365,52 @@ class Meta:
14001365 proxy = True
14011366
14021367
1368+ # @TODO Decide whether to change the name of this model when we review the
1369+ # LIAS and finalize models for expandability and coping. Ideally we want to be
1370+ # able to identify Livelihood Activities that are produce staple foods, and/or
1371+ # are part of the different baskets.
1372+ class LivelihoodProductCategory (common_models .Model ):
1373+ """
1374+ The usage category of the Product in the Livelihood Zone, such as staple food or livelihood protection.
1375+ """
1376+
1377+ class ProductBasket (models .IntegerChoices ):
1378+ MAIN_STAPLE = 1 , _ ("Main Staple" )
1379+ OTHER_STAPLE = 2 , _ ("Other Staple" )
1380+ SURVIVAL_NON_FOOD = 3 , _ ("Non-food survival" )
1381+ LIVELIHOODS_PROTECTION = 4 , _ ("Livelihoods Protection" )
1382+
1383+ baseline_livelihood_activity = models .ForeignKey (
1384+ BaselineLivelihoodActivity ,
1385+ on_delete = models .RESTRICT ,
1386+ verbose_name = _ ("Baseline Livelihood Activity" ),
1387+ )
1388+ basket = models .PositiveSmallIntegerField (choices = ProductBasket .choices , verbose_name = _ ("Product Basket" ))
1389+ percentage_allocation_to_basket = models .PositiveIntegerField (
1390+ blank = True ,
1391+ null = True ,
1392+ verbose_name = _ ("Percentage allocation to basket" ),
1393+ help_text = _ (
1394+ "The percentage of expenditure or kcals from the Livelihood Activity that is allocated to this Basket. The remainder is implicitly part of the 'Other' basket"
1395+ ),
1396+ )
1397+
1398+ def clean (self ):
1399+ super ().clean ()
1400+ if self .percentage_allocation_to_basket and self .percentage_allocation_to_basket > 100 :
1401+ raise ValidationError (
1402+ {
1403+ "percentage_allocation_to_basket" : _ (
1404+ f"Percentage allocation cannot exceed 100%. Got: { self .percentage_allocation_to_basket } %"
1405+ )
1406+ }
1407+ )
1408+
1409+ class Meta :
1410+ verbose_name = _ ("Livelihood Product Category" )
1411+ verbose_name_plural = _ ("Livelihood Product Categories" )
1412+
1413+
14031414class MilkProduction (LivelihoodActivity ):
14041415 """
14051416 Production of milk by households in a Wealth Group for their own consumption, for sale and for other uses.
0 commit comments