Skip to content

Commit

Permalink
Merge pull request #7 from brighthive/feat/HIVE-1143/add-county-field…
Browse files Browse the repository at this point in the history
…-to-address

feat: add county to address model
  • Loading branch information
gregmundy authored Nov 9, 2020
2 parents c3abe80 + 4e4d9fa commit 4132845
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 4 deletions.
25 changes: 25 additions & 0 deletions mci_database/db/migrations/versions/f1f3df877341_.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
"""Add county field to Address.
Revision ID: f1f3df877341
Revises: 08dad05889a9
Create Date: 2020-11-09 09:52:20.889107
"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = 'f1f3df877341'
down_revision = '08dad05889a9'
branch_labels = None
depends_on = None


def upgrade():
op.add_column('address', sa.Column(
'county', sa.String(length=125), nullable=True))


def downgrade():
op.drop_column('address', 'county')
13 changes: 9 additions & 4 deletions mci_database/db/models/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ class Address(db.Model):
postal_code (str): The postal code of the location.
county (str): The US county associated with the location.
country (str): The two digit country code where the location exists.
"""
Expand All @@ -29,13 +31,15 @@ class Address(db.Model):
city = db.Column(db.String(100))
state = db.Column(db.String(20))
postal_code = db.Column(db.String(20))
county = db.Column(db.String(125))
country = db.Column(db.String(2))

def __init__(self, address=None, city=None, state=None, postal_code=None, country=None):
def __init__(self, address=None, city=None, state=None, postal_code=None, county=None, country=None):
self.address = address
self.city = city
self.state = state
self.postal_code = postal_code
self.county = county
self.country = country


Expand Down Expand Up @@ -219,8 +223,8 @@ def as_dict(self):
Represent the Individual as a dict that uses empty strings for None values.
'''
dict_repr = {column.name: getattr(self, column.name)
for column in self.__table__.columns}
for column in self.__table__.columns}

for k, v in dict_repr.items():
if v is None:
dict_repr[k] = ""
Expand All @@ -229,6 +233,7 @@ def as_dict(self):

return dict_repr


class IndividualDisposition(db.Model):
individual_id = db.Column(db.String(40), db.ForeignKey(
Individual.mci_id, ondelete='CASCADE'), nullable=False, primary_key=True)
Expand All @@ -249,7 +254,7 @@ class IndividualPIIRemoval(db.Model):
removal_timestamp = db.Column(
db.DateTime, server_default=db.func.now(), nullable=False)
comment = db.Column(db.String(500))


class Referral(db.Model):
"""An individual's referral.
Expand Down

0 comments on commit 4132845

Please sign in to comment.