Skip to content

Commit

Permalink
Add more results data to Election model
Browse files Browse the repository at this point in the history
- adds electorate, ballot papers issued,
 turnout and spoilt ballots
  • Loading branch information
VirginiaDooley committed Sep 13, 2023
1 parent 8393a08 commit 36b8410
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Generated by Django 4.2.3 on 2023-09-06 11:30

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("elections", "0040_postelection_requires_voter_id"),
]

operations = [
migrations.AddField(
model_name="election",
name="ballot_papers_issued",
field=models.IntegerField(blank=True, null=True),
),
migrations.AddField(
model_name="election",
name="electorate",
field=models.IntegerField(blank=True, null=True),
),
migrations.AddField(
model_name="election",
name="spoilt_ballots",
field=models.IntegerField(blank=True, null=True),
),
migrations.AddField(
model_name="election",
name="turnout",
field=models.IntegerField(blank=True, null=True),
),
]
4 changes: 4 additions & 0 deletions wcivf/apps/elections/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ class Election(models.Model):
election_weight = models.IntegerField(default=10)
metadata = JSONField(null=True)
any_non_by_elections = models.BooleanField(default=False)
ballot_papers_issued = models.IntegerField(blank=True, null=True)
electorate = models.IntegerField(blank=True, null=True)
turnout = models.IntegerField(blank=True, null=True)
spoilt_ballots = models.IntegerField(blank=True, null=True)

objects = ElectionManager()

Expand Down
20 changes: 20 additions & 0 deletions wcivf/apps/elections/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,26 @@ def test_in_past(self):

assert election.in_past is True

def test_electorate(self):
election = Election(electorate=1000)
assert election.electorate == 1000
assert type(election.electorate) == int

def test_turnout(self):
election = Election(turnout=1000)
assert election.turnout == 1000
assert type(election.turnout) == int

def test_spoilt_ballots(self):
election = Election(spoilt_ballots=1000)
assert election.spoilt_ballots == 1000
assert type(election.spoilt_ballots) == int

def test_ballot_papers_issued(self):
election = Election(ballot_papers_issued=1000)
assert election.ballot_papers_issued == 1000
assert type(election.ballot_papers_issued) == int

def test_is_city_of_london(self, election, city_of_london_election):
assert election.is_city_of_london is False
assert city_of_london_election.is_city_of_london is True
Expand Down

0 comments on commit 36b8410

Please sign in to comment.