From 5c77acc338c010a2fd42aa17eb8bb478b116d342 Mon Sep 17 00:00:00 2001 From: Virginia Dooley Date: Wed, 8 May 2024 14:53:06 +0100 Subject: [PATCH] Temp changes to Dummy PostElection for testing --- wcivf/apps/elections/dummy_models.py | 19 +++++++-- wcivf/apps/elections/views/postcode_view.py | 45 +++++++++++++++++---- 2 files changed, 52 insertions(+), 12 deletions(-) diff --git a/wcivf/apps/elections/dummy_models.py b/wcivf/apps/elections/dummy_models.py index bb2d056d6..3a39d85a2 100644 --- a/wcivf/apps/elections/dummy_models.py +++ b/wcivf/apps/elections/dummy_models.py @@ -1,21 +1,32 @@ from datetime import date from random import randint -from elections.models import Election, Post, PostElection +from elections.models import Election, Post, PostElection, VotingSystem from people.dummy_models import DummyCandidacy, DummyPerson class DummyPostElection(PostElection): party_ballot_count = 5 display_as_party_list = False + locked = True + voting_system_id = "FPTP" + ballot_paper_id = "local.faketown.made-up-ward.2024-05-31" + cancelled = False + show_polling_card = True + contested = True + requires_voter_id = "EA-2022" election = Election( name="Llantalbot local election", - election_date=date(2022, 5, 5), + election_date=date(2024, 5, 31), any_non_by_elections=True, - slug="local.faketown.2022-05-05", + slug="local.faketown.2024-05-31", + voting_system=VotingSystem(slug="FPTP"), + current=True, ) + post = Post(label="Made-Up-Ward") + post.territory = "ENG" pk = randint(1, 100000) class Meta: @@ -23,7 +34,7 @@ class Meta: def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) - self.ballot_paper_id = "local.faketown.made-up-ward.2022-05-05" + self.ballot_paper_id = "local.faketown.made-up-ward.2024-05-31" self.election.get_absolute_url = self.election_get_absolute_url def election_get_absolute_url(self): diff --git a/wcivf/apps/elections/views/postcode_view.py b/wcivf/apps/elections/views/postcode_view.py index f194068c4..c8ea6f91a 100644 --- a/wcivf/apps/elections/views/postcode_view.py +++ b/wcivf/apps/elections/views/postcode_view.py @@ -84,14 +84,14 @@ def get_context_data(self, **kwargs): postelection.people = self.people_for_ballot(postelection) context["polling_station"] = self.ballot_dict.get("polling_station") - context[ - "advance_voting_station" - ] = self.get_advance_voting_station_info(context["polling_station"]) + context["advance_voting_station"] = ( + self.get_advance_voting_station_info(context["polling_station"]) + ) context["ballots_today"] = self.get_todays_ballots() - context[ - "multiple_city_of_london_elections_today" - ] = self.multiple_city_of_london_elections_today() + context["multiple_city_of_london_elections_today"] = ( + self.multiple_city_of_london_elections_today() + ) context["referendums"] = list(self.get_referendums()) context["parish_council_election"] = self.get_parish_council_election() context["num_ballots"] = self.num_ballots() @@ -310,6 +310,7 @@ def get(self, request, *args, **kwargs): class DummyPostcodeView(PostcodeView): postcode = None + uprn = None def get(self, request, *args, **kwargs): kwargs["postcode"] = self.postcode @@ -320,12 +321,40 @@ def get_context_data(self, **kwargs): context = kwargs self.postcode = clean_postcode(kwargs["postcode"]) context["postcode"] = self.postcode + self.uprn = self.kwargs.get("uprn") + context["uprn"] = self.uprn + context["postelections"] = self.get_ballot_dict() context["show_polling_card"] = True - context["polling_station"] = {} + context["polling_station"] = self.get_polling_station() + context["requires_voter_id"] = "EA-2022" context["num_ballots"] = 1 - return context def get_ballot_dict(self): return [DummyPostElection()] + + def get_polling_station(self): + return { + "polling_station_known": True, + "custom_finder": False, + "report_problem_url": "http://wheredoivote.co.uk/report_problem/?source=testing&source_url=testing", + "station": { + "id": "w06000015.QK", + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [-3.119229, 51.510885], + }, + "properties": { + "address": "1 Made Up Street\nMade Up Town\nMade Up County", + "postcode": "MA1 1AA", + }, + }, + "geometry": { + "coordinates": [-0.127758, 51.507351], + }, + "properties": { + "address": "1 Made Up Street\nMade Up Town\nMade Up County", + }, + }