Skip to content

Commit

Permalink
Merge pull request #1655 from DemocracyClub/feature/party_nations
Browse files Browse the repository at this point in the history
Feature/party nations
  • Loading branch information
Bekabyx authored Jul 20, 2023
2 parents 867173d + 20388c2 commit 6059f98
Show file tree
Hide file tree
Showing 6 changed files with 147 additions and 44 deletions.
94 changes: 56 additions & 38 deletions locale/cy/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-06-16 12:53+0100\n"
"POT-Creation-Date: 2023-07-14 11:40+0100\n"
"PO-Revision-Date: 2022-03-24 09:04+0000\n"
"Last-Translator: Sym Roe <sym@talusdesign.co.uk>, 2022\n"
"Language-Team: Welsh (https://www.transifex.com/democracy-club/teams/61326/"
Expand All @@ -29,21 +29,21 @@ msgstr ""
msgid "Enter your postcode"
msgstr "Rhowch eich cod post"

#: wcivf/apps/elections/models.py:655
#: wcivf/apps/elections/models.py:659
msgid "First-past-the-post"
msgstr "Y Cyntaf i’r Felin"

#: wcivf/apps/elections/models.py:657
#: wcivf/apps/elections/models.py:661
#, fuzzy
#| msgid "The Additional Member System"
msgid "Additional Member System"
msgstr "Y System Aelodau Ychwanegol"

#: wcivf/apps/elections/models.py:659
#: wcivf/apps/elections/models.py:663
msgid "Supplementary Vote"
msgstr "Pleidlais Atodol"

#: wcivf/apps/elections/models.py:661
#: wcivf/apps/elections/models.py:665
msgid "Single Transferable Vote"
msgstr "Pleidlais Sengl Drosglwyddadwy"

Expand Down Expand Up @@ -74,7 +74,7 @@ msgid ""
msgstr ""
"Bydd yr etholiad hwn yn cael ei gynnal <strong>%(election_date)s</strong>"

#: wcivf/apps/elections/templates/elections/election_view.html:40
#: wcivf/apps/elections/templates/elections/election_view.html:39
#, python-format
msgid ""
"%(stood_or_standing)s for this election, in <strong>%(post_count)s</strong> "
Expand All @@ -83,21 +83,21 @@ msgstr ""
"Ymgeisiodd%(stood_or_standing)s yn yr etholiad hwn, mewn "
"<strong>%(post_count)s</strong> swydd."

#: wcivf/apps/elections/templates/elections/election_view.html:46
#: wcivf/apps/elections/templates/elections/election_view.html:45
msgid "Add more at our candidate crowd-sourcing site"
msgstr "Ychwanegwch ragor ar ein gwefan torfoli ymgeiswyr"

#: wcivf/apps/elections/templates/elections/election_view.html:51
#: wcivf/apps/elections/templates/elections/election_view.html:50
msgid "Add some candidates at our candidate crowd-sourcing site"
msgstr "Ychwanegwch rai ymgeiswyr at ein gwefan torfoli ymgeiswyr"

#: wcivf/apps/elections/templates/elections/election_view.html:55
#: wcivf/apps/elections/templates/elections/election_view.html:54
#, fuzzy, python-format
#| msgid " %(title)s"
msgid "%(title)s"
msgstr " %(title)s"

#: wcivf/apps/elections/templates/elections/election_view.html:59
#: wcivf/apps/elections/templates/elections/election_view.html:58
#, python-format
msgid ""
"<a href=\"%(postelection_url)s\">%(post_label)s</a> %(cancelled_message)s"
Expand Down Expand Up @@ -239,7 +239,9 @@ msgid "Elections"
msgstr "Etholiadau"

#: wcivf/apps/elections/templates/elections/includes/_how-to-vote.html:17
msgid "How you vote"
#, fuzzy
#| msgid "How you vote"
msgid "How to vote"
msgstr "Sut i bleidleisio"

