-
-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Refactor Officer -> Suspect First step of the refactor is to separate the Officer table from the version that is a child of the incident table. We'll set up a standalone officer and agency table where we'll store records related to known officers and law enforcement agencies. The old officer table, now called Suspects will store information about those officers suspected of committing a crime against the public. The suspect table will be connected to officers via the accusation table. * Refactor: Source is now parent of incident - Remove source from other models - Remove SourceMixin * Many-to-Many Relationships added. Tags and Agencies linked to Incidents Suspects and Agencies linked to officers Style changes. * Refactor: suspect --> perpetrator * Flake8 fix * Update perpetrator backref Update tests Flake8 fix * Additional Refactoring changes * UI Errors * UI Test Fixes - Updated Snapshots - Update models * Fix mock data issue * Continued refactoring * Mismatched Source ID type * Update victim table * Jest corrections --------- Co-authored-by: Darrell Malone <[email protected]>
- Loading branch information
Showing
35 changed files
with
379 additions
and
406 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,12 +2,11 @@ | |
from backend.database import User, UserRole | ||
from backend.auth import user_manager | ||
from backend.database.models.incident import Incident | ||
from backend.database.models.officer import Officer | ||
from backend.database.models.perpetrator import Perpetrator | ||
from backend.database.models.source import Source | ||
from backend.database.models.use_of_force import UseOfForce | ||
|
||
|
||
|
||
def create_user(user): | ||
user_exists = ( | ||
db.session.query(User).filter_by(email=user.email).first() is not None | ||
|
@@ -61,6 +60,7 @@ def create_user(user): | |
) | ||
) | ||
|
||
|
||
def create_source(source): | ||
source_exists = ( | ||
db.session.query(Source).filter_by(id=source.id).first() is not None | ||
|
@@ -69,36 +69,37 @@ def create_source(source): | |
if not source_exists: | ||
source.create() | ||
|
||
|
||
create_source( | ||
Source( | ||
id="mpv", | ||
publication_name="Mapping Police Violence", | ||
publication_date="01/01/2015", | ||
author="Samuel Sinyangwe", | ||
URL="https://mappingpoliceviolence.us", | ||
id=10000000, | ||
name="Mapping Police Violence", | ||
url="https://mappingpoliceviolence.us", | ||
contact_email="[email protected]" | ||
) | ||
) | ||
|
||
|
||
def create_incident(key=1, date="10-01-2019", lon=84, lat=34): | ||
base_id = 10000000 | ||
id = base_id + key | ||
mpv = db.session.query(Source).filter_by( | ||
name="Mapping Police Violence").first() | ||
incident = Incident( | ||
id=id, | ||
source=mpv, | ||
location=f"Test location {key}", | ||
longitude=lon, | ||
latitude=lat, | ||
description=f"Test description {key}", | ||
department=f"Small Police Department {key}", | ||
time_of_incident=f"{date} 00:00:00", | ||
officers=[ | ||
Officer( | ||
perpetrators=[ | ||
Perpetrator( | ||
first_name=f"TestFirstName {key}", | ||
last_name=f"TestLastName {key}", | ||
) | ||
], | ||
use_of_force=[UseOfForce(item=f"gunshot {key}")], | ||
source="mpv", | ||
use_of_force=[UseOfForce(item=f"gunshot {key}")] | ||
) | ||
exists = db.session.query(Incident).filter_by(id=id).first() is not None | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
from .. import db | ||
from backend.database.models.officer import Rank | ||
|
||
incident_agency = db.Table( | ||
'incident_agency', | ||
db.Column('incident_id', db.Integer, db.ForeignKey('incident.id'), | ||
primary_key=True), | ||
db.Column('agency_id', db.Integer, db.ForeignKey('agency.id'), | ||
primary_key=True), | ||
db.Column('officers_present', db.Integer) | ||
) | ||
|
||
incident_tag = db.Table( | ||
'incident_tag', | ||
db.Column('incident_id', db.Integer, db.ForeignKey('incident.id'), | ||
primary_key=True), | ||
db.Column('tag_id', db.Integer, db.ForeignKey('tag.id'), primary_key=True) | ||
) | ||
|
||
agency_officer = db.Table( | ||
'agency_officer', | ||
db.Column('agency_id', db.Integer, db.ForeignKey('agency.id'), | ||
primary_key=True), | ||
db.Column('officer_id', db.Integer, db.ForeignKey('officer.id'), | ||
primary_key=True), | ||
db.Column('earliest_employment', db.Text), | ||
db.Column('latest_employment', db.Text), | ||
db.Column('badge_number', db.Text), | ||
db.Column('unit', db.Text), | ||
db.Column('highest_rank', db.Enum(Rank)), | ||
db.Column('currently_employed', db.Boolean) | ||
) | ||
|
||
perpetrator_officer = db.Table( | ||
'perpetrator_officer', | ||
db.Column('perpetrator_id', db.Integer, db.ForeignKey('perpetrator.id'), | ||
primary_key=True), | ||
db.Column('officer_id', db.Integer, db.ForeignKey('officer.id'), | ||
primary_key=True) | ||
) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,27 @@ | ||
import enum | ||
from backend.database.models._assoc_tables import agency_officer | ||
from .. import db | ||
|
||
|
||
class JURISDICTION(enum.Enum): | ||
FEDERAL = 1 | ||
STATE = 2 | ||
COUNTY = 3 | ||
MUNICIPAL = 4 | ||
PRIVATE = 5 | ||
OTHER = 6 | ||
|
||
|
||
class Agency(db.Model): | ||
id = db.Column(db.Integer, primary_key=True) | ||
incident_id = db.Column(db.Integer, db.ForeignKey("incident.id")) | ||
name = db.Column(db.Text) | ||
website_url = db.Column(db.Text) | ||
hq_address = db.Column(db.Text) | ||
hq_city = db.Column(db.Text) | ||
hq_zip = db.Column(db.Text) | ||
jurisdiction = db.Column(db.Enum(JURISDICTION)) | ||
known_officers = db.relationship( | ||
"Officer", secondary=agency_officer, backref="known_employers") | ||
|
||
def __repr__(self): | ||
return f"<Agency {self.name}>" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from .. import db | ||
|
||
|
||
class Attachment(db.Model): | ||
id = db.Column(db.Integer, primary_key=True) | ||
incident_id = db.Column(db.Integer, db.ForeignKey("incident.id")) | ||
title = db.Column(db.Text) | ||
hash = db.Column(db.Text) | ||
location = db.Column(db.Text) | ||
filetype = db.Column(db.Text) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.