Skip to content

Commit

Permalink
Customise Dummy PostElection
Browse files Browse the repository at this point in the history
  • Loading branch information
VirginiaDooley committed May 23, 2024
1 parent 44ad2f0 commit d262cd3
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 6 deletions.
21 changes: 17 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-07-04"
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, 7, 4),
any_non_by_elections=True,
slug="local.faketown.2022-05-05",
slug="local.faketown.2024-07-04",
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-07-04"
self.election.get_absolute_url = self.election_get_absolute_url

def election_get_absolute_url(self):
Expand All @@ -37,6 +48,8 @@ def people(self):
),
election=self.election,
party_name="Yellow Party",
deselected=True,
deselected_source="www.google.com",
),
DummyCandidacy(
person=DummyPerson(
Expand Down
33 changes: 31 additions & 2 deletions wcivf/apps/elections/views/postcode_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,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 @@ -329,12 +330,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 d262cd3

Please sign in to comment.