Skip to content

Commit

Permalink
Temp changes to Dummy PostElection for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
VirginiaDooley committed May 8, 2024
1 parent 9c2f329 commit 5c77acc
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 12 deletions.
19 changes: 15 additions & 4 deletions wcivf/apps/elections/dummy_models.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,40 @@
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:
proxy = True

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):
Expand Down
45 changes: 37 additions & 8 deletions wcivf/apps/elections/views/postcode_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand All @@ -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",
},
}

0 comments on commit 5c77acc

Please sign in to comment.