Skip to content

Commit

Permalink
Add more OCD proxies
Browse files Browse the repository at this point in the history
  • Loading branch information
gordonje committed Aug 14, 2017
1 parent 1800118 commit 4847d0a
Show file tree
Hide file tree
Showing 6 changed files with 248 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.3 on 2017-08-14 17:06
from __future__ import unicode_literals

import calaccess_processed.models.proxies.opencivicdata.base
from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('elections', '0002_auto_20170731_2047'),
('calaccess_processed', '0003_auto_20170811_2020'),
]

operations = [
migrations.CreateModel(
name='OCDCandidacySourceProxy',
fields=[
],
options={
'proxy': True,
'indexes': [],
},
bases=('elections.candidacysource', calaccess_processed.models.proxies.opencivicdata.base.OCDProxyModelMixin),
),
migrations.CreateModel(
name='OCDCandidateContestPostProxy',
fields=[
],
options={
'proxy': True,
'indexes': [],
},
bases=('elections.candidatecontestpost', calaccess_processed.models.proxies.opencivicdata.base.OCDProxyModelMixin),
),
migrations.CreateModel(
name='OCDCandidateContestSourceProxy',
fields=[
],
options={
'proxy': True,
'indexes': [],
},
bases=('elections.candidatecontestsource', calaccess_processed.models.proxies.opencivicdata.base.OCDProxyModelMixin),
),
migrations.CreateModel(
name='OCDElectionIdentifierProxy',
fields=[
],
options={
'proxy': True,
'indexes': [],
},
bases=('elections.electionidentifier', calaccess_processed.models.proxies.opencivicdata.base.OCDProxyModelMixin),
),
migrations.CreateModel(
name='OCDElectionSourceProxy',
fields=[
],
options={
'proxy': True,
'indexes': [],
},
bases=('elections.electionsource', calaccess_processed.models.proxies.opencivicdata.base.OCDProxyModelMixin),
),
]
57 changes: 57 additions & 0 deletions calaccess_processed/models/proxies/opencivicdata/ballotmeasures.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Proxy models for augmenting our source data tables with methods useful for processing.
"""
from __future__ import unicode_literals
from opencivicdata.elections.models import (
BallotMeasureContest,
BallotMeasureContestIdentifier,
BallotMeasureContestOption,
BallotMeasureContestSource,
)
from .base import OCDProxyModelMixin


class OCDBallotMeasureContestProxy(BallotMeasureContest, OCDProxyModelMixin):
"""
A proxy on the OCD BallotMeasureContest model.
"""
class Meta:
"""
Make this a proxy model.
"""
proxy = True


class OCDBallotMeasureContestIdentifierProxy(BallotMeasureContestIdentifier, OCDProxyModelMixin):
"""
A proxy on the OCD BallotMeasureContestIdentifier model.
"""
class Meta:
"""
Make this a proxy model.
"""
proxy = True


class OCDBallotMeasureContestOptionProxy(BallotMeasureContestOption, OCDProxyModelMixin):
"""
A proxy on the OCD BallotMeasureContestOption model.
"""
class Meta:
"""
Make this a proxy model.
"""
proxy = True


class OCDBallotMeasureContestSourceProxy(BallotMeasureContestSource, OCDProxyModelMixin):
"""
A proxy on the OCD BallotMeasureContestSource model.
"""
class Meta:
"""
Make this a proxy model.
"""
proxy = True
13 changes: 12 additions & 1 deletion calaccess_processed/models/proxies/opencivicdata/candidacies.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from django.db.models import Case, When, Q
from django.db.models.functions import Cast
from opencivicdata.core.models import Membership
from opencivicdata.elections.models import Candidacy
from opencivicdata.elections.models import Candidacy, CandidacySource
from .base import OCDProxyModelMixin


Expand Down Expand Up @@ -270,3 +270,14 @@ def form501s(self):
"""
from calaccess_processed.models import Form501Filing
return Form501Filing.objects.filter(filing_id__in=self.form501_filing_ids)