#: wcivf/apps/elections/templates/elections/includes/_how-to-vote.html:20
Expand Down Expand Up @@ -1185,92 +1187,104 @@ msgid ""
"field candidates. "
msgstr ""

#: wcivf/apps/parties/templates/parties/party_detail.html:68
#: wcivf/apps/parties/templates/parties/party_detail.html:69
#, fuzzy, python-format
#| msgid "This election was held <strong>%(election_date)s</strong>."
msgid ""
"<p>This party %(was_is)s on the <strong>%(register)s</strong> register and "
"%(was_is)s registered to stand candidates in <strong>%(nations)s</strong>.</"
"p>"
msgstr "Cynhaliwyd yr etholiad hwn <strong>%(election_date)s</strong>"

#: wcivf/apps/parties/templates/parties/party_detail.html:73
#, fuzzy, python-format
#| msgid "This election was held <strong>%(election_date)s</strong>."
msgid ""
"<p>This party %(was_is)s on the <strong>%(register)s</strong> register.</p>"
msgstr "Cynhaliwyd yr etholiad hwn <strong>%(election_date)s</strong>"

#: wcivf/apps/parties/templates/parties/party_detail.html:79
#: wcivf/apps/parties/templates/parties/party_detail.html:85
#, fuzzy
#| msgid " %(description)s "
msgid "Joint description"
msgstr " %(description)s "

#: wcivf/apps/parties/templates/parties/party_detail.html:82
#: wcivf/apps/parties/templates/parties/party_detail.html:88
#, fuzzy, python-format
#| msgid ""
#| "\n"
#| " %(num_votes)s votes (elected)\n"
msgid ""
"\n"
" \"%(joint_name)s\" is a joint description of "
"the %(first_name)s and the %(second_name)s.\n"
"%(first_name)s and %(second_name)s.\n"
" "
msgstr ""
"\n"
" %(num_votes)s pleidlais (etholwyd)\n"

#: wcivf/apps/parties/templates/parties/party_detail.html:91
#: wcivf/apps/parties/templates/parties/party_detail.html:97
#, python-format
msgid ""
"View the entry for the %(party_name)s in the register of political parties."
msgstr ""

#: wcivf/apps/parties/templates/parties/party_detail.html:101
#: wcivf/apps/parties/templates/parties/party_detail.html:107
msgid "View this party's entry in the register of political parties."
msgstr ""

#: wcivf/apps/parties/templates/parties/party_detail.html:108
#: wcivf/apps/parties/templates/parties/party_detail.html:114
#, fuzzy
#| msgid " %(description)s "
msgid "Ballot descriptions"
msgstr " %(description)s "

#: wcivf/apps/parties/templates/parties/party_detail.html:110
#: wcivf/apps/parties/templates/parties/party_detail.html:116
#, python-format
msgid ""
"This party may appear on the ballot paper as \"%(ballot_name)s\", or any of "
"the following names:"
msgstr ""

#: wcivf/apps/parties/templates/parties/party_detail.html:122
msgid "This party currently has no alternative descriptions."
#: wcivf/apps/parties/templates/parties/party_detail.html:128
msgid ""
"This party currently has no descriptions registered with the Electoral "
"Commission."
msgstr ""

#: wcivf/apps/parties/templates/parties/party_detail.html:129
#: wcivf/apps/parties/templates/parties/party_detail.html:135
#, fuzzy
#| msgid " %(description)s "
msgid "Previous Descriptions"
msgstr " %(description)s "

#: wcivf/apps/parties/templates/parties/party_detail.html:131
#: wcivf/apps/parties/templates/parties/party_detail.html:137
msgid ""
"These descriptions are no longer registered with the Electoral Commission "
"and cannot be used."
"and cannot be used:"
msgstr ""

#: wcivf/apps/parties/templates/parties/party_detail.html:144
#: wcivf/apps/parties/templates/parties/party_detail.html:149
#, fuzzy
#| msgid "emblem"
msgid "Emblems"
msgstr "symbol"

