diff --git a/plugins/polio/api/campaigns/campaigns.py b/plugins/polio/api/campaigns/campaigns.py index ff709f002a..3066ded8a8 100644 --- a/plugins/polio/api/campaigns/campaigns.py +++ b/plugins/polio/api/campaigns/campaigns.py @@ -129,21 +129,6 @@ class Meta: class CampaignSerializer(serializers.ModelSerializer): - round_one = serializers.SerializerMethodField(read_only=True) - round_two = serializers.SerializerMethodField(read_only=True) - - def get_round_one(self, campaign): - for round in campaign.rounds.all(): - if round.number == 1: - return RoundSerializer(round).data - return None - - def get_round_two(self, campaign): - for round in campaign.rounds.all(): - if round.number == 2: - return RoundSerializer(round).data - return None - rounds = RoundSerializer(many=True, required=False) org_unit: Field = OrgUnitSerializer(source="initial_org_unit", read_only=True) top_level_org_unit_name: Field = serializers.SlugRelatedField(source="country", slug_field="name", read_only=True) @@ -469,21 +454,6 @@ class Meta: class AnonymousCampaignSerializer(CampaignSerializer): rounds = RoundAnonymousSerializer(many=True) - round_one = serializers.SerializerMethodField(read_only=True) - round_two = serializers.SerializerMethodField(read_only=True) - - def get_round_one(self, campaign): - for round in campaign.rounds.all(): - if round.number == 1: - return RoundAnonymousSerializer(round).data - return None - - def get_round_two(self, campaign): - for round in campaign.rounds.all(): - if round.number == 2: - return RoundAnonymousSerializer(round).data - return None - campaign_types = CampaignTypeSerializer(many=True, required=False) class Meta: @@ -522,8 +492,6 @@ class Meta: "unicef_disbursed_to_moh_at", "no_regret_fund_amount", "payment_mode", - "round_one", - "round_two", "rounds", "created_at", "updated_at", diff --git a/plugins/polio/js/src/constants/messages.ts b/plugins/polio/js/src/constants/messages.ts index c58f74982a..68fcfbdfba 100644 --- a/plugins/polio/js/src/constants/messages.ts +++ b/plugins/polio/js/src/constants/messages.ts @@ -409,22 +409,6 @@ const MESSAGES = defineMessages({ id: 'iaso.polio.form.label.disbursedToMohUnicef', defaultMessage: 'Disbursed to MOH (Unicef)', }, - roundOneStart: { - id: 'iaso.polio.form.label.roundOneStart', - defaultMessage: 'Round 1 Start', - }, - roundOneEnd: { - id: 'iaso.polio.form.label.roundOneEnd', - defaultMessage: 'Round 1 End', - }, - roundTwoStart: { - id: 'iaso.polio.form.label.roundtwoStart', - defaultMessage: 'Round 2 Start', - }, - roundTwoEnd: { - id: 'iaso.polio.form.label.roundtwoEnd', - defaultMessage: 'Round 2 End', - }, mop_up_started_at: { id: 'iaso.polio.form.label.mopUpStart', defaultMessage: 'Mop Up Start', @@ -513,22 +497,6 @@ const MESSAGES = defineMessages({ id: 'iaso.polio.title.preparedness', defaultMessage: 'Preparedness', }, - roundOne: { - id: 'iaso.polio.title.roundOne', - defaultMessage: 'Round 1', - }, - round_one: { - id: 'iaso.polio.title.roundOne', - defaultMessage: 'Round 1', - }, - roundTwo: { - id: 'iaso.polio.title.roundTwo', - defaultMessage: 'Round 2', - }, - round_two: { - id: 'iaso.polio.title.roundTwo', - defaultMessage: 'Round 2', - }, deleteWarning: { id: 'iaso.polio.label.deleteWarning', defaultMessage: 'Are you sure you want to delete this campaign?', diff --git a/plugins/polio/js/src/constants/translations/en.json b/plugins/polio/js/src/constants/translations/en.json index 83f1b9f785..1137ed5b88 100644 --- a/plugins/polio/js/src/constants/translations/en.json +++ b/plugins/polio/js/src/constants/translations/en.json @@ -215,11 +215,7 @@ "iaso.polio.form.label.risk_assessment_first_draft_submitted_at": "1st Draft Submission", "iaso.polio.form.label.risk_assessment_rrt_oprtt_approval_at": "RRT/ORPG-Approval", "iaso.polio.form.label.roundNumbers": "Round number(s)", - "iaso.polio.form.label.roundOneEnd": "Round 1 End", - "iaso.polio.form.label.roundOneStart": "Round 1 Start", "iaso.polio.form.label.rounds": "Rounds", - "iaso.polio.form.label.roundtwoEnd": "Round 2 End", - "iaso.polio.form.label.roundtwoStart": "Round 2 Start", "iaso.polio.form.label.rrtOprttApproval": "RRT/ORPG Approval", "iaso.polio.form.label.RRTReview": "RRT review", "iaso.polio.form.label.selectInitialRegion": "Select initial region", @@ -798,8 +794,6 @@ "iaso.polio.title.preparednessGoogleSheetUrl": "Preparedness Google Sheet URL", "iaso.polio.title.refreshPreparednessData": "Refresh Preparedness data", "iaso.polio.title.riskAssessment": "Risk Assessment", - "iaso.polio.title.roundOne": "Round 1", - "iaso.polio.title.roundTwo": "Round 2", "iaso.polio.title.scope": "Scope", "iaso.polio.title.tryUpdateStep": "Resend data?", "iaso.polio.title.vaccinemodule": "Vaccine module", diff --git a/plugins/polio/js/src/constants/translations/fr.json b/plugins/polio/js/src/constants/translations/fr.json index 6bcd31293d..03f462bc53 100644 --- a/plugins/polio/js/src/constants/translations/fr.json +++ b/plugins/polio/js/src/constants/translations/fr.json @@ -214,11 +214,7 @@ "iaso.polio.form.label.risk_assessment_first_draft_submitted_at": "Date de soumission d'une première version", "iaso.polio.form.label.risk_assessment_rrt_oprtt_approval_at": "Date d'approbation du RRT/ORPG", "iaso.polio.form.label.roundNumbers": "Numéro(s) de round", - "iaso.polio.form.label.roundOneEnd": "Date de fin Round 1", - "iaso.polio.form.label.roundOneStart": "Date de début Round 1", "iaso.polio.form.label.rounds": "Rounds", - "iaso.polio.form.label.roundtwoEnd": "Date de fin Round 2", - "iaso.polio.form.label.roundtwoStart": "Date de début Round 2", "iaso.polio.form.label.rrtOprttApproval": "Date d'approbation du RRT/OPRTT", "iaso.polio.form.label.RRTReview": "Review RRT", "iaso.polio.form.label.selectInitialRegion": "Selectionner région initiale", @@ -797,8 +793,6 @@ "iaso.polio.title.preparednessGoogleSheetUrl": "Url de la Google Sheet de préparation", "iaso.polio.title.refreshPreparednessData": "Actualiser les données de préparation de campagne", "iaso.polio.title.riskAssessment": "Evaluation du risque", - "iaso.polio.title.roundOne": "Round 1", - "iaso.polio.title.roundTwo": "Round 2", "iaso.polio.title.scope": "Périmètre", "iaso.polio.title.tryUpdateStep": "Renvoyer les données?", "iaso.polio.title.vaccinemodule": "Module vaccins", diff --git a/plugins/polio/models/base.py b/plugins/polio/models/base.py index 936d8ceb10..68cfc5a672 100644 --- a/plugins/polio/models/base.py +++ b/plugins/polio/models/base.py @@ -767,20 +767,6 @@ def vaccine_names(self): vaccine_names = sorted({scope.vaccine for scope in scopes_with_orgunits_and_vaccine}) return ", ".join(vaccine_names) - def get_round_one(self): - try: - round = self.rounds.get(number=1) - return round - except Round.DoesNotExist: - return None - - def get_round_two(self): - try: - round = self.rounds.get(number=2) - return round - except Round.DoesNotExist: - return None - def update_geojson_field(self): "Update the geojson field on the campaign DO NOT TRIGGER the save() you have to do it manually" campaign = self diff --git a/plugins/polio/tests/test_api.py b/plugins/polio/tests/test_api.py index 6b783a5039..d0c6f72a5c 100644 --- a/plugins/polio/tests/test_api.py +++ b/plugins/polio/tests/test_api.py @@ -259,9 +259,8 @@ def test_create_campaign_with_round_one(self): response = self.client.get(f"/api/polio/campaigns/{c.id}/", payload, format="json") r = self.assertJSONResponse(response, 200) - self.assertNotEqual(r["round_one"], None, r) - self.assertEqual(r["round_one"]["started_at"], "2021-02-01", r) self.assertEqual(len(r["rounds"]), 1) + self.assertEqual(r["rounds"][0]["started_at"], "2021-02-01") def test_create_campaign_with_round_one_and_two(self): self.client.force_authenticate(self.yoda) @@ -295,12 +294,9 @@ def test_create_campaign_with_round_one_and_two(self): self.assertQuerySetEqual(rounds, [1, 2], lambda r: r.number) response = self.client.get(f"/api/polio/campaigns/{c.id}/", format="json") r = self.assertJSONResponse(response, 200) - self.assertNotEqual(r["round_one"], None, r) - # self.assertHasField(r["round_one"], "started_at", r) - self.assertEqual(r["round_one"]["started_at"], "2021-02-01", r) self.assertEqual(len(r["rounds"]), 2) - self.assertNotEqual(r["round_two"], None, r) - self.assertEqual(r["round_two"]["started_at"], "2021-04-01", r) + self.assertEqual(r["rounds"][0]["started_at"], "2021-02-01") + self.assertEqual(r["rounds"][1]["started_at"], "2021-04-01") @skip("Skipping as long as PATCH is disabled for campaigns") def test_patch_campaign(self): @@ -442,14 +438,11 @@ def test_create_campaign_with_scopes(self): # check via the api response = self.client.get(f"/api/polio/campaigns/{c.id}/", format="json") r = self.assertJSONResponse(response, 200) - self.assertNotEqual(r["round_one"], None, r) - # self.assertHasField(r["round_one"], "started_at", r) - self.assertEqual(r["round_one"]["started_at"], "2021-02-01", r) - self.assertEqual(r["round_one"]["districts_count_calculated"], 2, r["round_one"]) self.assertEqual(len(r["rounds"]), 2) - self.assertNotEqual(r["round_two"], None, r) - self.assertEqual(r["round_two"]["started_at"], "2021-04-01", r) - self.assertEqual(r["round_two"]["districts_count_calculated"], 2, r["round_two"]) + self.assertEqual(r["rounds"][0]["started_at"], "2021-02-01") + self.assertEqual(r["rounds"][0]["districts_count_calculated"], 2) + self.assertEqual(r["rounds"][1]["started_at"], "2021-04-01") + self.assertEqual(r["rounds"][1]["districts_count_calculated"], 2) scope_bOPV = c.scopes.get(vaccine="bOPV") scope_mOPV2 = c.scopes.get(vaccine="mOPV2") @@ -516,15 +509,13 @@ def test_create_campaign_with_round_scopes(self): self.assertQuerySetEqual(first_round.scopes.get(vaccine="mOPV2").group.org_units.all(), [self.child_org_unit]) response = self.client.get(f"/api/polio/campaigns/{c.id}/", format="json") r = self.assertJSONResponse(response, 200) - self.assertNotEqual(r["round_one"], None, r) - # self.assertHasField(r["round_one"], "started_at", r) - self.assertEqual(r["round_one"]["started_at"], "2021-02-01", r) - self.assertEqual(r["round_one"]["districts_count_calculated"], 2, r["round_one"]) self.assertEqual(len(r["rounds"]), 2) - self.assertNotEqual(r["round_two"], None, r) - self.assertEqual(r["round_two"]["started_at"], "2021-04-01", r) - self.assertEqual(r["round_two"]["districts_count_calculated"], 0, r["round_two"]) - round_one = list(filter(lambda r: r["number"] == 1, r["rounds"]))[0] + self.assertEqual(r["rounds"][0]["started_at"], "2021-02-01") + self.assertEqual(r["rounds"][0]["districts_count_calculated"], 2) + self.assertEqual(r["rounds"][1]["started_at"], "2021-04-01") + self.assertEqual(r["rounds"][1]["districts_count_calculated"], 0) + + round_one = r["rounds"][0] self.assertEqual( round_one["scopes"],