Skip to content

Commit

Permalink
More concise related names, update initial migration
Browse files Browse the repository at this point in the history
  • Loading branch information
gordonje committed Jun 22, 2017
1 parent 4cd41a4 commit bba89e4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
18 changes: 9 additions & 9 deletions opencivicdata/elections/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.2 on 2017-06-05 19:54
# Generated by Django 1.11.2 on 2017-06-22 00:43
from __future__ import unicode_literals

import django.contrib.postgres.fields
Expand Down Expand Up @@ -33,7 +33,7 @@ class Migration(migrations.Migration):
('description', models.TextField(help_text='Text describing the purpose and/or potential outcomes of the ballot measure, not necessarily as it appears on the ballot.')),
('requirement', models.CharField(blank=True, default='50% plus one vote', help_text='The threshold of votes the ballot measure needs in order to pass.', max_length=300)),
('classification', models.CharField(blank=True, help_text='Describes the origin and/or potential outcome of the ballot measure, e.g., "initiative statute", "legislative constitutional amendment".', max_length=300)),
('division', models.ForeignKey(help_text="Reference to the Division that defines the political geography of the contest, e.g., a specific Congressional or State Senate district. Should be a subdivision of the Division referenced by the contest's Election.", on_delete=django.db.models.deletion.CASCADE, related_name='ballotmeasurecontest_divisions', related_query_name='ballotmeasurecontests', to='core.Division')),
('division', models.ForeignKey(help_text="Reference to the Division that defines the political geography of the contest, e.g., a specific Congressional or State Senate district. Should be a subdivision of the Division referenced by the contest's Election.", on_delete=django.db.models.deletion.CASCADE, related_name='ballotmeasurecontests', related_query_name='ballotmeasurecontests', to='core.Division')),
],
options={
'db_table': 'opencivicdata_ballotmeasurecontest',
Expand Down Expand Up @@ -116,7 +116,7 @@ class Migration(migrations.Migration):
('name', models.CharField(help_text='Name of the contest, not necessarily as it appears on the ballot.', max_length=300)),
('previous_term_unexpired', models.BooleanField(default=False, help_text='Indicates the previous public office holder vacated the post before serving a full term.')),
('number_elected', models.IntegerField(default=1, help_text="Number of candidates that are elected in the contest, i.e. 'N' of N-of-M.")),
('division', models.ForeignKey(help_text="Reference to the Division that defines the political geography of the contest, e.g., a specific Congressional or State Senate district. Should be a subdivision of the Division referenced by the contest's Election.", on_delete=django.db.models.deletion.CASCADE, related_name='candidatecontest_divisions', related_query_name='candidatecontests', to='core.Division')),
('division', models.ForeignKey(help_text="Reference to the Division that defines the political geography of the contest, e.g., a specific Congressional or State Senate district. Should be a subdivision of the Division referenced by the contest's Election.", on_delete=django.db.models.deletion.CASCADE, related_name='candidatecontests', related_query_name='candidatecontests', to='core.Division')),
],
options={
'db_table': 'opencivicdata_candidatecontest',
Expand Down Expand Up @@ -210,8 +210,8 @@ class Migration(migrations.Migration):
('locked_fields', django.contrib.postgres.fields.ArrayField(base_field=models.TextField(), blank=True, default=list, size=None)),
('id', opencivicdata.core.models.base.OCDIDField(help_text='Open Civic Data-style id in the format ``ocd-contest/{{uuid}}``.', ocd_type='contest', serialize=False, validators=[django.core.validators.RegexValidator(flags=re.RegexFlag(32), message='ID must match ^ocd-contest/[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}$', regex='^ocd-contest/[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}$')])),
('name', models.CharField(help_text='Name of the contest, not necessarily as it appears on the ballot.', max_length=300)),
('division', models.ForeignKey(help_text="Reference to the Division that defines the political geography of the contest, e.g., a specific Congressional or State Senate district. Should be a subdivision of the Division referenced by the contest's Election.", on_delete=django.db.models.deletion.CASCADE, related_name='partycontest_divisions', related_query_name='partycontests', to='core.Division')),
('election', models.ForeignKey(help_text='Reference to the Election in which the contest is decided.', on_delete=django.db.models.deletion.CASCADE, related_name='elections_partycontest_contests', related_query_name='elections_partycontests', to='elections.Election')),
('division', models.ForeignKey(help_text="Reference to the Division that defines the political geography of the contest, e.g., a specific Congressional or State Senate district. Should be a subdivision of the Division referenced by the contest's Election.", on_delete=django.db.models.deletion.CASCADE, related_name='partycontests', related_query_name='partycontests', to='core.Division')),
('election', models.ForeignKey(help_text='Reference to the Election in which the contest is decided.', on_delete=django.db.models.deletion.CASCADE, related_name='partycontests', related_query_name='partycontests', to='elections.Election')),
('runoff_for_contest', models.OneToOneField(help_text='If this contest is a runoff to determine the outcome of a previously undecided contest, reference to that PartyContest.', null=True, on_delete=django.db.models.deletion.CASCADE, to='elections.PartyContest')),
],
options={
Expand Down Expand Up @@ -266,8 +266,8 @@ class Migration(migrations.Migration):
('name', models.CharField(help_text='Name of the contest, not necessarily as it appears on the ballot.', max_length=300)),
('description', models.TextField(help_text='Text describing the purpose and/or potential outcomes of the contest, not necessarily as it appears on the ballot.')),
('requirement', models.CharField(blank=True, default='50% plus one vote', help_text='The threshold of votes need in order to retain the officeholder.', max_length=300)),
('division', models.ForeignKey(help_text="Reference to the Division that defines the political geography of the contest, e.g., a specific Congressional or State Senate district. Should be a subdivision of the Division referenced by the contest's Election.", on_delete=django.db.models.deletion.CASCADE, related_name='retentioncontest_divisions', related_query_name='retentioncontests', to='core.Division')),
('election', models.ForeignKey(help_text='Reference to the Election in which the contest is decided.', on_delete=django.db.models.deletion.CASCADE, related_name='elections_retentioncontest_contests', related_query_name='elections_retentioncontests', to='elections.Election')),
('division', models.ForeignKey(help_text="Reference to the Division that defines the political geography of the contest, e.g., a specific Congressional or State Senate district. Should be a subdivision of the Division referenced by the contest's Election.", on_delete=django.db.models.deletion.CASCADE, related_name='retentioncontests', related_query_name='retentioncontests', to='core.Division')),
('election', models.ForeignKey(help_text='Reference to the Election in which the contest is decided.', on_delete=django.db.models.deletion.CASCADE, related_name='retentioncontests', related_query_name='retentioncontests', to='elections.Election')),
('membership', models.ForeignKey(help_text='Reference to the Membership that represents the tenure of a person in a specific public office.', on_delete=django.db.models.deletion.CASCADE, to='core.Membership')),
('runoff_for_contest', models.OneToOneField(help_text='If this contest is a runoff to determine the outcome of a previously undecided contest, reference to that RetentionContest.', null=True, on_delete=django.db.models.deletion.CASCADE, related_name='runoff_contest', to='elections.RetentionContest')),
],
Expand Down Expand Up @@ -313,7 +313,7 @@ class Migration(migrations.Migration):
migrations.AddField(
model_name='candidatecontest',
name='election',
field=models.ForeignKey(help_text='Reference to the Election in which the contest is decided.', on_delete=django.db.models.deletion.CASCADE, related_name='elections_candidatecontest_contests', related_query_name='elections_candidatecontests', to='elections.Election'),
field=models.ForeignKey(help_text='Reference to the Election in which the contest is decided.', on_delete=django.db.models.deletion.CASCADE, related_name='candidatecontests', related_query_name='candidatecontests', to='elections.Election'),
),
migrations.AddField(
model_name='candidatecontest',
Expand Down Expand Up @@ -353,7 +353,7 @@ class Migration(migrations.Migration):
migrations.AddField(
model_name='ballotmeasurecontest',
name='election',
field=models.ForeignKey(help_text='Reference to the Election in which the contest is decided.', on_delete=django.db.models.deletion.CASCADE, related_name='elections_ballotmeasurecontest_contests', related_query_name='elections_ballotmeasurecontests', to='elections.Election'),
field=models.ForeignKey(help_text='Reference to the Election in which the contest is decided.', on_delete=django.db.models.deletion.CASCADE, related_name='ballotmeasurecontests', related_query_name='ballotmeasurecontests', to='elections.Election'),
),
migrations.AddField(
model_name='ballotmeasurecontest',
Expand Down
6 changes: 3 additions & 3 deletions opencivicdata/elections/models/contests/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class ContestBase(OCDBase):
)
division = models.ForeignKey(
Division,
related_name="%(class)s_divisions",
related_name="%(class)ss",
related_query_name="%(class)ss",
help_text="Reference to the Division that defines the political "
"geography of the contest, e.g., a specific Congressional or "
Expand All @@ -38,8 +38,8 @@ class ContestBase(OCDBase):
)
election = models.ForeignKey(
Election,
related_name="%(app_label)s_%(class)s_contests",
related_query_name="%(app_label)s_%(class)ss",
related_name="%(class)ss",
related_query_name="%(class)ss",
help_text="Reference to the Election in which the contest is decided.",
)

Expand Down

0 comments on commit bba89e4

Please sign in to comment.