Skip to content

Commit 6944ec2

Browse files
committed
chore(fulleap): Remove fields from fulleap model (#2614)
1 parent cc5a111 commit 6944ec2

5 files changed

Lines changed: 201 additions & 35 deletions

File tree

eap/factories.py

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ class Meta:
4949

5050
status = fuzzy.FuzzyChoice(EAPStatus)
5151
eap_type = fuzzy.FuzzyChoice(EAPType)
52+
national_society_contact_name = fuzzy.FuzzyText(length=10, prefix="NS-")
53+
national_society_contact_email = factory.LazyAttribute(lambda obj: f"{obj.national_society_contact_name.lower()}@example.com")
5254

5355
@factory.post_generation
5456
def partners(self, create, extracted, **kwargs):
@@ -73,6 +75,14 @@ class Meta:
7375
seap_lead_timeframe_unit = fuzzy.FuzzyInteger(TimeFrame.MONTHS)
7476
seap_lead_time = fuzzy.FuzzyInteger(1, 12)
7577
operational_timeframe = fuzzy.FuzzyInteger(1, 12)
78+
national_society_contact_name = fuzzy.FuzzyText(length=10, prefix="NS-")
79+
national_society_contact_email = factory.LazyAttribute(lambda obj: f"{obj.national_society_contact_name.lower()}@example.com")
80+
ifrc_delegation_focal_point_name = fuzzy.FuzzyText(length=10, prefix="IFRC-")
81+
ifrc_delegation_focal_point_email = factory.LazyAttribute(
82+
lambda obj: f"{obj.ifrc_delegation_focal_point_name.lower()}@example.com"
83+
)
84+
ifrc_head_of_delegation_name = fuzzy.FuzzyText(length=10, prefix="ifrc-head-")
85+
ifrc_head_of_delegation_email = factory.LazyAttribute(lambda obj: f"{obj.ifrc_head_of_delegation_name.lower()}@example.com")
7686

7787
@factory.post_generation
7888
def enable_approaches(self, create, extracted, **kwargs):
@@ -185,11 +195,27 @@ class FullEAPFactory(factory.django.DjangoModelFactory):
185195
class Meta:
186196
model = FullEAP
187197

188-
seap_timeframe = fuzzy.FuzzyInteger(5)
189198
expected_submission_time = fuzzy.FuzzyDateTime(datetime(2025, 1, 1, tzinfo=pytz.utc))
190199
lead_time = fuzzy.FuzzyInteger(1, 100)
191200
total_budget = fuzzy.FuzzyInteger(1000, 1000000)
192201
readiness_budget = fuzzy.FuzzyInteger(1000, 1000000)
193202
pre_positioning_budget = fuzzy.FuzzyInteger(1000, 1000000)
194203
early_action_budget = fuzzy.FuzzyInteger(1000, 1000000)
195204
people_targeted = fuzzy.FuzzyInteger(100, 100000)
205+
national_society_contact_name = fuzzy.FuzzyText(length=10, prefix="NS-")
206+
national_society_contact_email = factory.LazyAttribute(lambda obj: f"{obj.national_society_contact_name.lower()}@example.com")
207+
ifrc_delegation_focal_point_name = fuzzy.FuzzyText(length=10, prefix="IFRC-")
208+
ifrc_delegation_focal_point_email = factory.LazyAttribute(
209+
lambda obj: f"{obj.ifrc_delegation_focal_point_name.lower()}@example.com"
210+
)
211+
ifrc_head_of_delegation_name = fuzzy.FuzzyText(length=10, prefix="ifrc-head-")
212+
ifrc_head_of_delegation_email = factory.LazyAttribute(lambda obj: f"{obj.ifrc_head_of_delegation_name.lower()}@example.com")
213+
214+
@factory.post_generation
215+
def key_actors(self, create, extracted, **kwargs):
216+
if not create:
217+
return
218+
219+
if extracted:
220+
for actor in extracted:
221+
self.key_actors.add(actor)
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
# Generated by Django 4.2.26 on 2025-12-19 04:02
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
dependencies = [
8+
("eap", "0011_alter_fulleap_updated_checklist_file_and_more"),
9+
]
10+
11+
operations = [
12+
migrations.RemoveField(
13+
model_name="fulleap",
14+
name="seap_timeframe",
15+
),
16+
migrations.RemoveField(
17+
model_name="fulleap",
18+
name="selection_area",
19+
),
20+
migrations.AlterField(
21+
model_name="fulleap",
22+
name="ifrc_delegation_focal_point_email",
23+
field=models.CharField(
24+
default="test@gmail.com",
25+
max_length=255,
26+
verbose_name="IFRC delegation focal point email",
27+
),
28+
preserve_default=False,
29+
),
30+
migrations.AlterField(
31+
model_name="fulleap",
32+
name="ifrc_delegation_focal_point_name",
33+
field=models.CharField(
34+
default="test",
35+
max_length=255,
36+
verbose_name="IFRC delegation focal point name",
37+
),
38+
preserve_default=False,
39+
),
40+
migrations.AlterField(
41+
model_name="fulleap",
42+
name="ifrc_head_of_delegation_email",
43+
field=models.CharField(
44+
default="test@gmail.com",
45+
max_length=255,
46+
verbose_name="IFRC head of delegation email",
47+
),
48+
preserve_default=False,
49+
),
50+
migrations.AlterField(
51+
model_name="fulleap",
52+
name="ifrc_head_of_delegation_name",
53+
field=models.CharField(
54+
default="test",
55+
max_length=255,
56+
verbose_name="IFRC head of delegation name",
57+
),
58+
preserve_default=False,
59+
),
60+
migrations.AlterField(
61+
model_name="fulleap",
62+
name="national_society_contact_email",
63+
field=models.CharField(
64+
default="test@gmail.com",
65+
max_length=255,
66+
verbose_name="national society contact email",
67+
),
68+
preserve_default=False,
69+
),
70+
migrations.AlterField(
71+
model_name="fulleap",
72+
name="national_society_contact_name",
73+
field=models.CharField(
74+
default="test",
75+
max_length=255,
76+
verbose_name="national society contact name",
77+
),
78+
preserve_default=False,
79+
),
80+
migrations.AlterField(
81+
model_name="simplifiedeap",
82+
name="ifrc_delegation_focal_point_email",
83+
field=models.CharField(
84+
default="test@gmail.com",
85+
max_length=255,
86+
verbose_name="IFRC delegation focal point email",
87+
),
88+
preserve_default=False,
89+
),
90+
migrations.AlterField(
91+
model_name="simplifiedeap",
92+
name="ifrc_delegation_focal_point_name",
93+
field=models.CharField(
94+
default="test",
95+
max_length=255,
96+
verbose_name="IFRC delegation focal point name",
97+
),
98+
preserve_default=False,
99+
),
100+
migrations.AlterField(
101+
model_name="simplifiedeap",
102+
name="ifrc_head_of_delegation_email",
103+
field=models.CharField(
104+
default="test@gmail.com",
105+
max_length=255,
106+
verbose_name="IFRC head of delegation email",
107+
),
108+
preserve_default=False,
109+
),
110+
migrations.AlterField(
111+
model_name="simplifiedeap",
112+
name="ifrc_head_of_delegation_name",
113+
field=models.CharField(
114+
default="test",
115+
max_length=255,
116+
verbose_name="IFRC head of delegation name",
117+
),
118+
preserve_default=False,
119+
),
120+
migrations.AlterField(
121+
model_name="simplifiedeap",
122+
name="national_society_contact_email",
123+
field=models.CharField(
124+
default="test@gmail.com",
125+
max_length=255,
126+
verbose_name="national society contact email",
127+
),
128+
preserve_default=False,
129+
),
130+
migrations.AlterField(
131+
model_name="simplifiedeap",
132+
name="national_society_contact_name",
133+
field=models.CharField(
134+
default="test",
135+
max_length=255,
136+
verbose_name="national society contact name",
137+
),
138+
preserve_default=False,
139+
),
140+
]

eap/models.py

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -749,11 +749,6 @@ class CommonEAPFields(models.Model):
749749
related_name="+",
750750
)
751751

