Skip to content

Commit

Permalink
Add Enum for State Abbreviations
Browse files Browse the repository at this point in the history
  • Loading branch information
DMalone87 committed Jan 5, 2024
1 parent 96c0100 commit af7875a
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 3 deletions.
55 changes: 54 additions & 1 deletion backend/database/models/officer.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,59 @@ class Rank(str, enum.Enum):
CHIEF = "CHIEF"


class State(str, enum.Enum):
AL = "AL"
AK = "AK"
AZ = "AZ"
AR = "AR"
CA = "CA"
CO = "CO"
CT = "CT"
DE = "DE"
FL = "FL"
GA = "GA"
HI = "HI"
ID = "ID"
IL = "IL"
IN = "IN"
IA = "IA"
KS = "KS"
KY = "KY"
LA = "LA"
ME = "ME"
MD = "MD"
MA = "MA"
MI = "MI"
MN = "MN"
MS = "MS"
MO = "MO"
MT = "MT"
NE = "NE"
NV = "NV"
NH = "NH"
NJ = "NJ"
NM = "NM"
NY = "NY"
NC = "NC"
ND = "ND"
OH = "OH"
OK = "OK"
OR = "OR"
PA = "PA"
RI = "RI"
SC = "SC"
SD = "SD"
TN = "TN"
TX = "TX"
UT = "UT"
VT = "VT"
VA = "VA"
WA = "WA"
WV = "WV"
WI = "WI"
WY = "WY"


class StateID(db.Model):
"""
Represents a Statewide ID that follows an offcier even as they move between
Expand All @@ -26,7 +79,7 @@ class StateID(db.Model):
officer_id = db.Column(
db.Integer, db.ForeignKey("officer.id"))
id_name = db.Column(db.Text) # e.g. "Tax ID Number"
state = db.Column(db.Text) # e.g. "NY"
state = db.Column(db.Enum(State)) # e.g. "NY"
value = db.Column(db.Text) # e.g. "958938"

def __repr__(self):
Expand Down
4 changes: 2 additions & 2 deletions backend/database/models/perpetrator.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from backend.database.models._assoc_tables import perpetrator_officer
from backend.database.models.officer import Rank
from backend.database.models.officer import Rank, State
from .. import db


Expand All @@ -16,7 +16,7 @@ class Perpetrator(db.Model):
# Note: rank at time of incident
rank = db.Column(db.Enum(Rank))
state_id_val = db.Column(db.Text)
state_id_state = db.Column(db.Text)
state_id_state = db.Column(db.Enum(State))
state_id_name = db.Column(db.Text)
role = db.Column(db.Text)
suspects = db.relationship(
Expand Down

0 comments on commit af7875a

Please sign in to comment.