From 7c39695b97090d199abddc65a4c3fd4b1c13965a Mon Sep 17 00:00:00 2001 From: Virginia Dooley Date: Tue, 5 Sep 2023 14:17:25 +0100 Subject: [PATCH] Import more data from results --- wcivf/apps/elections/import_helpers.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/wcivf/apps/elections/import_helpers.py b/wcivf/apps/elections/import_helpers.py index f0454a6b8..241702ccc 100644 --- a/wcivf/apps/elections/import_helpers.py +++ b/wcivf/apps/elections/import_helpers.py @@ -103,6 +103,24 @@ def update_or_create_from_ballot_dict(self, ballot_dict): }, ) + if ballot_dict["results"]: + election, created = Election.objects.update_or_create( + slug=slug, + election_type=election_type, + defaults={ + "ballot_papers_issued": ballot_dict["results"][ + "num_turnout_reported" + ], + "electorate": ballot_dict["results"][ + "total_electorate" + ], + "turnout": ballot_dict["results"]["turnout_percentage"], + "spoilt_ballots": ballot_dict["results"][ + "num_spoilt_ballots" + ], + }, + ) + self.import_metadata_from_ee(election) self.election_cache[election.slug] = election return self.election_cache[slug]