Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion assets
Submodule assets updated 1 files
+160 −330 openapi-schema.yaml
26 changes: 13 additions & 13 deletions eap/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,9 @@ class SimplifiedEAPAdmin(admin.ModelAdmin):
readonly_fields = (
"cover_image",
"partner_contacts",
"hazard_impact_images",
"risk_selected_protocols_images",
"selected_early_actions_images",
"hazard_impact_files",
"risk_selected_protocols_files",
"selected_early_actions_files",
"planned_operations",
"enabling_approaches",
"parent",
Expand Down Expand Up @@ -194,7 +194,7 @@ def get_queryset(self, request):

@admin.register(KeyActor)
class KeyActorAdmin(admin.ModelAdmin):
list_display = ("national_society",)
list_display = ("partner",)


@admin.register(FullEAP)
Expand All @@ -218,19 +218,19 @@ class FullEAPAdmin(admin.ModelAdmin):
"planned_operations",
"enabling_approaches",
"planned_operations",
"hazard_selection_images",
"hazard_selection_files",
"theory_of_change_table_file",
"exposed_element_and_vulnerability_factor_images",
"prioritized_impact_images",
"exposed_element_and_vulnerability_factor_files",
"prioritized_impact_files",
"risk_analysis_relevant_files",
"forecast_selection_images",
"definition_and_justification_impact_level_images",
"identification_of_the_intervention_area_images",
"forecast_selection_files",
"definition_and_justification_impact_level_files",
"identification_of_the_intervention_area_files",
"trigger_model_relevant_files",
"early_action_selection_process_images",
"early_action_selection_process_files",
"evidence_base_relevant_files",
"early_action_implementation_images",
"trigger_activation_system_images",
"early_action_implementation_files",
"trigger_activation_system_files",
"activation_process_relevant_files",
"meal_relevant_files",
"capacity_relevant_files",
Expand Down
6 changes: 3 additions & 3 deletions eap/dev_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ def get(self, request):
"resubmission_of_revised_eap": "email/eap/re-submission.html",
"feedback_for_revised_eap": "email/eap/feedback_to_revised_eap.html",
"technically_validated_eap": "email/eap/technically_validated_eap.html",
"pending_pfa": "email/eap/pending_pfa.html",
"approved_eap": "email/eap/approved.html",
"project_agreement_signed": "email/eap/project_agreement_signed.html",
Comment thread
susilnem marked this conversation as resolved.
"reminder": "email/eap/reminder.html",
"share_eap": "email/eap/share_eap.html",
}
Expand Down Expand Up @@ -97,13 +97,13 @@ def get(self, request):
"national_society": "Test National Society",
"disaster_type": "Flood",
},
"pending_pfa": {
"approved_eap": {
"eap_type_display": "FULL EAP",
"country_name": "Test Country",
"national_society": "Test National Society",
"disaster_type": "Flood",
},
"approved_eap": {
"project_agreement_signed": {
"eap_type_display": "FULL EAP",
"country_name": "Test Country",
"national_society": "Test National Society",
Expand Down
25 changes: 9 additions & 16 deletions eap/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class Meta:
status = fuzzy.FuzzyChoice(EAPStatus)
eap_type = fuzzy.FuzzyChoice(EAPType)
national_society_contact_name = fuzzy.FuzzyText(length=10, prefix="NS-")
national_society_contact_title = fuzzy.FuzzyText(length=10, prefix="NS-Title-")
national_society_contact_email = factory.LazyAttribute(lambda obj: f"{obj.national_society_contact_name.lower()}@example.com")

@factory.post_generation
Expand All @@ -83,18 +84,13 @@ class Meta:
readiness_budget = fuzzy.FuzzyInteger(1000, 1000000)
pre_positioning_budget = fuzzy.FuzzyInteger(1000, 1000000)
early_action_budget = fuzzy.FuzzyInteger(1000, 1000000)
people_targeted = fuzzy.FuzzyInteger(2001, 100000)
total_people_targeted = fuzzy.FuzzyInteger(2001, 100000)
seap_lead_timeframe_unit = fuzzy.FuzzyInteger(TimeFrame.MONTHS)
seap_lead_time = fuzzy.FuzzyInteger(1, 12)
operational_timeframe = fuzzy.FuzzyInteger(1, 12)
activation_timeframe = fuzzy.FuzzyInteger(1, 12)
national_society_contact_name = fuzzy.FuzzyText(length=10, prefix="NS-")
national_society_contact_title = fuzzy.FuzzyText(length=10, prefix="NS-Title-")
national_society_contact_email = factory.LazyAttribute(lambda obj: f"{obj.national_society_contact_name.lower()}@example.com")
ifrc_delegation_focal_point_name = fuzzy.FuzzyText(length=10, prefix="IFRC-")
ifrc_delegation_focal_point_email = factory.LazyAttribute(
lambda obj: f"{obj.ifrc_delegation_focal_point_name.lower()}@example.com"
)
ifrc_head_of_delegation_name = fuzzy.FuzzyText(length=10, prefix="ifrc-head-")
ifrc_head_of_delegation_email = factory.LazyAttribute(lambda obj: f"{obj.ifrc_head_of_delegation_name.lower()}@example.com")
prioritized_hazard_and_impact = fuzzy.FuzzyText(length=50, prefix="prioritized-hazard")
risks_selected_protocols = fuzzy.FuzzyText(length=50, prefix="risks-selected-")
selected_early_actions = fuzzy.FuzzyText(length=50, prefix="selected-early-")
Expand Down Expand Up @@ -208,6 +204,7 @@ class KeyActorFactory(factory.django.DjangoModelFactory):
class Meta:
model = KeyActor

partner = fuzzy.FuzzyText(length=10, prefix="Partner-")
description = fuzzy.FuzzyText(length=5, prefix="KeyActor-")


Expand All @@ -216,20 +213,16 @@ class Meta:
model = FullEAP

expected_submission_time = fuzzy.FuzzyDateTime(datetime(2025, 1, 1, tzinfo=pytz.utc))
lead_time = fuzzy.FuzzyInteger(1, 100)
lead_timeframe_unit = fuzzy.FuzzyInteger(TimeFrame.MONTHS)
lead_time = fuzzy.FuzzyInteger(1, 12)
total_budget = fuzzy.FuzzyInteger(1000, 1000000)
readiness_budget = fuzzy.FuzzyInteger(1000, 1000000)
pre_positioning_budget = fuzzy.FuzzyInteger(1000, 1000000)
early_action_budget = fuzzy.FuzzyInteger(1000, 1000000)
people_targeted = fuzzy.FuzzyInteger(10001, 10000000)
total_people_targeted = fuzzy.FuzzyInteger(10001, 10000000)
national_society_contact_name = fuzzy.FuzzyText(length=10, prefix="NS-")
national_society_contact_title = fuzzy.FuzzyText(length=10, prefix="NS-Title-")
national_society_contact_email = factory.LazyAttribute(lambda obj: f"{obj.national_society_contact_name.lower()}@example.com")
ifrc_delegation_focal_point_name = fuzzy.FuzzyText(length=10, prefix="IFRC-")
ifrc_delegation_focal_point_email = factory.LazyAttribute(
lambda obj: f"{obj.ifrc_delegation_focal_point_name.lower()}@example.com"
)
ifrc_head_of_delegation_name = fuzzy.FuzzyText(length=10, prefix="ifrc-head-")
ifrc_head_of_delegation_email = factory.LazyAttribute(lambda obj: f"{obj.ifrc_head_of_delegation_name.lower()}@example.com")

@factory.post_generation
def key_actors(self, create, extracted, **kwargs):
Expand Down
105 changes: 105 additions & 0 deletions eap/migrations/0006_remove_eapregistration_pending_pfa_at_and_more.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# Generated by Django 5.2.14 on 2026-07-24 04:49

from django.db import migrations, models
from django.db.models import F
from django.db.models.functions import Abs


def backfill_partner_from_national_society(apps, schema_editor):
"""
Preserve the old FK's name instead of dropping it once national_society is removed.
"""
KeyActor = apps.get_model("eap", "KeyActor")
for key_actor in KeyActor.objects.select_related("national_society").iterator():
key_actor.partner = key_actor.national_society.society_name
key_actor.save(update_fields=["partner"])


def clamp_negative_values_to_zero(apps, schema_editor):
"""
PositiveField adds a DB-level `>= 0` CHECK constraint on PostgreSQL;
existing negative rows would make the AlterField operations in the next
migration fail.
"""
PlannedOperation = apps.get_model("eap", "PlannedOperation")
SimplifiedEAP = apps.get_model("eap", "SimplifiedEAP")
FullEAP = apps.get_model("eap", "FullEAP")

PlannedOperation.objects.update(people_targeted=Abs(F("people_targeted")), budget_per_sector=Abs(F("budget_per_sector")))

for Model in (SimplifiedEAP, FullEAP):
Model.objects.update(
people_targeted=Abs(F("people_targeted")),
total_budget=Abs(F("total_budget")),
readiness_budget=Abs(F("readiness_budget")),
pre_positioning_budget=Abs(F("pre_positioning_budget")),
early_action_budget=Abs(F("early_action_budget")),
)


class Migration(migrations.Migration):

dependencies = [
('eap', '0005_remove_fulleap_unique_full_eap_version_and_more'),
]

operations = [
migrations.RenameField(
model_name='eapregistration',
old_name='approved_at',
new_name='project_agreement_signed_at',
),
migrations.RenameField(
model_name='eapregistration',
old_name='pending_pfa_at',
new_name='approved_at',
),
migrations.AlterField(
model_name='eapregistration',
name='project_agreement_signed_at',
field=models.DateTimeField(blank=True, help_text='Timestamp when the project agreement was signed.', null=True, verbose_name='project agreement signed at'),
),
migrations.AlterField(
model_name='eapregistration',
name='approved_at',
field=models.DateTimeField(blank=True, help_text='Timestamp when the EAP was approved.', null=True, verbose_name='approved at'),
),
migrations.AddField(
model_name='keyactor',
name='partner',
field=models.CharField(default='', help_text='Name of the partner organization or entity.', max_length=255, verbose_name='Partner'),
preserve_default=False,
),
migrations.AddField(
model_name='eapregistration',
name='disaster_sub_type',
field=models.CharField(blank=True, max_length=255, null=True, verbose_name='Disaster Sub Type'),
),
migrations.AddField(
model_name='fulleap',
name='include_rcrc_climate_center',
field=models.BooleanField(default=False, verbose_name='Include RCRC Climate Center.'),
),
migrations.AddField(
model_name='simplifiedeap',
name='include_rcrc_climate_center',
field=models.BooleanField(default=False, verbose_name='Include RCRC Climate Center.'),
),
migrations.AlterField(
model_name='eapregistration',
name='status',
field=models.IntegerField(choices=[(10, 'Under Development'), (20, 'Under Review'), (30, 'NS Addressing Comments'), (40, 'Technically validated by VC'), (50, 'Approved'), (60, 'Project Agreement Signed')], default=10, help_text='Select the current status of the EAP development process.', verbose_name='EAP Status'),
),
migrations.AddField(
model_name='operationactivity',
name='activation_one',
field=models.BooleanField(blank=True, null=True, verbose_name='Activation 1'),
),
migrations.AddField(
model_name='operationactivity',
name='activation_two',
field=models.BooleanField(blank=True, null=True, verbose_name='Activation 2'),
),
migrations.RunPython(backfill_partner_from_national_society, migrations.RunPython.noop),
migrations.RunPython(clamp_negative_values_to_zero, migrations.RunPython.noop),
]
Loading