Skip to content

Commit 8c0c957

Browse files
committed
feat(eap): Update full eap fields and add new fields
- Update test cases, admin, serializers - Make budget file required in both eaps
1 parent c3edbf0 commit 8c0c957

7 files changed

Lines changed: 250 additions & 133 deletions

File tree

eap/admin.py

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
from django.contrib import admin
22

3-
from eap.models import EAPRegistration, FullEAP, KeyActor, SimplifiedEAP
3+
from eap.models import EAPFile, EAPRegistration, FullEAP, KeyActor, SimplifiedEAP
4+
5+
6+
@admin.register(EAPFile)
7+
class EAPFileAdmin(admin.ModelAdmin):
8+
search_fields = ("caption",)
49

510

611
@admin.register(EAPRegistration)
@@ -120,19 +125,19 @@ class FullEAPAdmin(admin.ModelAdmin):
120125
"planned_operations",
121126
"enable_approaches",
122127
"planned_operations",
123-
"hazard_selection_files",
128+
"hazard_selection_images",
124129
"theory_of_change_table_file",
125-
"exposed_element_and_vulnerability_factor_files",
126-
"prioritized_impact_files",
130+
"exposed_element_and_vulnerability_factor_images",
131+
"prioritized_impact_images",
127132
"risk_analysis_relevant_files",
128-
"forecast_selection_files",
129-
"definition_and_justification_impact_level_files",
130-
"identification_of_the_intervention_area_files",
133+
"forecast_selection_images",
134+
"definition_and_justification_impact_level_images",
135+
"identification_of_the_intervention_area_images",
131136
"trigger_model_relevant_files",
132-
"early_action_selection_process_files",
133-
"evidence_base_files",
134-
"early_action_implementation_files",
135-
"trigger_activation_system_files",
137+
"early_action_selection_process_images",
138+
"evidence_base_relevant_files",
139+
"early_action_implementation_images",
140+
"trigger_activation_system_images",
136141
"activation_process_relevant_files",
137142
"meal_relevant_files",
138143
"capacity_relevant_files",

eap/factories.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from factory import fuzzy
33

44
from eap.models import (
5+
EAPFile,
56
EAPRegistration,
67
EAPStatus,
78
EAPType,
@@ -13,6 +14,30 @@
1314
)
1415

1516

17+
class EAPFileFactory(factory.django.DjangoModelFactory):
18+
class Meta:
19+
model = EAPFile
20+
21+
caption = fuzzy.FuzzyText(length=10, prefix="EAPFile-")
22+
file = factory.django.FileField(filename="eap_file.txt")
23+
24+
@classmethod
25+
def _create_image(cls, *args, **kwargs) -> EAPFile:
26+
return cls.create(
27+
file=factory.django.FileField(filename="eap_image.jpeg", data=b"fake image data"),
28+
caption="EAP Image",
29+
**kwargs,
30+
)
31+
32+
@classmethod
33+
def _create_file(cls, *args, **kwargs) -> EAPFile:
34+
return cls.create(
35+
file=factory.django.FileField(filename="eap_document.pdf", data=b"fake pdf data"),
36+
caption="EAP Document",
37+
**kwargs,
38+
)
39+
40+
1641
class EAPRegistrationFactory(factory.django.DjangoModelFactory):
1742
class Meta:
1843
model = EAPRegistration
@@ -39,6 +64,7 @@ class Meta:
3964
readiness_budget = fuzzy.FuzzyInteger(1000, 1000000)
4065
pre_positioning_budget = fuzzy.FuzzyInteger(1000, 1000000)
4166
early_action_budget = fuzzy.FuzzyInteger(1000, 1000000)
67+
people_targeted = fuzzy.FuzzyInteger(100, 100000)
4268

4369
@factory.post_generation
4470
def enable_approaches(self, create, extracted, **kwargs):
@@ -150,3 +176,4 @@ class Meta:
150176
readiness_budget = fuzzy.FuzzyInteger(1000, 1000000)
151177
pre_positioning_budget = fuzzy.FuzzyInteger(1000, 1000000)
152178
early_action_budget = fuzzy.FuzzyInteger(1000, 1000000)
179+
people_targeted = fuzzy.FuzzyInteger(100, 100000)