752-
seap_timeframe = models.IntegerField(
753-
verbose_name=_("Timeframe (Years) of the EAP"),
754-
help_text=_("Timeframe of the EAP in years."),
755-
)
756-
757752
admin2 = models.ManyToManyField(
758753
Admin2,
759754
verbose_name=_("admin"),
@@ -768,13 +763,15 @@ class CommonEAPFields(models.Model):
768763
# Contacts
769764
# National Society
770765
national_society_contact_name = models.CharField(
771-
verbose_name=_("national society contact name"), max_length=255, null=True, blank=True
766+
verbose_name=_("national society contact name"),
767+
max_length=255,
772768
)
773769
national_society_contact_title = models.CharField(
774770
verbose_name=_("national society contact title"), max_length=255, null=True, blank=True
775771
)
776772
national_society_contact_email = models.CharField(
777-
verbose_name=_("national society contact email"), max_length=255, null=True, blank=True
773+
verbose_name=_("national society contact email"),
774+
max_length=255,
778775
)
779776
national_society_contact_phone_number = models.CharField(
780777
verbose_name=_("national society contact phone number"), max_length=100, null=True, blank=True
@@ -787,25 +784,17 @@ class CommonEAPFields(models.Model):
787784
partner_ns_phone_number = models.CharField(verbose_name=_("Partner NS phone number"), max_length=100, null=True, blank=True)
788785

789786
# Delegations
790-
ifrc_delegation_focal_point_name = models.CharField(
791-
verbose_name=_("IFRC delegation focal point name"), max_length=255, null=True, blank=True
792-
)
793-
ifrc_delegation_focal_point_email = models.CharField(
794-
verbose_name=_("IFRC delegation focal point email"), max_length=255, null=True, blank=True
795-
)
787+
ifrc_delegation_focal_point_name = models.CharField(verbose_name=_("IFRC delegation focal point name"), max_length=255)
788+
ifrc_delegation_focal_point_email = models.CharField(verbose_name=_("IFRC delegation focal point email"), max_length=255)
796789
ifrc_delegation_focal_point_title = models.CharField(
797790
verbose_name=_("IFRC delegation focal point title"), max_length=255, null=True, blank=True
798791
)
799792
ifrc_delegation_focal_point_phone_number = models.CharField(
800793
verbose_name=_("IFRC delegation focal point phone number"), max_length=100, null=True, blank=True
801794
)
802795

803-
ifrc_head_of_delegation_name = models.CharField(
804-
verbose_name=_("IFRC head of delegation name"), max_length=255, null=True, blank=True
805-
)
806-
ifrc_head_of_delegation_email = models.CharField(
807-
verbose_name=_("IFRC head of delegation email"), max_length=255, null=True, blank=True
808-
)
796+
ifrc_head_of_delegation_name = models.CharField(verbose_name=_("IFRC head of delegation name"), max_length=255)
797+
ifrc_head_of_delegation_email = models.CharField(verbose_name=_("IFRC head of delegation email"), max_length=255)
809798
ifrc_head_of_delegation_title = models.CharField(
810799
verbose_name=_("IFRC head of delegation title"), max_length=255, null=True, blank=True
811800
)
@@ -926,6 +915,11 @@ class SimplifiedEAP(EAPBaseModel, CommonEAPFields):
926915
related_name="simplified_eap",
927916
)
928917

918+
seap_timeframe = models.IntegerField(
919+
verbose_name=_("Timeframe (Years) of the EAP"),
920+
help_text=_("Timeframe of the EAP in years."),
921+
)
922+
929923
# RISK ANALYSIS and EARLY ACTION SELECTION #
930924

931925
# RISK ANALYSIS #
@@ -1284,11 +1278,6 @@ class FullEAP(EAPBaseModel, CommonEAPFields):
12841278
blank=True,
12851279
)
12861280

