From 7906e3de7feefb709f63bf4a8329a27fa0aa9444 Mon Sep 17 00:00:00 2001 From: Sushil Tiwari Date: Fri, 19 Dec 2025 10:01:52 +0545 Subject: [PATCH] chore(fulleap): Remove fields from fulleap model --- assets | 2 +- eap/factories.py | 28 +++- ..._remove_fulleap_seap_timeframe_and_more.py | 140 ++++++++++++++++++ eap/models.py | 37 ++--- eap/serializers.py | 15 +- eap/test_views.py | 16 +- 6 files changed, 202 insertions(+), 36 deletions(-) create mode 100644 eap/migrations/0012_remove_fulleap_seap_timeframe_and_more.py diff --git a/assets b/assets index 1057847ee..c2ef12ccd 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 1057847ee145f36774c8c9216751e4268d02167e +Subproject commit c2ef12ccd2a0440e448310352dd8625bb1987cb4 diff --git a/eap/factories.py b/eap/factories.py index 90f3dd1f3..4459fb6bd 100644 --- a/eap/factories.py +++ b/eap/factories.py @@ -49,6 +49,8 @@ class Meta: status = fuzzy.FuzzyChoice(EAPStatus) eap_type = fuzzy.FuzzyChoice(EAPType) + national_society_contact_name = fuzzy.FuzzyText(length=10, prefix="NS-") + national_society_contact_email = factory.LazyAttribute(lambda obj: f"{obj.national_society_contact_name.lower()}@example.com") @factory.post_generation def partners(self, create, extracted, **kwargs): @@ -73,6 +75,14 @@ class Meta: seap_lead_timeframe_unit = fuzzy.FuzzyInteger(TimeFrame.MONTHS) seap_lead_time = fuzzy.FuzzyInteger(1, 12) operational_timeframe = fuzzy.FuzzyInteger(1, 12) + national_society_contact_name = fuzzy.FuzzyText(length=10, prefix="NS-") + 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 enable_approaches(self, create, extracted, **kwargs): @@ -185,7 +195,6 @@ class FullEAPFactory(factory.django.DjangoModelFactory): class Meta: model = FullEAP - seap_timeframe = fuzzy.FuzzyInteger(5) expected_submission_time = fuzzy.FuzzyDateTime(datetime(2025, 1, 1, tzinfo=pytz.utc)) lead_time = fuzzy.FuzzyInteger(1, 100) total_budget = fuzzy.FuzzyInteger(1000, 1000000) @@ -193,3 +202,20 @@ class Meta: pre_positioning_budget = fuzzy.FuzzyInteger(1000, 1000000) early_action_budget = fuzzy.FuzzyInteger(1000, 1000000) people_targeted = fuzzy.FuzzyInteger(100, 100000) + national_society_contact_name = fuzzy.FuzzyText(length=10, prefix="NS-") + 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): + if not create: + return + + if extracted: + for actor in extracted: + self.key_actors.add(actor) diff --git a/eap/migrations/0012_remove_fulleap_seap_timeframe_and_more.py b/eap/migrations/0012_remove_fulleap_seap_timeframe_and_more.py new file mode 100644 index 000000000..57ff54f65 --- /dev/null +++ b/eap/migrations/0012_remove_fulleap_seap_timeframe_and_more.py @@ -0,0 +1,140 @@ +# Generated by Django 4.2.26 on 2025-12-19 04:02 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ("eap", "0011_alter_fulleap_updated_checklist_file_and_more"), + ] + + operations = [ + migrations.RemoveField( + model_name="fulleap", + name="seap_timeframe", + ), + migrations.RemoveField( + model_name="fulleap", + name="selection_area", + ), + migrations.AlterField( + model_name="fulleap", + name="ifrc_delegation_focal_point_email", + field=models.CharField( + default="test@gmail.com", + max_length=255, + verbose_name="IFRC delegation focal point email", + ), + preserve_default=False, + ), + migrations.AlterField( + model_name="fulleap", + name="ifrc_delegation_focal_point_name", + field=models.CharField( + default="test", + max_length=255, + verbose_name="IFRC delegation focal point name", + ), + preserve_default=False, + ), + migrations.AlterField( + model_name="fulleap", + name="ifrc_head_of_delegation_email", + field=models.CharField( + default="test@gmail.com", + max_length=255, + verbose_name="IFRC head of delegation email", + ), + preserve_default=False, + ), + migrations.AlterField( + model_name="fulleap", + name="ifrc_head_of_delegation_name", + field=models.CharField( + default="test", + max_length=255, + verbose_name="IFRC head of delegation name", + ), + preserve_default=False, + ), + migrations.AlterField( + model_name="fulleap", + name="national_society_contact_email", + field=models.CharField( + default="test@gmail.com", + max_length=255, + verbose_name="national society contact email", + ), + preserve_default=False, + ), + migrations.AlterField( + model_name="fulleap", + name="national_society_contact_name", + field=models.CharField( + default="test", + max_length=255, + verbose_name="national society contact name", + ), + preserve_default=False, + ), + migrations.AlterField( + model_name="simplifiedeap", + name="ifrc_delegation_focal_point_email", + field=models.CharField( + default="test@gmail.com", + max_length=255, + verbose_name="IFRC delegation focal point email", + ), + preserve_default=False, + ), + migrations.AlterField( + model_name="simplifiedeap", + name="ifrc_delegation_focal_point_name", + field=models.CharField( + default="test", + max_length=255, + verbose_name="IFRC delegation focal point name", + ), + preserve_default=False, + ), + migrations.AlterField( + model_name="simplifiedeap", + name="ifrc_head_of_delegation_email", + field=models.CharField( + default="test@gmail.com", + max_length=255, + verbose_name="IFRC head of delegation email", + ), + preserve_default=False, + ), + migrations.AlterField( + model_name="simplifiedeap", + name="ifrc_head_of_delegation_name", + field=models.CharField( + default="test", + max_length=255, + verbose_name="IFRC head of delegation name", + ), + preserve_default=False, + ), + migrations.AlterField( + model_name="simplifiedeap", + name="national_society_contact_email", + field=models.CharField( + default="test@gmail.com", + max_length=255, + verbose_name="national society contact email", + ), + preserve_default=False, + ), + migrations.AlterField( + model_name="simplifiedeap", + name="national_society_contact_name", + field=models.CharField( + default="test", + max_length=255, + verbose_name="national society contact name", + ), + preserve_default=False, + ), + ] diff --git a/eap/models.py b/eap/models.py index a4ca0454f..403e260da 100644 --- a/eap/models.py +++ b/eap/models.py @@ -749,11 +749,6 @@ class CommonEAPFields(models.Model): related_name="+", ) - seap_timeframe = models.IntegerField( - verbose_name=_("Timeframe (Years) of the EAP"), - help_text=_("Timeframe of the EAP in years."), - ) - admin2 = models.ManyToManyField( Admin2, verbose_name=_("admin"), @@ -768,13 +763,15 @@ class CommonEAPFields(models.Model): # Contacts # National Society national_society_contact_name = models.CharField( - verbose_name=_("national society contact name"), max_length=255, null=True, blank=True + verbose_name=_("national society contact name"), + max_length=255, ) national_society_contact_title = models.CharField( verbose_name=_("national society contact title"), max_length=255, null=True, blank=True ) national_society_contact_email = models.CharField( - verbose_name=_("national society contact email"), max_length=255, null=True, blank=True + verbose_name=_("national society contact email"), + max_length=255, ) national_society_contact_phone_number = models.CharField( verbose_name=_("national society contact phone number"), max_length=100, null=True, blank=True @@ -787,12 +784,8 @@ class CommonEAPFields(models.Model): partner_ns_phone_number = models.CharField(verbose_name=_("Partner NS phone number"), max_length=100, null=True, blank=True) # Delegations - ifrc_delegation_focal_point_name = models.CharField( - verbose_name=_("IFRC delegation focal point name"), max_length=255, null=True, blank=True - ) - ifrc_delegation_focal_point_email = models.CharField( - verbose_name=_("IFRC delegation focal point email"), max_length=255, null=True, blank=True - ) + ifrc_delegation_focal_point_name = models.CharField(verbose_name=_("IFRC delegation focal point name"), max_length=255) + ifrc_delegation_focal_point_email = models.CharField(verbose_name=_("IFRC delegation focal point email"), max_length=255) ifrc_delegation_focal_point_title = models.CharField( verbose_name=_("IFRC delegation focal point title"), max_length=255, null=True, blank=True ) @@ -800,12 +793,8 @@ class CommonEAPFields(models.Model): verbose_name=_("IFRC delegation focal point phone number"), max_length=100, null=True, blank=True ) - ifrc_head_of_delegation_name = models.CharField( - verbose_name=_("IFRC head of delegation name"), max_length=255, null=True, blank=True - ) - ifrc_head_of_delegation_email = models.CharField( - verbose_name=_("IFRC head of delegation email"), max_length=255, null=True, blank=True - ) + ifrc_head_of_delegation_name = models.CharField(verbose_name=_("IFRC head of delegation name"), max_length=255) + ifrc_head_of_delegation_email = models.CharField(verbose_name=_("IFRC head of delegation email"), max_length=255) ifrc_head_of_delegation_title = models.CharField( verbose_name=_("IFRC head of delegation title"), max_length=255, null=True, blank=True ) @@ -926,6 +915,11 @@ class SimplifiedEAP(EAPBaseModel, CommonEAPFields): related_name="simplified_eap", ) + seap_timeframe = models.IntegerField( + verbose_name=_("Timeframe (Years) of the EAP"), + help_text=_("Timeframe of the EAP in years."), + ) + # RISK ANALYSIS and EARLY ACTION SELECTION # # RISK ANALYSIS # @@ -1284,11 +1278,6 @@ class FullEAP(EAPBaseModel, CommonEAPFields): blank=True, ) - selection_area = models.TextField( - verbose_name=_("Areas selection rationale"), - help_text=_("Add description for the selection of the areas."), - ) - trigger_model_relevant_files = models.ManyToManyField( EAPFile, blank=True, diff --git a/eap/serializers.py b/eap/serializers.py index 2ee1889ca..01a9b5b89 100644 --- a/eap/serializers.py +++ b/eap/serializers.py @@ -115,7 +115,6 @@ class Meta: "readiness_budget", "pre_positioning_budget", "early_action_budget", - "seap_timeframe", "budget_file", "version", "is_locked", @@ -448,8 +447,8 @@ class SimplifiedEAPSerializer( # FILES hazard_impact_images = EAPFileUpdateSerializer(required=False, many=True) - selected_early_actions_images = EAPFileUpdateSerializer(required=False, many=True) - risk_selected_protocols_images = EAPFileUpdateSerializer(required=False, many=True) + selected_early_actions_images = EAPFileUpdateSerializer(required=False, many=True, allow_null=True) + risk_selected_protocols_images = EAPFileUpdateSerializer(required=False, many=True, allow_null=True) # TimeFrame seap_lead_timeframe_unit_display = serializers.CharField(source="get_seap_lead_timeframe_unit_display", read_only=True) @@ -570,11 +569,11 @@ class FullEAPSerializer( prioritized_impacts = ImpactSerializer(many=True, required=False) # SOURCE OF INFORMATIONS - risk_analysis_source_of_information = EAPSourceInformationSerializer(many=True, required=False) - trigger_statement_source_of_information = EAPSourceInformationSerializer(many=True, required=False) - trigger_model_source_of_information = EAPSourceInformationSerializer(many=True, required=False) - evidence_base_source_of_information = EAPSourceInformationSerializer(many=True, required=False) - activation_process_source_of_information = EAPSourceInformationSerializer(many=True, required=False) + risk_analysis_source_of_information = EAPSourceInformationSerializer(many=True, required=False, allow_null=True) + trigger_statement_source_of_information = EAPSourceInformationSerializer(many=True, required=False, allow_null=True) + trigger_model_source_of_information = EAPSourceInformationSerializer(many=True, required=False, allow_null=True) + evidence_base_source_of_information = EAPSourceInformationSerializer(many=True, required=False, allow_null=True) + activation_process_source_of_information = EAPSourceInformationSerializer(many=True, required=False, allow_null=True) # IMAGES hazard_selection_images = EAPFileUpdateSerializer( diff --git a/eap/test_views.py b/eap/test_views.py index ab9994938..639cc6dbf 100644 --- a/eap/test_views.py +++ b/eap/test_views.py @@ -131,6 +131,8 @@ def test_create_eap_registration(self): "disaster_type": self.disaster_type.id, "expected_submission_time": "2024-12-31", "partners": [self.partner1.id, self.partner2.id], + "national_society_contact_name": "National society contact name", + "national_society_contact_email": "test@example.com", } self.authenticate(self.country_admin) @@ -464,6 +466,12 @@ def test_create_simplified_eap(self): data = { "eap_registration": eap_registration.id, + "national_society_contact_name": "National society contact name", + "national_society_contact_email": "test@example.com", + "ifrc_delegation_focal_point_name": "IFRC delegation focal point name", + "ifrc_delegation_focal_point_email": "test_ifrc@example.com", + "ifrc_head_of_delegation_name": "IFRC head of delegation name", + "ifrc_head_of_delegation_email": "ifrc_head@example.com", "prioritized_hazard_and_impact": "Floods with potential heavy impact.", "risks_selected_protocols": "Protocol A and Protocol B.", "selected_early_actions": "The early actions selected.", @@ -1875,6 +1883,12 @@ def test_create_full_eap(self): data = { "eap_registration": eap_registration.id, + "national_society_contact_name": "National society contact name", + "national_society_contact_email": "test@example.com", + "ifrc_delegation_focal_point_name": "IFRC delegation focal point name", + "ifrc_delegation_focal_point_email": "test_ifrc@example.com", + "ifrc_head_of_delegation_name": "IFRC head of delegation name", + "ifrc_head_of_delegation_email": "ifrc_head@example.com", "budget_file": budget_file_instance.id, "forecast_table_file": forecast_table_file.id, "hazard_selection_images": [ @@ -1918,7 +1932,6 @@ def test_create_full_eap(self): "objective": "FUll eap objective", "lead_time": 5, "expected_submission_time": "2024-12-31", - "seap_timeframe": 5, "readiness_budget": 3000, "pre_positioning_budget": 4000, "early_action_budget": 3000, @@ -1945,7 +1958,6 @@ def test_create_full_eap(self): "forecast_selection": "Rainfall forecast", "definition_and_justification_impact_level": "Definition and justification of impact levels", "identification_of_the_intervention_area": "Identification of the intervention areas", - "selection_area": "Selection of the area", "early_action_selection_process": "Early action selection process", "evidence_base": "Evidence base", "usefulness_of_actions": "Usefulness of actions",