Skip to content

Commit 259e451

Browse files
committed
chore(eap): update global file export url, test cases
- Change eap global export file url
1 parent eb9a2b4 commit 259e451

10 files changed

Lines changed: 223 additions & 200 deletions

api/utils.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,23 +160,36 @@ class CountryValidator(TypedDict):
160160

161161
def generate_eap_export_url(
162162
registration_id: int,
163-
diff: bool = False,
164163
version: Optional[int] = None,
164+
diff: bool = False,
165165
summary: bool = False,
166166
) -> str:
167167
"""
168168
Generate EAP export URL for given registration ID, version and diff flag.
169169
"""
170170
from django.conf import settings
171171

172+
from eap.models import EAPRegistration, EAPType
173+
174+
registration = EAPRegistration.objects.filter(id=registration_id).first()
175+
if not registration:
176+
raise ValueError("EAP Registration with the given ID does not exist.")
177+
172178
url = f"{settings.GO_WEB_INTERNAL_URL}/eap/{registration_id}/export/"
179+
if summary:
180+
return url + "summary/"
181+
182+
assert registration.get_eap_type_enum is not None, "EAP Type should not be None"
183+
if registration.get_eap_type_enum == EAPType.SIMPLIFIED_EAP:
184+
url += "simplified/"
185+
else:
186+
url += "full/"
187+
173188
if version:
174189
url += f"?version={version}"
175190

176191
# NOTE: EAP exports with diff view only for EAPs exports
177192
if diff:
178193
url += "&diff=true" if version else "?diff=true"
179194

180-
if summary:
181-
url = f"{settings.GO_WEB_INTERNAL_URL}/eap/{registration_id}/summary/export/"
182195
return url

eap/admin.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ class SimplifiedEAPAdmin(admin.ModelAdmin):
9999
"risk_selected_protocols_images",
100100
"selected_early_actions_images",
101101
"planned_operations",
102-
"enable_approaches",
102+
"enabling_approaches",
103103
"parent",
104104
"is_locked",
105105
"version",
@@ -187,7 +187,7 @@ class FullEAPAdmin(admin.ModelAdmin):
187187
"partner_contacts",
188188
"cover_image",
189189
"planned_operations",
190-
"enable_approaches",
190+
"enabling_approaches",
191191
"planned_operations",
192192
"hazard_selection_images",
193193
"theory_of_change_table_file",

eap/enums.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@
99
"months_timeframe_value": models.MonthsTimeFrameChoices,
1010
"days_timeframe_value": models.DaysTimeFrameChoices,
1111
"hours_timeframe_value": models.HoursTimeFrameChoices,
12-
"approach": models.EnableApproach.Approach,
12+
"approach": models.EnablingApproach.Approach,
1313
}

eap/factories.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
EAPRegistration,
1111
EAPStatus,
1212
EAPType,
13-
EnableApproach,
13+
EnablingApproach,
1414
FullEAP,
1515
KeyActor,
1616
OperationActivity,
@@ -96,13 +96,13 @@ class Meta:
9696
ifrc_head_of_delegation_email = factory.LazyAttribute(lambda obj: f"{obj.ifrc_head_of_delegation_name.lower()}@example.com")
9797

9898
@factory.post_generation
99-
def enable_approaches(self, create, extracted, **kwargs):
99+
def enabling_approaches(self, create, extracted, **kwargs):
100100
if not create:
101101
return
102102

103103
if extracted:
104104
for approach in extracted:
105-
self.enable_approaches.add(approach)
105+
self.enabling_approaches.add(approach)
106106

107107
@factory.post_generation
108108
def planned_operations(self, create, extracted, **kwargs):
@@ -122,11 +122,11 @@ class Meta:
122122
timeframe = fuzzy.FuzzyChoice(TimeFrame)
123123

124124

125-
class EnableApproachFactory(factory.django.DjangoModelFactory):
125+
class EnablingApproachFactory(factory.django.DjangoModelFactory):
126126
class Meta:
127-
model = EnableApproach
127+
model = EnablingApproach
128128

129-
approach = fuzzy.FuzzyChoice(EnableApproach.Approach)
129+
approach = fuzzy.FuzzyChoice(EnablingApproach.Approach)
130130
budget_per_approach = fuzzy.FuzzyInteger(1000, 1000000)
131131
ap_code = fuzzy.FuzzyInteger(100, 999)
132132

eap/migrations/0003_eapaction_eapcontact_eapfile_eapimpact_and_more.py

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Generated by Django 4.2.26 on 2026-01-14 08:52
1+
# Generated by Django 4.2.26 on 2026-01-16 06:27
22

33
from django.conf import settings
44
import django.contrib.postgres.fields
@@ -9,8 +9,8 @@
99

1010
class Migration(migrations.Migration):
1111
dependencies = [
12-
("api", "0227_alter_export_export_type"),
1312
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
13+
("api", "0227_alter_export_export_type"),
1414
("eap", "0002_auto_20220708_0747"),
1515
]
1616