1287-
selection_area = models.TextField(
1288-
verbose_name=_("Areas selection rationale"),
1289-
help_text=_("Add description for the selection of the areas."),
1290-
)
1291-
12921281
trigger_model_relevant_files = models.ManyToManyField(
12931282
EAPFile,
12941283
blank=True,

eap/serializers.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ class Meta:
115115
"readiness_budget",
116116
"pre_positioning_budget",
117117
"early_action_budget",
118-
"seap_timeframe",
119118
"budget_file",
120119
"version",
121120
"is_locked",
@@ -448,8 +447,8 @@ class SimplifiedEAPSerializer(
448447

449448
# FILES
450449
hazard_impact_images = EAPFileUpdateSerializer(required=False, many=True)
451-
selected_early_actions_images = EAPFileUpdateSerializer(required=False, many=True)
452-
risk_selected_protocols_images = EAPFileUpdateSerializer(required=False, many=True)
450+
selected_early_actions_images = EAPFileUpdateSerializer(required=False, many=True, allow_null=True)
451+
risk_selected_protocols_images = EAPFileUpdateSerializer(required=False, many=True, allow_null=True)
453452

454453
# TimeFrame
455454
seap_lead_timeframe_unit_display = serializers.CharField(source="get_seap_lead_timeframe_unit_display", read_only=True)
@@ -570,11 +569,11 @@ class FullEAPSerializer(
570569
prioritized_impacts = ImpactSerializer(many=True, required=False)
571570

572571
# SOURCE OF INFORMATIONS
573-
risk_analysis_source_of_information = EAPSourceInformationSerializer(many=True, required=False)
574-
trigger_statement_source_of_information = EAPSourceInformationSerializer(many=True, required=False)
575-
trigger_model_source_of_information = EAPSourceInformationSerializer(many=True, required=False)
576-
evidence_base_source_of_information = EAPSourceInformationSerializer(many=True, required=False)
577-
activation_process_source_of_information = EAPSourceInformationSerializer(many=True, required=False)
572+
risk_analysis_source_of_information = EAPSourceInformationSerializer(many=True, required=False, allow_null=True)
573+
trigger_statement_source_of_information = EAPSourceInformationSerializer(many=True, required=False, allow_null=True)
574+
trigger_model_source_of_information = EAPSourceInformationSerializer(many=True, required=False, allow_null=True)
575+
evidence_base_source_of_information = EAPSourceInformationSerializer(many=True, required=False, allow_null=True)
576+
activation_process_source_of_information = EAPSourceInformationSerializer(many=True, required=False, allow_null=True)
578577

579578
# IMAGES
580579
hazard_selection_images = EAPFileUpdateSerializer(

eap/test_views.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,8 @@ def test_create_eap_registration(self):
131131
"disaster_type": self.disaster_type.id,
132132
"expected_submission_time": "2024-12-31",
133133
"partners": [self.partner1.id, self.partner2.id],
134+
"national_society_contact_name": "National society contact name",
135+
"national_society_contact_email": "test@example.com",
134136
}
135137

136138
self.authenticate(self.country_admin)
@@ -464,6 +466,12 @@ def test_create_simplified_eap(self):
464466

465467
data = {
466468
"eap_registration": eap_registration.id,
469+
"national_society_contact_name": "National society contact name",
470+
"national_society_contact_email": "test@example.com",
471+
"ifrc_delegation_focal_point_name": "IFRC delegation focal point name",
472+
"ifrc_delegation_focal_point_email": "test_ifrc@example.com",
473+
"ifrc_head_of_delegation_name": "IFRC head of delegation name",
474+
"ifrc_head_of_delegation_email": "ifrc_head@example.com",
467475
"prioritized_hazard_and_impact": "Floods with potential heavy impact.",
468476
"risks_selected_protocols": "Protocol A and Protocol B.",
469477
"selected_early_actions": "The early actions selected.",
@@ -1875,6 +1883,12 @@ def test_create_full_eap(self):
18751883

18761884
data = {
18771885
"eap_registration": eap_registration.id,
1886+
"national_society_contact_name": "National society contact name",
1887+
"national_society_contact_email": "test@example.com",
1888+
"ifrc_delegation_focal_point_name": "IFRC delegation focal point name",
1889+
"ifrc_delegation_focal_point_email": "test_ifrc@example.com",
1890+
"ifrc_head_of_delegation_name": "IFRC head of delegation name",
1891+
"ifrc_head_of_delegation_email": "ifrc_head@example.com",
18781892
"budget_file": budget_file_instance.id,
18791893
"forecast_table_file": forecast_table_file.id,
18801894
"hazard_selection_images": [
@@ -1918,7 +1932,6 @@ def test_create_full_eap(self):
19181932
"objective": "FUll eap objective",
19191933
"lead_time": 5,
19201934
"expected_submission_time": "2024-12-31",
1921-
"seap_timeframe": 5,
19221935
"readiness_budget": 3000,
19231936
"pre_positioning_budget": 4000,
19241937
"early_action_budget": 3000,
@@ -1945,7 +1958,6 @@ def test_create_full_eap(self):
19451958
"forecast_selection": "Rainfall forecast",
19461959
"definition_and_justification_impact_level": "Definition and justification of impact levels",
19471960
"identification_of_the_intervention_area": "Identification of the intervention areas",
1948-
"selection_area": "Selection of the area",
19491961
"early_action_selection_process": "Early action selection process",
19501962
"evidence_base": "Evidence base",
19511963
"usefulness_of_actions": "Usefulness of actions",

0 commit comments

Comments
 (0)