Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature #313 - Add Statewide IDs #314

Merged
merged 2 commits into from
Jan 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 70 additions & 3 deletions backend/database/models/officer.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,83 @@ 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
law enforcement agencies. for an officer. For example, in New York, this
would be the Tax ID Number.
"""
id = db.Column(db.Integer, primary_key=True)
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.Enum(State)) # e.g. "NY"
value = db.Column(db.Text) # e.g. "958938"

def __repr__(self):
return f"<StateID {self.id}>"


class Officer(db.Model):
id = db.Column(db.Integer, primary_key=True) # officer id
first_name = db.Column(db.Text)
last_name = db.Column(db.Text)
race = db.Column(db.Text)
ethnicity = db.Column(db.Text)
gender = db.Column(db.Text)
# Note: rank at time of incident
Copy link
Collaborator Author

@DMalone87 DMalone87 Jan 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rank and Star are removed since those are dependent on the Law Enforcement Agency the officer is employed by and are not unique to the officer in all cases. Those values can still be found in the association table for Officers and Agencies.

rank = db.Column(db.Enum(Rank))
star = db.Column(db.Text) # type?
date_of_birth = db.Column(db.Date)

def __repr__(self):
Expand Down
6 changes: 4 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 @@ -15,7 +15,9 @@ class Perpetrator(db.Model):
unit = db.Column(db.Text) # type?
# Note: rank at time of incident
rank = db.Column(db.Enum(Rank))
star = db.Column(db.Text) # type?
state_id_val = 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(
"Officer", secondary=perpetrator_officer, backref="accusations")
Expand Down
Loading