eap/migrations/0009_sourceinformation_alter_simplifiedeap_admin2_and_more.py

Lines changed: 56 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Generated by Django 4.2.19 on 2025-11-26 09:04
1+
# Generated by Django 4.2.26 on 2025-11-26 15:19
22

33
from django.conf import settings
44
from django.db import migrations, models
@@ -8,8 +8,8 @@
88

99
class Migration(migrations.Migration):
1010
dependencies = [
11-
("api", "0227_alter_export_export_type"),
1211
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
12+
("api", "0228_alter_export_export_type"),
1313
("eap", "0008_remove_simplifiedeap_hazard_impact_file_and_more"),
1414
]
1515

@@ -47,6 +47,16 @@ class Migration(migrations.Migration):
4747
blank=True, related_name="+", to="api.admin2", verbose_name="admin"
4848
),
4949
),
50+
migrations.AlterField(
51+
model_name="simplifiedeap",
52+
name="budget_file",
53+
field=models.ForeignKey(
54+
on_delete=django.db.models.deletion.CASCADE,
55+
related_name="+",
56+
to="eap.eapfile",
57+
verbose_name="Budget File",
58+
),
59+
),
5060
migrations.AlterField(
5161
model_name="simplifiedeap",
5262
name="cover_image",
@@ -59,6 +69,11 @@ class Migration(migrations.Migration):
5969
verbose_name="cover image",
6070
),
6171
),
72+
migrations.AlterField(
73+
model_name="simplifiedeap",
74+
name="people_targeted",
75+
field=models.IntegerField(verbose_name="People Targeted."),
76+
),
6277
migrations.AlterField(
6378
model_name="simplifiedeap",
6479
name="seap_timeframe",
@@ -129,6 +144,10 @@ class Migration(migrations.Migration):
129144
verbose_name="Timeframe (Years) of the EAP",
130145
),
131146
),
147+
(
148+
"people_targeted",
149+
models.IntegerField(verbose_name="People Targeted."),
150+
),
132151
(
133152
"national_society_contact_name",
134153
models.CharField(
@@ -647,15 +666,6 @@ class Migration(migrations.Migration):
647666
"budget_description",
648667
models.TextField(verbose_name="Full EAP Budget Description"),
649668
),
650-
(
651-
"budget_file",
652-
main.fields.SecureFileField(
653-
blank=True,
654-
null=True,
655-
upload_to="eap/full_eap/budget_files",
656-
verbose_name="Budget File",
657-
),
658-
),
659669
(
660670
"readiness_cost_description",
661671
models.TextField(verbose_name="Readiness Cost Description"),
@@ -718,6 +728,15 @@ class Migration(migrations.Migration):
718728
verbose_name="admin",
719729
),
720730
),
731+
(
732+
"budget_file",
733+
models.ForeignKey(
734+
on_delete=django.db.models.deletion.CASCADE,
735+
related_name="+",
736+
to="eap.eapfile",
737+
verbose_name="Budget File",
738+
),
739+
),
721740
(
722741
"capacity_relevant_files",
723742
models.ManyToManyField(
@@ -748,12 +767,12 @@ class Migration(migrations.Migration):
748767
),
749768
),
750769
(
751-
"definition_and_justification_impact_level_files",
770+
"definition_and_justification_impact_level_images",
752771
models.ManyToManyField(
753772
blank=True,
754773
related_name="+",
755774
to="eap.eapfile",
756-
verbose_name="Definition and Justification Impact Level Files",
775+
verbose_name="Definition and Justification Impact Level Images",
757776
),
758777
),
759778
(
@@ -766,21 +785,21 @@ class Migration(migrations.Migration):
766785
),
767786
),
768787
(
769-
"early_action_implementation_files",
788+
"early_action_implementation_images",
770789
models.ManyToManyField(
771790
blank=True,
772-
related_name="early_action_implementation_files",
791+
related_name="early_action_implementation_images",
773792
to="eap.eapfile",
774-
verbose_name="Early Action Implementation Files",
793+
verbose_name="Early Action Implementation Images",
775794
),
776795
),
777796
(
778-
"early_action_selection_process_files",
797+
"early_action_selection_process_images",
779798
models.ManyToManyField(
780799
blank=True,
781-
related_name="early_action_selection_process_files",
800+
related_name="early_action_selection_process_images",
782801
to="eap.eapfile",
783-
verbose_name="Early action selection process files",
802+
verbose_name="Early action selection process images",
784803
),
785804
),
786805
(
@@ -793,10 +812,10 @@ class Migration(migrations.Migration):
793812
),
794813
),
795814
(
796-
"evidence_base_files",
815+
"evidence_base_relevant_files",
797816
models.ManyToManyField(
798817
blank=True,
799-
related_name="full_eap_evidence_base_files",
818+
related_name="full_eap_evidence_base_relavent_files",
800819
to="eap.eapfile",
801820
verbose_name="Evidence base files",
802821
),
@@ -811,39 +830,39 @@ class Migration(migrations.Migration):
811830
),
812831
),
813832
(
814-
"exposed_element_and_vulnerability_factor_files",
833+
"exposed_element_and_vulnerability_factor_images",
815834
models.ManyToManyField(
816835
blank=True,
817-
related_name="full_eap_vulnerability_factor_files",
836+
related_name="full_eap_vulnerability_factor_images",
818837
to="eap.eapfile",
819-
verbose_name="Exposed elements and vulnerability factors files",
838+
verbose_name="Exposed elements and vulnerability factors images",
820839
),
821840
),
822841
(
823-
"forecast_selection_files",
842+
"forecast_selection_images",
824843
models.ManyToManyField(
825844
blank=True,
826845
related_name="+",
827846
to="eap.eapfile",
828-
verbose_name="Forecast Selection Files",
847+
verbose_name="Forecast Selection Images",
829848
),
830849
),
831850
(
832-
"hazard_selection_files",
851+
"hazard_selection_images",
833852
models.ManyToManyField(
834853
blank=True,
835-
related_name="full_eap_hazard_selection_files",
854+
related_name="full_eap_hazard_selection_images",
836855
to="eap.eapfile",
837-
verbose_name="Hazard files",
856+
verbose_name="Hazard images",
838857
),
839858
),
840859
(
841-
"identification_of_the_intervention_area_files",
860+
"identification_of_the_intervention_area_images",
842861
models.ManyToManyField(
843862
blank=True,
844863
related_name="+",
845864
to="eap.eapfile",
846-
verbose_name="Intervention Area Files",
865+
verbose_name="Intervention Area Images",
847866
),
848867
),
849868
(
@@ -894,12 +913,12 @@ class Migration(migrations.Migration):
894913
),
895914
),
896915
(
897-
"prioritized_impact_files",
916+
"prioritized_impact_images",
898917
models.ManyToManyField(
899918
blank=True,
900-
related_name="full_eap_prioritized_impact_files",
919+
related_name="full_eap_prioritized_impact_images",
901920
to="eap.eapfile",
902-
verbose_name="Prioritized impact files",
921+
verbose_name="Prioritized impact images",
903922
),
904923
),
905924
(
@@ -932,12 +951,12 @@ class Migration(migrations.Migration):
932951
),
933952
),
934953
(
935-
"trigger_activation_system_files",
954+
"trigger_activation_system_images",
936955
models.ManyToManyField(
937956
blank=True,
938-
related_name="trigger_activation_system_files",
957+
related_name="trigger_activation_system_images",
939958
to="eap.eapfile",
940-
verbose_name="Trigger Activation System Files",
959+
verbose_name="Trigger Activation System Images",
941960
),
942961
),
943962
(

0 commit comments

Comments
 (0)