#: wcivf/apps/parties/templates/parties/party_detail.html:154
msgid "This party currently has no alternative emblems."
#: wcivf/apps/parties/templates/parties/party_detail.html:159
msgid ""
"This party currently has no emblems registered with the Electoral Commission."
msgstr ""

#: wcivf/apps/parties/templates/parties/party_detail.html:161
#: wcivf/apps/parties/templates/parties/party_detail.html:166
#, fuzzy
#| msgid "emblem"
msgid "Previous Emblems"
msgstr "symbol"

#: wcivf/apps/parties/templates/parties/party_detail.html:163
#: wcivf/apps/parties/templates/parties/party_detail.html:168
msgid ""
"These emblems are no longer registered with the Electoral Commission and "
"cannot be used."
"cannot be used:"
msgstr ""

#: wcivf/apps/parties/templates/parties/party_list.html:4
Expand Down Expand Up @@ -1350,38 +1364,38 @@ msgid ""
"\">their role in elections</a> on the parliament.uk website."
msgstr ""

#: wcivf/apps/people/models.py:75
#: wcivf/apps/people/models.py:76
msgid "Elected unopposed"
msgstr "Wedi'i ethol yn ddiwrthwynebiad."

#: wcivf/apps/people/models.py:76
#: wcivf/apps/people/models.py:77
#, fuzzy
#| msgid "This election was cancelled."
msgid "(election cancelled)"
msgstr "Canslwyd yr etholiad hwn."

#: wcivf/apps/people/models.py:87
#: wcivf/apps/people/models.py:88
#, python-format
msgid "(Results due after %(date)s)"
msgstr ""

#: wcivf/apps/people/models.py:99
#: wcivf/apps/people/models.py:100
#, fuzzy, python-format
#| msgid "%(num_votes)s votes"
msgid "%(num_votes)s votes (elected)"
msgstr "%(num_votes)s pleidlais"

#: wcivf/apps/people/models.py:102
#: wcivf/apps/people/models.py:103
msgid "Elected (vote count not available)"
msgstr "Nid yw'r cyfrif pleidleisiau ar gael"

#: wcivf/apps/people/models.py:108
#: wcivf/apps/people/models.py:109
#, fuzzy, python-format
#| msgid "%(num_votes)s votes"
msgid "%(num_votes)s votes (not elected)"
msgstr "%(num_votes)s pleidlais"

#: wcivf/apps/people/models.py:111
#: wcivf/apps/people/models.py:112
#, fuzzy
#| msgid "Not Elected (vote count not available)"
msgid "Not elected (vote count not available)"
Expand Down Expand Up @@ -1777,7 +1791,11 @@ msgstr "Canlyniadau"
msgid "Other party affiliations in the past 12 months"
msgstr ""

#: wcivf/apps/people/templates/people/includes/_person_previous_elections_card.html:24
#: wcivf/apps/people/templates/people/includes/_person_previous_elections_card.html:19
msgid "Position"
msgstr ""

#: wcivf/apps/people/templates/people/includes/_person_previous_elections_card.html:25
#, python-format
msgid "%(post_label)s: %(election)s"
msgstr "%(post_label)s: %(election)s"
Expand Down
25 changes: 25 additions & 0 deletions wcivf/apps/parties/migrations/0021_party_nations.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Generated by Django 4.1.6 on 2023-07-14 13:06

import django.contrib.postgres.fields
from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("parties", "0020_party_alternative_name"),
]

operations = [
migrations.AddField(
model_name="party",
name="nations",
field=django.contrib.postgres.fields.ArrayField(
base_field=models.CharField(max_length=3),
help_text='\n Some subset of ["ENG", "SCO", "WAL"],\n depending on where the party fields candidates. \n Nullable as not applicable to NI-based parties.\n ',
max_length=3,
null=True,
size=None,
verbose_name="Party nations",
),
),
]
35 changes: 35 additions & 0 deletions wcivf/apps/parties/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from django.utils import timezone
from django.utils.text import slugify
from django.utils.translation import get_language
from django.contrib.postgres.fields import ArrayField
from model_utils.models import TimeStampedModel

