Skip to content

Commit c57d158

Browse files
committed
Merge pull request #2635 from IFRCGo/fix/cleanup-squash-migrations
2 parents 6efd9ff + 259e451 commit c57d158

27 files changed

Lines changed: 2550 additions & 2490 deletions
Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,29 @@
1-
# Generated by Django 4.2.19 on 2025-11-18 05:22
1+
# Generated by Django 4.2.26 on 2026-01-14 08:51
22

33
from django.db import migrations, models
44

55

66
class Migration(migrations.Migration):
7-
87
dependencies = [
9-
('api', '0226_nsdinitiativescategory_and_more'),
8+
("api", "0226_nsdinitiativescategory_and_more"),
109
]
1110

1211
operations = [
1312
migrations.AlterField(
14-
model_name='export',
15-
name='export_type',
16-
field=models.CharField(choices=[('dref-applications', 'DREF Application'), ('dref-operational-updates', 'DREF Operational Update'), ('dref-final-reports', 'DREF Final Report'), ('old-dref-final-reports', 'Old DREF Final Report'), ('per', 'Per'), ('simplified-eap', 'Simplified EAP')], max_length=255, verbose_name='Export Type'),
13+
model_name="export",
14+
name="export_type",
15+
field=models.CharField(
16+
choices=[
17+
("dref-applications", "DREF Application"),
18+
("dref-operational-updates", "DREF Operational Update"),
19+
("dref-final-reports", "DREF Final Report"),
20+
("old-dref-final-reports", "Old DREF Final Report"),
21+
("per", "Per"),
22+
("simplified", "Simplified EAP"),
23+
("full", "Full EAP"),
24+
],
25+
max_length=255,
26+
verbose_name="Export Type",
27+
),
1728
),
1829
]

api/migrations/0228_alter_export_export_type.py

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

api/migrations/0229_alter_export_export_type.py

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

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

0 commit comments

Comments
 (0)