-
Notifications
You must be signed in to change notification settings - Fork 1
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
City of London registration info #108
Conversation
show the user correct 'register to vote' information for both - CoL local elections - everywhere else
0857a72
to
2594c7a
Compare
context["htag"] = "h2" | ||
context["htag_primary"] = "h2" | ||
context["htag_secondary"] = "h3" | ||
if self.response_type == ResponseTypes.MULTIPLE_DATES: | ||
context["htag"] = "h3" | ||
context["htag_primary"] = "h3" | ||
context["htag_secondary"] = "h4" |
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.
This was a little issue I fixed while I was here.
Previously if htag
was h3
we'd render the next heading as a h3
too
postcode_lookup/template_sorter.py
Outdated
@@ -162,7 +165,34 @@ def toc_label(self): | |||
|
|||
@property | |||
def toc_id(self): | |||
return "voter-registration" | |||
return f"voter-registration-{self.timetable.registration_deadline}" |
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.
voter-registration
was already not a unique ID, and even less-so now.
I think this should make it unique
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.
I actually realised when I came back to this we need to account for both polling day and the registration deadline to ensure uniqueness
template_name = "includes/registration_timetable_col.html" | ||
|
||
def __init__(self, *args, **kwargs) -> None: | ||
self.with_headers = kwargs.pop("with_headers") |
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.
Basically: If we're showing 2 "register to vote" CTAs, we need a way to say "don't show the headers on the second one"
@@ -199,7 +229,7 @@ def __init__( | |||
|
|||
self.polling_station_opening_times_str = _("7am – 10pm") | |||
if any( | |||
"city-of-london" in ballot.ballot_paper_id | |||
ballot.ballot_paper_id.startswith("local.city-of-london.") | |||
for ballot in self.date_data.ballots | |||
): | |||
self.polling_station_opening_times_str = _("8am – 8pm") |
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.
Declaring this out of scope for this PR 🏃
enabled_sections = [BallotSection] | ||
if not self.all_cancelled: | ||
enabled_sections.append(RegistrationDateSection) | ||
enabled_sections = [BallotSection(**section_kwargs)] |
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.
Previously we were making a list of classes and then constructing them all into objects at the end with the same kwargs.
I've switched to constructing objects as I go. This allows me to pass in custom timetable into each registration section instead of having on global one.
href="#electoral_services">Contact City of London</a> to check if you are on the register.</p> | ||
<p>You can <a href="https://www.speakforthecity.com/">register to vote in the City of London</a> in future elections.</p> | ||
{% endtrans %} | ||
{% endif %} |
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.
I haven't updated any translations in this PR. See #110
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.
Also, all this text is open to change if it needs it. I've mostly used the same text Peter gave me that we used in DemocracyClub/WhoCanIVoteFor#2071
@@ -33,3 +40,46 @@ def uvicorn_server(): | |||
time.sleep(0.3) | |||
yield f"http://localhost:{port}" | |||
proc.kill() | |||
|
|||
|
|||
@pytest.fixture |
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.
Here I am just moving these fixtures into conftest.py
so we can use them in multiple files.
return [s for s in sections if type(s) == type_] | ||
|
||
|
||
@freeze_time("2024-04-16") |
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.
This isn't really enough tests bth, but it is better than a kick in the teeth
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.
Nitpick: I first read this as "column" not "City Of London". Would you mind calling this registration_timetable_city-of-london.html
?
Refs https://app.asana.com/0/1204880927741389/1208540419887296/f
Refs DemocracyClub/WhoCanIVoteFor#2071
City of London has different registration rules to everywhere else in the country.
The point of this PR is to show people the correct "register to vote" information.
The starting point for this PR is that we were showing a register to vote Call To Action against every date. For various reasons, I've stuck with showing the registration info at date level rather than moving it to the ballot. We'll show the gov.uk/register-to-vote CTA at most once per date with upcoming elections and the City of London CTA at most once.
In terms of testing this locally, you can check the various "standard" fixtures continue to work.
I've also added a couple of specific mock data cases for testing City of London with some other ballot.
The really juicy one is 2 ballots on the same day (one City of London, one not).
Within that, there are 3 sub-cases:
Both ballots are before the registration deadline:
http://127.0.0.1:8000/mock/polling-stations?postcode-search=AA1%201AM&baseline_date=2025-12-04
One ballot is before the registration deadline and one is after
http://127.0.0.1:8000/mock/polling-stations?postcode-search=AA1%201AM&baseline_date=2024-11-19
Both ballots after the registration deadline
http://127.0.0.1:8000/mock/polling-stations?postcode-search=AA1%201AM&baseline_date=2024-11-05
I think I've managed to make all 3 work nicely.
side notes:
This PR took a really long time. It probably isn't obvious from the finished code, but I had to try a bunch of stuff that didn't work before finding the thing that did :D
I think one of the things we might need to look at on this codebase is making it easier to pass additional information about individual ballots through to the template layer beyond the exact fields returned by the API. At the moment, if you want to do something like give a ballot an
is_city_london
property, or attach a customtimetable
object to a ballot (for example), you can't do it because:I reckon we might end up wanting a way to pass additional context for an individual ballot, but its more of an extensive refactor.
That isn't really actionable for this review. Just something I hit while I was working on this.