@@ -436,7 +436,7 @@ class Migration(migrations.Migration):
436436
},
437437
),
438438
migrations.CreateModel(
439-
name="EnableApproach",
439+
name="EnablingApproach",
440440
fields=[
441441
(
442442
"id",
@@ -474,8 +474,8 @@ class Migration(migrations.Migration):
474474
),
475475
],
476476
options={
477-
"verbose_name": "Enable Approach",
478-
"verbose_name_plural": "Enable Approaches",
477+
"verbose_name": "Enabling Approach",
478+
"verbose_name_plural": "Enabling Approaches",
479479
},
480480
),
481481
migrations.CreateModel(
@@ -1181,17 +1181,17 @@ class Migration(migrations.Migration):
11811181
"eap_registration",
11821182
models.ForeignKey(
11831183
on_delete=django.db.models.deletion.CASCADE,
1184-
related_name="simplified_eap",
1184+
related_name="simplified_eaps",
11851185
to="eap.eapregistration",
11861186
verbose_name="EAP Development Registration",
11871187
),
11881188
),
11891189
(
1190-
"enable_approaches",
1190+
"enabling_approaches",
11911191
models.ManyToManyField(
11921192
blank=True,
1193-
related_name="simplified_eap_enable_approaches",
1194-
to="eap.enableapproach",
1193+
related_name="simplified_eap_enabling_approaches",
1194+
to="eap.enablingapproach",
11951195
verbose_name="Enabling Approaches",
11961196
),
11971197
),
@@ -1679,7 +1679,9 @@ class Migration(migrations.Migration):
16791679
(
16801680
"worked_with_government_description",
16811681
models.TextField(
1682-
verbose_name="Government and actors engagement description"
1682+
blank=True,
1683+
null=True,
1684+
verbose_name="Government and actors engagement description",
16831685
),
16841686
),
16851687
(
@@ -1702,7 +1704,9 @@ class Migration(migrations.Migration):
17021704
(
17031705
"technical_working_groups_in_place_description",
17041706
models.TextField(
1705-
verbose_name="Technical working groups description"
1707+
blank=True,
1708+
null=True,
1709+
verbose_name="Technical working groups description",
17061710
),
17071711
),
17081712
(
@@ -1945,7 +1949,7 @@ class Migration(migrations.Migration):
19451949
"eap_registration",
19461950
models.ForeignKey(
19471951
on_delete=django.db.models.deletion.CASCADE,
1948-
related_name="full_eap",
1952+
related_name="full_eaps",
19491953
to="eap.eapregistration",
19501954
verbose_name="EAP Development Registration",
19511955
),
@@ -1977,11 +1981,11 @@ class Migration(migrations.Migration):
19771981
),
19781982
),
19791983
(
1980-
"enable_approaches",
1984+
"enabling_approaches",
19811985
models.ManyToManyField(
19821986
blank=True,
1983-
related_name="full_eap_enable_approaches",
1984-
to="eap.enableapproach",
1987+
related_name="full_eap_enabling_approaches",
1988+
to="eap.enablingapproach",
19851989
verbose_name="Enabling approaches",
19861990
),
19871991
),
@@ -2206,41 +2210,41 @@ class Migration(migrations.Migration):
22062210
},
22072211
),
22082212
migrations.AddField(
2209-
model_name="enableapproach",
2213+
model_name="enablingapproach",
22102214
name="early_action_activities",
22112215
field=models.ManyToManyField(
22122216
blank=True,
2213-
related_name="enable_approach_early_action_activities",
2217+
related_name="enabling_approach_early_action_activities",
22142218
to="eap.operationactivity",
22152219
verbose_name="Early Action Activities",
22162220
),
22172221
),
22182222
migrations.AddField(
2219-
model_name="enableapproach",
2223+
model_name="enablingapproach",
22202224
name="indicators",
22212225
field=models.ManyToManyField(
22222226
blank=True,
2223-
related_name="enable_approach_indicators",
2227+
related_name="enabling_approach_indicators",
22242228
to="eap.indicator",
2225-
verbose_name="Enable Approach Indicators",
2229+
verbose_name="Enabling Approach Indicators",
22262230
),
22272231
),
22282232
migrations.AddField(
2229-
model_name="enableapproach",
2233+
model_name="enablingapproach",
22302234
name="prepositioning_activities",
22312235
field=models.ManyToManyField(
22322236
blank=True,
2233-
related_name="enable_approach_prepositioning_activities",
2237+
related_name="enabling_approach_prepositioning_activities",
22342238
to="eap.operationactivity",
22352239
verbose_name="Pre-positioning Activities",
22362240
),
22372241
),
22382242
migrations.AddField(
2239-
model_name="enableapproach",
2243+
model_name="enablingapproach",
22402244
name="readiness_activities",
22412245
field=models.ManyToManyField(
22422246
blank=True,
2243-
related_name="enable_approach_readiness_activities",
2247+
related_name="enabling_approach_readiness_activities",
22442248
to="eap.operationactivity",
22452249
verbose_name="Readiness Activities",
22462250
),

eap/migrations/0016_alter_fulleap_technical_working_groups_in_place_description_and_more.py

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)