Skip to content

Commit 798960e

Browse files
authored
Merge pull request #2692 from IFRCGo/project/surge-eru-update
2 parents 312eb99 + 00864f4 commit 798960e

10 files changed

Lines changed: 82 additions & 1 deletion

File tree

api/filter_set.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,17 @@ class AppealHistoryFilter(filters.FilterSet):
284284
label="admin2",
285285
method="get_country_admin2",
286286
)
287+
needs_confirmation = filters.BooleanFilter(
288+
field_name="needs_confirmation",
289+
label="needs_confirmation",
290+
lookup_expr="exact",
291+
)
292+
has_event = filters.BooleanFilter(
293+
field_name="appeal__event",
294+
lookup_expr="isnull",
295+
label="has_event",
296+
exclude=True,
297+
)
287298

288299
class Meta:
289300
model = AppealHistory

api/serializers.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1610,10 +1610,26 @@ class Meta:
16101610
)
16111611

16121612

1613+
class EventDetailsSerializer(ModelSerializer):
1614+
ifrc_severity_level_display = serializers.CharField(source="get_ifrc_severity_level_display", read_only=True)
1615+
1616+
class Meta:
1617+
model = Event
1618+
fields = (
1619+
"id",
1620+
"name",
1621+
"ifrc_severity_level",
1622+
"ifrc_severity_level_display",
1623+
"ifrc_severity_level_update_date",
1624+
"updated_at",
1625+
)
1626+
1627+
16131628
class AppealHistorySerializer(ModelSerializer):
16141629
country = MiniCountrySerializer(read_only=True)
16151630
dtype = DisasterTypeSerializer(read_only=True)
16161631
region = RegionSerializer(read_only=True)
1632+
event_details = EventDetailsSerializer(source="appeal.event", read_only=True)
16171633
atype_display = serializers.CharField(source="get_atype_display", read_only=True)
16181634
status_display = serializers.CharField(source="get_status_display", read_only=True)
16191635
code = serializers.CharField(source="appeal.code", read_only=True)
@@ -1650,6 +1666,7 @@ class Meta:
16501666
"country",
16511667
"region",
16521668
"id",
1669+
"event_details",
16531670
)
16541671

16551672

assets

deployments/drf_views.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,6 +1021,7 @@ class ERUReadinessFilter(filters.FilterSet):
10211021
eru_owner = filters.NumberFilter(field_name="eru_owner", lookup_expr="exact")
10221022
eru_type = filters.NumberFilter(field_name="eru_types__type", lookup_expr="exact")
10231023
eru_type__in = ListFilter(field_name="eru_types__type")
1024+
ns_contribution = filters.NumberFilter(field_name="eru_types__ns_contribution", lookup_expr="exact")
10241025

10251026

10261027
class ERUReadinessViewSet(RevisionMixin, viewsets.ModelViewSet):

deployments/enums.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@
1111
"emergency_project_status": models.EmergencyProject.ActivityStatus,
1212
"emergency_project_activity_people_households": models.EmergencyProjectActivity.PeopleHouseholds,
1313
"eru_readiness_status": models.ERUReadinessType.ReadinessStatus,
14+
"eru_readiness_ns_contribution": models.ERUReadinessType.NationalSocietyContribution,
1415
}

deployments/factories/emergency_project.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,3 +116,4 @@ class Meta:
116116
people_readiness = fuzzy.FuzzyChoice(ERUReadinessType.ReadinessStatus)
117117
funding_readiness = fuzzy.FuzzyChoice(ERUReadinessType.ReadinessStatus)
118118
comment = fuzzy.FuzzyText(length=10, prefix="comment-")
119+
ns_contribution = fuzzy.FuzzyChoice(ERUReadinessType.NationalSocietyContribution)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Generated by Django 4.2.29 on 2026-03-18 05:13
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('deployments', '0093_sector_title_ar_sector_title_en_sector_title_es_and_more'),
10+
]
11+
12+
operations = [
13+
migrations.AddField(
14+
model_name='erureadinesstype',
15+
name='ns_contribution',
16+
field=models.IntegerField(choices=[(1, 'Confirm that you have the capacity to hold this type of ERU'), (2, 'Confirm that you have the capacity to support this type of ERU')], default=1, verbose_name='National Society Contribution'),
17+
preserve_default=False,
18+
),
19+
]

