Skip to content

Commit

Permalink
Update registration with new context
Browse files Browse the repository at this point in the history
-  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
  • Loading branch information
VirginiaDooley committed May 23, 2024
1 parent e18c417 commit 6852af8
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 52 deletions.
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>
Original file line number Diff line number Diff line change
Expand Up @@ -22,43 +22,22 @@ <h2 id='register'>
</p>
{% if postelection %}
<p>
{% blocktrans trimmed with registration_deadline=postelection.registration_deadline election_date=postelection.election.election_date|date:"j M Y" %}
{% blocktrans trimmed with registration_deadline=postelection.registration_deadline|naturalday:"j F Y" election_date=postelection.election.election_date|naturalday:"j F Y" %}
Register before midnight on {{ registration_deadline }} to vote on {{ election_date }}.
{% endblocktrans %}
</p>
<p>
{% if council %}
{% if council.registration_contacts %}
{% blocktrans trimmed %}To register by post, contact your Valuation Joint Board.{% endblocktrans %}
{% else %}
{% blocktrans trimmed with council_name=council.name%}To register by post, contact {{ council_name }}.{% endblocktrans %}
{% endif %}
{% else %}
{% if postelection.post.territory == "SCT" %}
{% blocktrans trimmed %}To register by post, contact your Valuation Joint Board.{% endblocktrans %}
{% else %}
{% blocktrans trimmed%}To register by post, contact your local council.{% endblocktrans %}
{% endif %}
{% endif %}

</p>
{% endif %}
{% if council.council_id %}
<!-- valid only for Scottish postcodes -->
{% if council.registration_contacts %}
{% include "elections/includes/_council_contact_details.html" with contact_details=council.registration_contacts %}

<p>
{% blocktrans trimmed %}
For questions about your poll card, polling place, or about returning your postal voting ballot, contact your council.
{% endblocktrans %}
</p>

<p>
{% blocktrans trimmed %}
For questions about your poll card, polling place, or about returning your postal voting ballot, contact your council.
{% endblocktrans %}
</p>
{% if registration %}
{% include "elections/includes/_council_contact_details.html" with contact_details=registration %}
{% endif %}

{% include "elections/includes/_council_contact_details.html" with contact_details=council.electoral_services_contacts %}


{% include "elections/includes/_council_contact_details.html" with contact_details=council %}
{% endif %}

</details>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
{% endif %}

{% if is_before_registration_deadline %}
{% include "elections/includes/_registration_details.html" with postelection=postelections.first council=polling_station.council %}
{% include "elections/includes/_registration_details.html" with postelection=postelections.0 council=council %}
{% endif %}

{% if not messages %}
Expand Down
1 change: 0 additions & 1 deletion wcivf/apps/elections/tests/test_election_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,6 @@ def test_previous_cancelled_elections(self):
self.post_election.cancelled = True
self.post_election.save()
response = self.client.get(self.person.get_absolute_url(), follow=True)
# import pdb; pdb.set_trace()
self.assertContains(response, "{}'s elections".format(self.person.name))
self.assertContains(response, "(election cancelled")

Expand Down
8 changes: 7 additions & 1 deletion wcivf/apps/elections/views/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,15 @@ def is_before_registration_deadline(self, post_elections):
return False
election = post_elections[0].election
country = post_elections[0].post.territory

if not country:
country = Country.ENGLAND

country = {
"ENG": Country.ENGLAND,
"SCT": Country.SCOTLAND,
"WLS": Country.WALES,
"NIR": Country.NORTHERN_IRELAND,
}.get(country)
election = from_election_id(election_id=election.slug, country=country)
event = TimetableEvent.REGISTRATION_DEADLINE
return election.is_before(event)
Expand Down
8 changes: 6 additions & 2 deletions wcivf/apps/elections/views/postcode_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,16 @@ def get_context_data(self, **kwargs):
context["show_polling_card"] = self.show_polling_card(
context["postelections"]
)
context["is_before_registration_deadline"] = (
self.is_before_registration_deadline(context["postelections"])
)
context["people_for_post"] = {}
for postelection in context["postelections"]:
postelection.people = self.people_for_ballot(postelection)
context["polling_station"] = self.ballot_dict.get("polling_station")
context["council"] = self.ballot_dict.get("electoral_services")
context["registration"] = self.ballot_dict.get("registration")

context["advance_voting_station"] = (
self.get_advance_voting_station_info(context["polling_station"])
)
Expand All @@ -106,7 +110,7 @@ def get_context_data(self, **kwargs):
def future_postelections(self, postelections):
"""
Given a list of postelections, check if any of them are in the future
and return a list of those that are
and return True if so.
"""
return any(
postelection
Expand Down Expand Up @@ -350,7 +354,7 @@ def get_context_data(self, **kwargs):
context["is_before_registration_deadline"] = (
PostcodeView().is_before_registration_deadline(context["postelections"])
)
context["electoral_services"] = self.get_registration()
context["registration"] = self.get_registration()
context["council"] = self.get_electoral_services()
context["requires_voter_id"] = "EA-2022"
context["num_ballots"] = 1
Expand Down

0 comments on commit 6852af8

Please sign in to comment.