From a239152f0eca8561b65a4fb338b2c03d657fdd9d 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 | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/wcivf/apps/elections/import_helpers.py b/wcivf/apps/elections/import_helpers.py index f0454a6b8..8c6b42c8d 100644 --- a/wcivf/apps/elections/import_helpers.py +++ b/wcivf/apps/elections/import_helpers.py @@ -103,6 +103,26 @@ 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_ballot_papers" + ], + "electorate": ballot_dict["results"][ + "total_electorate" + ], + "turnout": ballot_dict["results"][ + "num_turnout_reported" + ], + "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]