deployments/models.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -927,6 +927,18 @@ class ReadinessStatus(models.IntegerChoices):
927927
PARTIAL_CAPACITY = 2, _("Partial capacity")
928928
NO_CAPACITY = 3, _("No capacity")
929929

930+
class NationalSocietyContribution(models.IntegerChoices):
931+
"""
932+
Note:The enum values are intentionally written in a longer form so the frontend design and
933+
labels can directly use and reflect them.
934+
"""
935+
936+
HOLDS = 1, _("Confirm that you have the capacity to hold this type of ERU")
937+
"""The National Society owns and maintains the ERU and is responsible for its readiness."""
938+
939+
SUPPORTS = 2, _("Confirm that you have the capacity to support this type of ERU")
940+
"""The National Society provides support to the ERU but does not hold it."""
941+
930942
type = models.IntegerField(choices=ERUType.choices, verbose_name=_("ERU type"))
931943
equipment_readiness = models.IntegerField(
932944
choices=ReadinessStatus.choices,
@@ -941,6 +953,10 @@ class ReadinessStatus(models.IntegerChoices):
941953
verbose_name=_("funding readiness"),
942954
)
943955
comment = models.TextField(verbose_name=_("comment"), blank=True, null=True)
956+
ns_contribution = models.IntegerField(
957+
choices=NationalSocietyContribution.choices,
958+
verbose_name=_("National Society Contribution"),
959+
)
944960

945961
class Meta:
946962
verbose_name = _("ERU Readiness Type")

deployments/serializers.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1056,6 +1056,7 @@ class ERUReadinessTypeSerializer(serializers.ModelSerializer):
10561056
equipment_readiness_display = serializers.CharField(source="get_equipment_readiness_display", read_only=True)
10571057
people_readiness_display = serializers.CharField(source="get_people_readiness_display", read_only=True)
10581058
funding_readiness_display = serializers.CharField(source="get_funding_readiness_display", read_only=True)
1059+
ns_contribution_display = serializers.CharField(source="get_ns_contribution_display", read_only=True)
10591060

10601061
class Meta:
10611062
model = ERUReadinessType

