diff --git a/dref/serializers.py b/dref/serializers.py index e4ed03d96..22e765531 100644 --- a/dref/serializers.py +++ b/dref/serializers.py @@ -60,6 +60,7 @@ class ProposedActionSerializer(serializers.ModelSerializer): proposed_type_display = serializers.CharField(source="get_proposed_type_display", read_only=True) activity = serializers.PrimaryKeyRelatedField(queryset=Sector.objects.all(), required=True) + budget = serializers.IntegerField(required=True) class Meta: model = ProposedAction @@ -344,6 +345,7 @@ class Meta: class DrefSerializer(NestedUpdateMixin, NestedCreateMixin, ModelSerializer): + SUB_TOTAL = 75000 SURGE_DEPLOYMENT_COST = 10000 INDIRECT_COST_SURGE = 5800 INDIRECT_COST_NO_SURGE = 5000 @@ -471,6 +473,10 @@ def validate(self, data): ) if not sub_total: raise serializers.ValidationError({"sub_total": gettext("Sub-total is required for Imminent DREF")}) + if sub_total != self.SUB_TOTAL: + raise serializers.ValidationError( + {"sub_total": gettext("Sub-total should be equal to %s for Imminent DREF" % self.SUB_TOTAL)} + ) if is_surge_personnel_deployed and not surge_deployment_cost: raise serializers.ValidationError( {"surge_deployment_cost": gettext("Surge Deployment is required for Imminent DREF")} diff --git a/dref/test_views.py b/dref/test_views.py index 72f9cadae..ee1c13cae 100644 --- a/dref/test_views.py +++ b/dref/test_views.py @@ -1264,7 +1264,7 @@ def test_dref_imminent(self): title="health", ) national_society = Country.objects.create(name="abc") - disaster_type = DisasterType.objects.create(name="abc") + disaster_type = DisasterType.objects.create(name="disaster 1") data = { "title": "Dref test title", "type_of_onset": Dref.OnsetType.SUDDEN.value,