-
Notifications
You must be signed in to change notification settings - Fork 1
Contact details only pages #207
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
763124b
df779bc
5d7e901
5e8aa23
3428718
1fc9423
ffd7373
f51f977
b5ab89a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,19 +1,9 @@ | ||
| import os | ||
| from pathlib import Path | ||
|
|
||
| from endpoints import ( | ||
| design_system_view, | ||
| failover, | ||
| live_postcode_form, | ||
| live_postcode_view, | ||
| live_uprn_view, | ||
| mock_postcode_view, | ||
| redirect_root_to_postcode_form, | ||
| sandbox_postcode_form, | ||
| sandbox_postcode_view, | ||
| sandbox_uprn_view, | ||
| section_tester, | ||
| ) | ||
| import endpoints.election_information | ||
| import endpoints.electoral_services_team | ||
| import endpoints.utils | ||
| from mangum import Mangum | ||
| from starlette.applications import Starlette | ||
| from starlette.middleware import Middleware | ||
|
|
@@ -39,109 +29,177 @@ | |
| ], | ||
| ) | ||
|
|
||
| routes = [ | ||
| Route("/", endpoint=redirect_root_to_postcode_form), | ||
| Route("/sections/{section}/", endpoint=section_tester), | ||
| Route("/failover", endpoint=failover, name="failover"), | ||
| util_routes = [ | ||
| Route("/", endpoint=endpoints.utils.redirect_root_to_postcode_form), | ||
| Route("/sections/{section}/", endpoint=endpoints.utils.section_tester), | ||
| Route("/failover", endpoint=endpoints.utils.failover, name="failover"), | ||
| Route( | ||
| "/design-system", | ||
| endpoint=endpoints.utils.design_system_view, | ||
| name="design_system_view", | ||
| ), | ||
| Mount( | ||
| "/themes/", | ||
| app=StaticFiles(directory=Path(__file__).parent / "themes"), | ||
| name="themes", | ||
| ), | ||
| Mount( | ||
| "/static/", | ||
| app=StaticFiles(directory=Path(__file__).parent / "static"), | ||
| name="static", | ||
| ), | ||
| ] | ||
|
|
||
| election_information_routes = [ | ||
| # Live, EN | ||
| Route( | ||
| "/i-am-a/voter/your-election-information", | ||
| endpoint=live_postcode_form, | ||
| endpoint=endpoints.election_information.live_postcode_form, | ||
| name="live_postcode_form_en", | ||
| ), | ||
| Route( | ||
| "/polling-stations/address/{postcode}/{uprn}", | ||
| endpoint=live_uprn_view, | ||
| endpoint=endpoints.election_information.live_uprn_view, | ||
| name="live_uprn_en", | ||
| ), | ||
| Route( | ||
| "/polling-stations", | ||
| endpoint=live_postcode_view, | ||
| endpoint=endpoints.election_information.live_postcode_view, | ||
| name="live_postcode_en", | ||
| ), | ||
| # Live, CY | ||
| Route( | ||
| "/cy/rwyf-yneg-pleidleisiwr/pleidleisiwr/gwybodaeth-etholiad", | ||
| endpoint=live_postcode_form, | ||
| endpoint=endpoints.election_information.live_postcode_form, | ||
| name="live_postcode_form_cy", | ||
| ), | ||
| Route( | ||
| "/cy/polling-stations/{postcode}/{uprn}", | ||
| endpoint=live_uprn_view, | ||
| "/cy/polling-stations/address/{postcode}/{uprn}", | ||
| endpoint=endpoints.election_information.live_uprn_view, | ||
| name="live_uprn_cy", | ||
| ), | ||
| Route( | ||
| "/cy/polling-stations", | ||
| endpoint=live_postcode_view, | ||
| endpoint=endpoints.election_information.live_postcode_view, | ||
| name="live_postcode_cy", | ||
| ), | ||
| # Sandbox | ||
| Route( | ||
| "/sandbox/polling-stations", | ||
| endpoint=sandbox_postcode_view, | ||
| name="sandbox_postcode_en", | ||
| ), | ||
| # Sandbox, EN | ||
| Route( | ||
| "/sandbox/i-am-a/voter/your-election-information", | ||
| endpoint=sandbox_postcode_form, | ||
| endpoint=endpoints.election_information.sandbox_postcode_form, | ||
| name="sandbox_postcode_form_en", | ||
| ), | ||
| Route( | ||
| "/sandbox/cy/i-am-a/voter/your-election-information", | ||
| endpoint=sandbox_postcode_form, | ||
| name="sandbox_postcode_form_cy", | ||
| "/sandbox/polling-stations/address/{postcode}/{uprn}", | ||
| endpoint=endpoints.election_information.sandbox_uprn_view, | ||
| name="sandbox_uprn_en", | ||
| ), | ||
| Route( | ||
| "/cy/sandbox/polling-stations", | ||
| endpoint=sandbox_postcode_view, | ||
| name="sandbox_postcode_cy", | ||
| "/sandbox/polling-stations", | ||
| endpoint=endpoints.election_information.sandbox_postcode_view, | ||
| name="sandbox_postcode_en", | ||
| ), | ||
| # Sandbox, CY | ||
| Route( | ||
| "/sandbox/polling-stations/{postcode}/{uprn}", | ||
| endpoint=sandbox_uprn_view, | ||
| name="sandbox_uprn_en", | ||
| "/cy/sandbox/i-am-a/voter/your-election-information", | ||
| endpoint=endpoints.election_information.sandbox_postcode_form, | ||
| name="sandbox_postcode_form_cy", | ||
| ), | ||
| Route( | ||
| "/cy/sandbox/polling-stations/{postcode}/{uprn}", | ||
| endpoint=sandbox_uprn_view, | ||
| "/cy/sandbox/polling-stations/address/{postcode}/{uprn}", | ||
| endpoint=endpoints.election_information.sandbox_uprn_view, | ||
| name="sandbox_uprn_cy", | ||
| ), | ||
| Route( | ||
| "/cy/sandbox/polling-stations", | ||
| endpoint=endpoints.election_information.sandbox_postcode_view, | ||
| name="sandbox_postcode_cy", | ||
| ), | ||
| # Mock | ||
| Route( | ||
| "/mock/polling-stations", | ||
| endpoint=mock_postcode_view, | ||
| endpoint=endpoints.election_information.mock_postcode_view, | ||
| name="mock_postcode_en", | ||
| ), | ||
| Route( | ||
| "/cy/mock/polling-stations", | ||
| endpoint=mock_postcode_view, | ||
| endpoint=endpoints.election_information.mock_postcode_view, | ||
| name="mock_postcode_cy", | ||
| ), | ||
| ] | ||
|
|
||
| electoral_services_team_routes = [ | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note this PR introduces a bunch more URLs at the root of https://www.electoralcommission.org.uk (which could potentially conflict with URLs in their CMS, or might need CloudFlare changes to make sure the right requests get routed to us). |
||
| # Live, EN | ||
| Route( | ||
| "/i-am-a/voter/electoral-services", | ||
| endpoint=endpoints.electoral_services_team.live_postcode_form, | ||
| name="electoral_services_live_postcode_form_en", | ||
| ), | ||
| Route( | ||
| "/design-system", | ||
| endpoint=design_system_view, | ||
| name="design_system_view", | ||
| "/electoral-services/address/{postcode}/{uprn}", | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The existing site has this surprising behaviour where the UPRN has a
I'd actually argue that this is essentially a bug and we should either
However I have decided to leave the worms inside that can in this PR. What I have actually done in this PR is:
|
||
| endpoint=endpoints.electoral_services_team.live_uprn_view, | ||
| name="electoral_services_live_uprn_en", | ||
| ), | ||
| # Route( | ||
| # "/mock/polling-stations/{postcode}/{uprn}", | ||
| # endpoint=sandbox_uprn_view, | ||
| # name="sandbox_uprn_en", | ||
| # ), | ||
| # Route( | ||
| # "/cy/sandbox/polling-stations/{postcode}/{uprn}", | ||
| # endpoint=sandbox_uprn_view, | ||
| # name="sandbox_uprn_cy", | ||
| # ), | ||
| Mount( | ||
| "/themes/", | ||
| app=StaticFiles(directory=Path(__file__).parent / "themes"), | ||
| name="themes", | ||
| Route( | ||
| "/electoral-services", | ||
| endpoint=endpoints.electoral_services_team.live_postcode_view, | ||
| name="electoral_services_live_postcode_en", | ||
| ), | ||
| Mount( | ||
| "/static/", | ||
| app=StaticFiles(directory=Path(__file__).parent / "static"), | ||
| name="static", | ||
| # Live, CY | ||
| Route( | ||
| "/cy/rwyf-yneg-pleidleisiwr/pleidleisiwr/electoral-services", | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TODO: need a translated slug for |
||
| endpoint=endpoints.electoral_services_team.live_postcode_form, | ||
| name="electoral_services_live_postcode_form_cy", | ||
| ), | ||
| Route( | ||
| "/cy/electoral-services/address/{postcode}/{uprn}", | ||
| endpoint=endpoints.electoral_services_team.live_uprn_view, | ||
| name="electoral_services_live_uprn_cy", | ||
| ), | ||
| Route( | ||
| "/cy/electoral-services", | ||
| endpoint=endpoints.electoral_services_team.live_postcode_view, | ||
| name="electoral_services_live_postcode_cy", | ||
| ), | ||
| # Sandbox, EN | ||
| Route( | ||
| "/sandbox/electoral-services/address/{postcode}/{uprn}", | ||
| endpoint=endpoints.electoral_services_team.sandbox_uprn_view, | ||
| name="electoral_services_sandbox_uprn_en", | ||
| ), | ||
| Route( | ||
| "/sandbox/electoral-services", | ||
| endpoint=endpoints.electoral_services_team.sandbox_postcode_view, | ||
| name="electoral_services_sandbox_postcode_en", | ||
| ), | ||
| # Sandbox, CY | ||
| Route( | ||
| "/cy/sandbox/electoral-services/address/{postcode}/{uprn}", | ||
| endpoint=endpoints.electoral_services_team.sandbox_uprn_view, | ||
| name="electoral_services_sandbox_uprn_cy", | ||
| ), | ||
| Route( | ||
| "/cy/sandbox/electoral-services", | ||
| endpoint=endpoints.electoral_services_team.sandbox_postcode_view, | ||
| name="electoral_services_sandbox_postcode_cy", | ||
| ), | ||
| # Mock | ||
| Route( | ||
| "/mock/electoral-services", | ||
| endpoint=endpoints.electoral_services_team.mock_postcode_view, | ||
| name="electoral_services_mock_postcode_en", | ||
| ), | ||
| Route( | ||
| "/cy/mock/electoral-services", | ||
| endpoint=endpoints.electoral_services_team.mock_postcode_view, | ||
| name="electoral_services_mock_postcode_cy", | ||
| ), | ||
| ] | ||
|
|
||
| routes = ( | ||
| util_routes + election_information_routes + electoral_services_team_routes | ||
| ) | ||
|
|
||
| shared_translator = get_translator() # process global instance | ||
| shared_translator.load_from_directories([Path(__file__).parent / "locale"]) | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Every route needs to have a unique name.
I think if I was starting from scratch today, I would include
election_informationor something in the route names we already have to differentiate the two flavours of postcode form, postcode page, uprn page etc we now have.For now, I've kept the existing names for the "election information" routes. If you want, I can go through and rename all the existing ones. The fiddly bit of this is making sure we've accounted for the renames everywhere we concatenate some string together to make a
url_for()