-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update registration with new context
- Removes unused code - Updates logic for council v registration given change in context - Reformats registration deadline date - Fixes logic for is_before_registration_deadline - Removes the advice about registering by post - Fixes logic for past_registration_deadline to use datetime comparison
- Loading branch information
1 parent
e18c417
commit a8181a1
Showing
9 changed files
with
159 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 19 additions & 17 deletions
36
wcivf/apps/elections/templates/elections/includes/_council_contact_details.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,20 @@ | ||
<address class="ds-stack-smallest"> | ||
{{ contact_details.name }} | ||
{% if contact_details.address %} | ||
{{ contact_details.address|linebreaksbr }} | ||
{% endif %} | ||
{% if contact_details.postcode %} | ||
<br>{{ contact_details.postcode }} | ||
<br> | ||
{% endif %} | ||
<p> | ||
<address class="ds-stack-smallest"> | ||
{{ contact_details.name }} | ||
{% if contact_details.address %} | ||
{{ contact_details.address|linebreaksbr }} | ||
{% endif %} | ||
{% if contact_details.postcode %} | ||
<br>{{ contact_details.postcode }} | ||
<br> | ||
{% endif %} | ||
|
||
<a href="{{ contact_details.website }}"> | ||
{{ contact_details.website }} | ||
</a> | ||
<br><a href="mailto:{{ contact_details.email }}">{{ contact_details.email }}</a> | ||
{% for number in contact_details.phone_numbers %} | ||
<br><a href="tel:{{ number }}">{{ number }}</a> | ||
{% endfor %} | ||
</address> | ||
<a href="{{ contact_details.website }}"> | ||
{{ contact_details.website }} | ||
</a> | ||
<br><a href="mailto:{{ contact_details.email }}">{{ contact_details.email }}</a> | ||
{% for number in contact_details.phone_numbers %} | ||
<br><a href="tel:{{ number }}">{{ number }}</a> | ||
{% endfor %} | ||
</address> | ||
</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -151,7 +151,12 @@ def mock_response(self, mocker): | |
individual tests can then add json data to | ||
""" | ||
response = mocker.MagicMock(status_code=200) | ||
response.json.return_value = {"address_picker": False, "dates": []} | ||
response.json.return_value = { | ||
"address_picker": False, | ||
"dates": [], | ||
"electoral_services": {}, | ||
"registration": {}, | ||
} | ||
mocker.patch( | ||
"requests.get", | ||
return_value=response, | ||
|
@@ -164,6 +169,7 @@ def test_city_of_london_today(self, mock_response, client): | |
ballot_paper_id="local.city-of-london.aldgate.2021-05-06", | ||
election__slug="local.city-of-london.2021-05-06", | ||
election__election_date="2021-05-06", | ||
post__territory="ENG", | ||
) | ||
|
||
mock_response.json.return_value["dates"].append( | ||
|
@@ -227,24 +233,29 @@ def test_not_today(self, mock_response, client): | |
response, "Polling stations are open from 8a.m. till 8p.m. today" | ||
) | ||
|
||
@pytest.mark.django_db | ||
@freeze_time("2024-05-23") | ||
def test_multiple_elections_london(self, mock_response, client): | ||
"""This test is for the case where there are multiple elections in | ||
London on the same day and we want to make sure that the correct | ||
polling station opening times are displayed for each election | ||
as well as the correct anchor links to the election pages | ||
""" | ||
local_london = PostElectionFactory( | ||
ballot_paper_id="local.city-of-london.aldgate.2021-05-06", | ||
ballot_paper_id="local.city-of-london.aldgate.2024-05-06", | ||
election__slug="local.city-of-london.2024-05-06", | ||
election__election_date="2024-05-06", | ||
election__name="City of London Corporation local election", | ||
) | ||
|
||
parl_london = PostElectionFactory( | ||
ballot_paper_id="parl.cities-of-london-and-westminster.by.2021-05-06", | ||
ballot_paper_id="parl.cities-of-london-and-westminster.by.2024-05-06", | ||
election__slug="parl.2024-05-06", | ||
election__election_date="2024-05-06", | ||
election__name="Cities of London and Westminster by-election", | ||
) | ||
parl_london.is_before_registration_deadline = True | ||
local_london.is_before_registration_deadline = True | ||
|
||
mock_response.json.return_value["dates"].extend( | ||
[ | ||
|
@@ -360,7 +371,11 @@ def test_no_polling_station_shows_council_details( | |
ballot_paper_id="local.sheffield.ecclesall.2021-05-06", | ||
election__slug="local.sheffield.2021-05-06", | ||
election__election_date="2021-05-06", | ||
post__territory="ENG", | ||
) | ||
|
||
local.is_before_registration_deadline = True | ||
|
||
mock_response.json.return_value["dates"].extend( | ||
[ | ||
{ | ||
|
@@ -371,14 +386,100 @@ def test_no_polling_station_shows_council_details( | |
] | ||
) | ||
|
||
mock_response.json.return_value["electoral_services"].update( | ||
{ | ||
"council_id": "W06000015", | ||
"name": "Cardiff Council", | ||
"nation": "Wales", | ||
"address": "Electoral Registration Officer\\nCity of Cardiff Council\\nCounty Hall Atlantic Wharf", | ||
"postcode": "CF10 4UW", | ||
"email": "[email protected]", | ||
"phone": "029 2087 2034", | ||
"website": "http://www.cardiff.gov.uk/", | ||
} | ||
) | ||
|
||
response = client.get( | ||
reverse("postcode_view", kwargs={"postcode": "TE11ST"}), follow=True | ||
reverse( | ||
"postcode_view", | ||
kwargs={ | ||
"postcode": "TE11ST", | ||
}, | ||
), | ||
follow=True, | ||
) | ||
|
||
assert response.status_code == 200 | ||
assert response.context["council"] is not None | ||
|
||
asserts.assertContains( | ||
response, | ||
"Cardiff Council", | ||
) | ||
|
||
def council_and_registration_details_differ(self, mock_response, client): | ||
"""When council contact details are different from | ||
the registration details, show both.""" | ||
local = PostElectionFactory( | ||
ballot_paper_id="local.sheffield.ecclesall.2021-05-06", | ||
election__slug="local.sheffield.2021-05-06", | ||
election__election_date="2021-05-06", | ||
post__territory="ENG", | ||
) | ||
|
||
local.is_before_registration_deadline = True | ||
|
||
mock_response.json.return_value["dates"].extend( | ||
[ | ||
{ | ||
"date": local.election.election_date, | ||
"polling_station": {"polling_station_known": False}, | ||
"ballots": [{"ballot_paper_id": local.ballot_paper_id}], | ||
}, | ||
] | ||
) | ||
|
||
mock_response.json.return_value["electoral_services"].update( | ||
{ | ||
"council_id": "W06000015", | ||
"name": "Cardiff Council", | ||
"nation": "Wales", | ||
"address": "City of Cardiff Council\\nCounty Hall Atlantic Wharf", | ||
"postcode": "CF10 4UW", | ||
"email": "[email protected]", | ||
"phone": "029 2087 2034", | ||
"website": "http://www.cardiff.gov.uk/", | ||
} | ||
) | ||
|
||
mock_response.json.return_value["registration"].update( | ||
{ | ||
"address": "Electoral Registration Officer\\nCity of Cardiff Council\\nCounty Hall Atlantic Wharf", | ||
"postcode": "CF10 4UW", | ||
"email": "[email protected]", | ||
"phone": "029 2087 2034", | ||
"website": "http://www.cardiff.gov.uk/", | ||
} | ||
) | ||
response = client.get( | ||
reverse( | ||
"postcode_view", | ||
kwargs={ | ||
"postcode": "TE11ST", | ||
}, | ||
), | ||
follow=True, | ||
) | ||
|
||
assert response.status_code == 200 | ||
assert response.context["registration"] is not None | ||
|
||
asserts.assertContains( | ||
response, | ||
"""You should get a "poll card" through the post telling you where to vote.""", | ||
"Electoral Registration Officer", | ||
) | ||
asserts.assertContains(response, "[email protected]") | ||
asserts.assertContains(response, "[email protected]") | ||
|
||
|
||
class TestPostcodeViewMethods: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters