Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

POLIO-1760 Remove round_one and round_two from the Campaign API payload #1831

Merged
merged 2 commits into from
Nov 27, 2024
Merged
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
32 changes: 0 additions & 32 deletions plugins/polio/api/campaigns/campaigns.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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",
Expand Down
32 changes: 0 additions & 32 deletions plugins/polio/js/src/constants/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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?',
Expand Down
6 changes: 0 additions & 6 deletions plugins/polio/js/src/constants/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
6 changes: 0 additions & 6 deletions plugins/polio/js/src/constants/translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
14 changes: 0 additions & 14 deletions plugins/polio/models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
35 changes: 13 additions & 22 deletions plugins/polio/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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"],
Expand Down
Loading