from elections.models import Election
Expand All @@ -18,6 +19,7 @@ def update_or_create_from_ynr(self, party):
"date_registered": party["date_registered"],
"date_deregistered": party["date_deregistered"],
"alternative_name": party["alternative_name"],
"nations": party["nations"],
}

if party["default_emblem"]:
Expand Down Expand Up @@ -73,6 +75,17 @@ class Party(models.Model):
],
default="Registered",
)
nations = ArrayField(
models.CharField(max_length=3),
max_length=3,
null=True,
verbose_name="Party nations",
help_text="""
Some subset of ["ENG", "SCO", "WAL"],
depending on where the party fields candidates.
Nullable as not applicable to NI-based parties.
""",
)
date_registered = models.DateField(null=True)
date_deregistered = models.DateField(null=True)

Expand Down Expand Up @@ -169,6 +182,28 @@ def format_register(self):

return None

@property
def format_nations(self):
"""
Returns human text describing which nation(s) a party can field candidates in
"""
if len((self.nations or [])) == 0:
return None

nation_names = {
"ENG": "England",
"SCO": "Scotland",
"WAL": "Wales",
}

if len(self.nations) == 1:
return nation_names[self.nations[0]]

if len(self.nations) == 2:
return f"{nation_names[self.nations[0]]} and {nation_names[self.nations[1]]}"

return "England, Scotland, and Wales"


class PartyDescriptionQuerySet(models.QuerySet):
def active(self):
Expand Down
18 changes: 12 additions & 6 deletions wcivf/apps/parties/templates/parties/party_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,15 @@ <h2>{{ object.format_name }}</h2>
{% endif %}

{% if object.register %}
{% blocktrans trimmed with register=object.format_register was_is=object.is_deregistered|yesno:"was,is" %}
<p>This party {{ was_is }} on the <strong>{{ register }}</strong> register.</p>
{% endblocktrans %}
{% if object.nations %}
{% blocktrans trimmed with register=object.format_register nations=object.format_nations was_is=object.is_deregistered|yesno:"was,is" %}
<p>This party {{ was_is }} on the <strong>{{ register }}</strong> register and {{ was_is }} registered to stand candidates in <strong>{{ nations }}</strong>.</p>
{% endblocktrans %}
{% else %}
{% blocktrans trimmed with register=object.format_register was_is=object.is_deregistered|yesno:"was,is" %}
<p>This party {{ was_is }} on the <strong>{{ register }}</strong> register.</p>
{% endblocktrans %}
{% endif %}
{% endif %}

{% if object.is_joint_party %}
Expand All @@ -80,7 +86,7 @@ <h3>
</h3>
<p>
{% blocktrans with joint_name=object.party_name first_name=sub_parties.0.party_name second_name=sub_parties.1.party_name %}
"{{ joint_name }}" is a joint description of the {{ first_name }} and the {{ second_name }}.
"{{ joint_name }}" is a joint description of {{ first_name }} and {{ second_name }}.
{% endblocktrans %}
</p>
</div>
Expand Down Expand Up @@ -119,7 +125,7 @@ <h3>{% trans "Ballot descriptions" %}</h3>
{% endif %}
</ul>
{% else %}
<p>{% trans "This party currently has no alternative descriptions registered with the Electoral Commission." %}</p>
<p>{% trans "This party currently has no descriptions registered with the Electoral Commission." %}</p>
{% endif %}
{% if object.party_descriptions.inactive %}
<ul class="ds-details">
Expand Down Expand Up @@ -150,7 +156,7 @@ <h3>{% trans "Emblems" %}</h3>
{% endfor %}
</ul>
{% else %}
<p>{% trans "This party currently has no alternative emblems registered with the Electoral Commission." %}</p>
<p>{% trans "This party currently has no emblems registered with the Electoral Commission." %}</p>
{% endif %}
{% if object.emblems.inactive %}
<ul class="ds-details">
Expand Down
Loading

0 comments on commit 6059f98

Please sign in to comment.