Skip to content

Commit

Permalink
Add party nations to importer
Browse files Browse the repository at this point in the history
  • Loading branch information
Bekabyx committed Jul 20, 2023
1 parent 867173d commit 46b54d6
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
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",
),
),
]
13 changes: 13 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", "WAL", "SCO"],
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
1 change: 1 addition & 0 deletions wcivf/apps/parties/tests/test_import_parties.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"alternative_name": "Cynghrair Wombles",
"register": "GB",
"status": "Registered",
"nations": ["ENG", "WAL", "SCO"],
"date_registered": "2018-01-31",
"date_deregistered": null,
"default_emblem": {
Expand Down

0 comments on commit 46b54d6

Please sign in to comment.