deployments/tests.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,7 @@ def test_eru_readiness_list(self):
491491
"equipment_readiness": ERUReadinessType.ReadinessStatus.READY,
492492
"people_readiness": ERUReadinessType.ReadinessStatus.READY,
493493
"funding_readiness": ERUReadinessType.ReadinessStatus.READY,
494+
"ns_contribution": ERUReadinessType.NationalSocietyContribution.HOLDS,
494495
}
495496
eru_readiness_type_1, eru_readiness_type_2 = ERUReadinessTypeFactory.create_batch(
496497
2,
@@ -531,6 +532,7 @@ def test_eru_readiness_create(self):
531532
"equipment_readiness": ERUReadinessType.ReadinessStatus.READY,
532533
"people_readiness": ERUReadinessType.ReadinessStatus.READY,
533534
"funding_readiness": ERUReadinessType.ReadinessStatus.READY,
535+
"ns_contribution": ERUReadinessType.NationalSocietyContribution.SUPPORTS,
534536
}
535537
eru_readiness_type_1 = ERUReadinessTypeFactory.create(
536538
type=ERUType.OSH,
@@ -549,12 +551,14 @@ def test_eru_readiness_create(self):
549551
"equipment_readiness": eru_readiness_type_1.equipment_readiness,
550552
"people_readiness": eru_readiness_type_1.people_readiness,
551553
"funding_readiness": eru_readiness_type_1.funding_readiness,
554+
"ns_contribution": eru_readiness_type_1.ns_contribution,
552555
},
553556
{
554557
"type": eru_readiness_type_2.type,
555558
"equipment_readiness": eru_readiness_type_2.equipment_readiness,
556559
"people_readiness": eru_readiness_type_2.people_readiness,
557560
"funding_readiness": eru_readiness_type_2.funding_readiness,
561+
"ns_contribution": eru_readiness_type_2.ns_contribution,
558562
},
559563
],
560564
}
@@ -571,6 +575,7 @@ def test_eru_readiness_update(self):
571575
"equipment_readiness": ERUReadinessType.ReadinessStatus.READY,
572576
"people_readiness": ERUReadinessType.ReadinessStatus.READY,
573577
"funding_readiness": ERUReadinessType.ReadinessStatus.READY,
578+
"ns_contribution": ERUReadinessType.NationalSocietyContribution.HOLDS,
574579
}
575580
eru_readiness_type_1 = ERUReadinessTypeFactory.create(
576581
type=ERUType.OSH,
@@ -598,20 +603,23 @@ def test_eru_readiness_update(self):
598603
"equipment_readiness": ERUReadinessType.ReadinessStatus.NO_CAPACITY,
599604
"people_readiness": ERUReadinessType.ReadinessStatus.NO_CAPACITY,
600605
"funding_readiness": ERUReadinessType.ReadinessStatus.NO_CAPACITY,
606+
"ns_contribution": ERUReadinessType.NationalSocietyContribution.SUPPORTS,
601607
},
602608
{
603609
"id": eru_readiness_type_2.id,
604610
"type": eru_readiness_type_2.type,
605611
"equipment_readiness": ERUReadinessType.ReadinessStatus.READY,
606612
"people_readiness": ERUReadinessType.ReadinessStatus.READY,
607613
"funding_readiness": ERUReadinessType.ReadinessStatus.READY,
614+
"ns_contribution": ERUReadinessType.NationalSocietyContribution.SUPPORTS,
608615
},
609616
# Add new ERU type
610617
{
611618
"type": ERUType.MHPSS,
612619
"equipment_readiness": ERUReadinessType.ReadinessStatus.PARTIAL_CAPACITY,
613620
"people_readiness": ERUReadinessType.ReadinessStatus.PARTIAL_CAPACITY,
614621
"funding_readiness": ERUReadinessType.ReadinessStatus.PARTIAL_CAPACITY,
622+
"ns_contribution": ERUReadinessType.NationalSocietyContribution.HOLDS,
615623
},
616624
],
617625
}
@@ -640,23 +648,29 @@ def test_eru_readiness_update(self):
640648
response.data["eru_types"][0]["equipment_readiness"],
641649
response.data["eru_types"][0]["people_readiness"],
642650
response.data["eru_types"][0]["funding_readiness"],
651+
response.data["eru_types"][0]["ns_contribution"],
643652
response.data["eru_types"][1]["equipment_readiness"],
644653
response.data["eru_types"][1]["people_readiness"],
645654
response.data["eru_types"][1]["funding_readiness"],
655+
response.data["eru_types"][1]["ns_contribution"],
646656
response.data["eru_types"][2]["equipment_readiness"],
647657
response.data["eru_types"][2]["people_readiness"],
648658
response.data["eru_types"][2]["funding_readiness"],
659+
response.data["eru_types"][2]["ns_contribution"],
649660
},
650661
{
651662
ERUReadinessType.ReadinessStatus.NO_CAPACITY,
652663
ERUReadinessType.ReadinessStatus.NO_CAPACITY,
653664
ERUReadinessType.ReadinessStatus.NO_CAPACITY,
665+
ERUReadinessType.NationalSocietyContribution.SUPPORTS,
654666
ERUReadinessType.ReadinessStatus.READY,
655667
ERUReadinessType.ReadinessStatus.READY,
656668
ERUReadinessType.ReadinessStatus.READY,
669+
ERUReadinessType.NationalSocietyContribution.SUPPORTS,
657670
ERUReadinessType.ReadinessStatus.PARTIAL_CAPACITY,
658671
ERUReadinessType.ReadinessStatus.PARTIAL_CAPACITY,
659672
ERUReadinessType.ReadinessStatus.PARTIAL_CAPACITY,
673+
ERUReadinessType.NationalSocietyContribution.HOLDS,
660674
},
661675
)
662676

0 commit comments

Comments
 (0)