class OCDCandidacySourceProxy(CandidacySource, OCDProxyModelMixin):
"""
A proxy on the OCD CandidacySource model.
"""
class Meta:
"""
Make this a proxy model.
"""
proxy = True
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
"""
from __future__ import unicode_literals
from django.db import models
from opencivicdata.elections.models import CandidateContest
from opencivicdata.elections.models import (
CandidateContest,
CandidateContestPost,
CandidateContestSource,
)
from .base import OCDProxyModelMixin


Expand Down Expand Up @@ -60,3 +64,25 @@ def get_parent(self):
).latest('election__date')
except CandidateContest.DoesNotExist:
return None


class OCDCandidateContestPostProxy(CandidateContestPost, OCDProxyModelMixin):
"""
A proxy on the OCD CandidateContestPost model.
"""
class Meta:
"""
Make this a proxy model.
"""
proxy = True


class OCDCandidateContestSourceProxy(CandidateContestSource, OCDProxyModelMixin):
"""
A proxy on the OCD CandidateContestSource model.
"""
class Meta:
"""
Make this a proxy model.
"""
proxy = True
30 changes: 28 additions & 2 deletions calaccess_processed/models/proxies/opencivicdata/elections.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@
from .divisions import OCDDivisionProxy
from django.utils.text import get_text_list
from .organizations import OCDOrganizationProxy
from opencivicdata.elections.models import Election
from opencivicdata.elections.models import (
Election,
ElectionIdentifier,
ElectionSource,
)
from .base import OCDProxyModelMixin


Expand Down Expand Up @@ -57,7 +61,7 @@ def create_from_calaccess(self, name, dt, election_id=None, election_type=None):

class OCDElectionProxy(Election, OCDProxyModelMixin):
"""
A proxy for the Election model in opencivicdata app.
A proxy on the OCD Election model.
"""
objects = OCDElectionManager()
partisan_primaries = OCDPartisanPrimaryManager()
Expand Down Expand Up @@ -135,3 +139,25 @@ def source_list(self):
Returns a prettified list of OCD sources.
"""
return get_text_list(list(self.sources.all()))


class OCDElectionIdentifierProxy(ElectionIdentifier, OCDProxyModelMixin):
"""
A proxy on the OCD ElectionIdentifier model.
"""
class Meta:
"""
Make this a proxy model.
"""
proxy = True


class OCDElectionSourceProxy(ElectionSource, OCDProxyModelMixin):
"""
A proxy on the OCD ElectionSource model.
"""
class Meta:
"""
Make this a proxy model.
"""
proxy = True
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Proxy models for augmenting our source data tables with methods useful for processing.
"""
from __future__ import unicode_literals
from opencivicdata.elections.models import (
RetentionContest,
RetentionContestIdentifier,
RetentionContestOption,
RetentionContestSource,
)
from .base import OCDProxyModelMixin


class OCDRetentionContestProxy(RetentionContest, OCDProxyModelMixin):
"""
A proxy on the OCD RetentionContest model.
"""
class Meta:
"""
Make this a proxy model.
"""
proxy = True


class OCDRetentionContestIdentifierProxy(RetentionContestIdentifier, OCDProxyModelMixin):
"""
A proxy on the OCD RetentionContestIdentifier model.
"""
class Meta:
"""
Make this a proxy model.
"""
proxy = True


class OCDRetentionContestOptionProxy(RetentionContestOption, OCDProxyModelMixin):
"""
A proxy on the OCD RetentionContestOption model.
"""
class Meta:
"""
Make this a proxy model.
"""
proxy = True


class OCDRetentionContestSourceProxy(RetentionContestSource, OCDProxyModelMixin):
"""
A proxy on the OCD RetentionContestSource model.
"""
class Meta:
"""
Make this a proxy model.
"""
proxy = True

0 comments on commit 4847d0a

Please sign in to comment.