Skip to content
Open
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
12 changes: 12 additions & 0 deletions backend/database/models/agency.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ class UnitMembership(StructuredRel, JsonSerializable):


class Unit(StructuredNode, JsonSerializable):
__property_order__ = [
"uid", "name", "website_url", "phone",
"email", "description", "address",
"city", "state", "zip", "agency_url",
"officers_url", "date_etsablished"
]
__hidden_properties__ = ["citations"]

uid = UniqueIdProperty()
Expand Down Expand Up @@ -62,6 +68,12 @@ def __repr__(self):


class Agency(StructuredNode, JsonSerializable):
__property_order__ = [
"uid", "name", "website_url", "hq_address",
"hq_city", "hq_state", "hq_zip",
"phone", "email", "description",
"jurisdiction"
]
__hidden_properties__ = ["citations"]

uid = UniqueIdProperty()
Expand Down
40 changes: 39 additions & 1 deletion backend/database/models/attachment.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,51 @@
from neomodel import (
StringProperty,
UniqueIdProperty,
StructuredNode
StructuredNode,
DateProperty
)


class Attachment(JsonSerializable, StructuredNode):
"""
Multimedia attachment.
"""
__property_order__ = [
"uid", "title", "url", "filetype"
]
__hidden_properties__ = ["hash"]

uid = UniqueIdProperty()
title = StringProperty()
hash = StringProperty()
url = StringProperty()
filetype = StringProperty()


class Article(StructuredNode, JsonSerializable):
"""
News article.
"""

uid = UniqueIdProperty()
title = StringProperty()
publisher = StringProperty()
publication_date = DateProperty()
url = StringProperty()


class SocialMediaInfo(StructuredNode, JsonSerializable):
"""
Social media information.
"""
__property_order__ = [
"twitter_url", "linkedin_url", "facebook_url",
"instagram_url", "youtube_url", "tiktok_url"
]

twitter_url = StringProperty()
linkedin_url = StringProperty()
facebook_url = StringProperty()
instagram_url = StringProperty()
youtube_url = StringProperty()
tiktok_url = StringProperty()
9 changes: 6 additions & 3 deletions backend/database/models/civilian.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
"""Define the Classes for Civilians."""
from backend.schemas import JsonSerializable
from backend.database.models.types.enums import Ethnicity, Gender
from neomodel import (
StructuredNode,
StringProperty,
Expand All @@ -7,10 +9,11 @@
)


class Civilian(StructuredNode):
class Civilian(StructuredNode, JsonSerializable):
age = IntegerProperty()
race = StringProperty()
gender = StringProperty()
age_range = StringProperty()
ethnicity = StringProperty(choices=Ethnicity.choices())
gender = StringProperty(choices=Gender.choices())

# Relationships
complaints = RelationshipTo(
Expand Down
95 changes: 73 additions & 22 deletions backend/database/models/complaint.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
RelationshipTo,
RelationshipFrom,
DateProperty,
UniqueIdProperty
UniqueIdProperty,
ZeroOrOne
)


Expand All @@ -19,36 +20,58 @@ class RecordType(str, PropertyEnum):


# Neo4j Models
class BaseSourceRel(StructuredRel, JsonSerializable):
class ComplaintSourceRel(StructuredRel, JsonSerializable):
uid = UniqueIdProperty()
record_type = StringProperty(
choices=RecordType.choices(),
required=True
)
date_published = DateProperty()


class LegalSourceRel(BaseSourceRel):
# Legal Source Properties
court = StringProperty()
judge = StringProperty()
docket_number = StringProperty()
date_of_action = DateProperty()

case_event_date = DateProperty()

class NewsSourceRel(BaseSourceRel):
# News Source Properties
publication_name = StringProperty()
publication_date = DateProperty()
publication_url = StringProperty()
author = StringProperty()
author_url = StringProperty()
author_email = StringProperty()


class GovernmentSourceRel(BaseSourceRel):
# Government Source Properties
reporting_agency = StringProperty()
reporting_agency_url = StringProperty()
reporting_agency_email = StringProperty()


class Location(StructuredNode, JsonSerializable):
__property_order__ = [
"location_type", "location_description",
"address", "city", "state", "zip",
"responsibility", "responsibility_type"
]

location_type = StringProperty()
loocation_description = StringProperty()
address = StringProperty()
city = StringProperty()
state = StringProperty()
zip = StringProperty()
responsibility = StringProperty()
responsibility_type = StringProperty()


class Complaint(StructuredNode, JsonSerializable):
__property_order__ = [
"uid", "record_id", "category",
"incident_date", "recieved_date",
"closed_date", "reason_for_contact",
"outcome_of_contact"
]

uid = UniqueIdProperty()
record_id = StringProperty()
category = StringProperty()
Expand All @@ -59,22 +82,33 @@ class Complaint(StructuredNode, JsonSerializable):
outcome_of_contact = StringProperty()

# Relationships
source_org = RelationshipFrom("Source", "REPORTED", model=BaseSourceRel)
source_org = RelationshipFrom(
"Source", "REPORTED", model=ComplaintSourceRel)
location = RelationshipTo("Location", "OCCURRED_AT")
civlian_witnesses = RelationshipFrom("Civilian", "WITNESSED")
civlian_witnesses = RelationshipFrom("models.civilian.Civilian", "WITNESSED")
police_witnesses = RelationshipFrom("Officer", "WITNESSED")
attachments = RelationshipTo("Attachment", "ATTACHED_TO")
attachments = RelationshipTo(
'backend.database.models.attachment.Attachment', "REFERENCED_IN")
articles = RelationshipTo(
'backend.database.models.attachment.Article', "MENTIONED_IN")
allegations = RelationshipTo("Allegation", "ALLEGED")
investigations = RelationshipTo("Investigation", "EXAMINED_BY")
penalties = RelationshipTo("Penalty", "RESULTS_IN")
civilian_review_board = RelationshipFrom("CivilianReviewBoard", "REVIEWED")
# civilian_review_board = RelationshipFrom(
# "CivilianReviewBoard", "REVIEWED")

def __repr__(self):
"""Represent instance as a unique string."""
return f"<Complaint {self.uid}>"


class Allegation(StructuredNode):
class Allegation(StructuredNode, JsonSerializable):
__property_order__ = [
"uid", "record_id", "allegation",
"type", "subtype", "recommended_finding",
"recommended_outcome", "finding", "outcome"
]

uid = UniqueIdProperty()
record_id = StringProperty()
allegation = StringProperty()
Expand All @@ -86,36 +120,53 @@ class Allegation(StructuredNode):
outcome = StringProperty()

# Relationships
complainant = RelationshipFrom("Civilian", "COMPLAINED_OF")
complainant = RelationshipFrom(
"models.civilian.Civilian", "COMPLAINED_OF", cardinality=ZeroOrOne)
complaint = RelationshipFrom(
"Complaint", "ALLEGED", cardinality=ZeroOrOne)
accused = RelationshipFrom("Officer", "ACCUSED_OF")
complaint = RelationshipFrom("Complaint", "ALLEGED")

def __repr__(self):
"""Represent instance as a unique string."""
return f"<Allegation {self.uid}>"


class Investigation(StructuredNode):
class Investigation(StructuredNode, JsonSerializable):
__property_order__ = [
"uid", "start_date", "end_date"
]

uid = UniqueIdProperty()
start_date = DateProperty()
end_date = DateProperty()

# Relationships
investigator = RelationshipFrom("Officer", "LED_BY")
investigator = RelationshipFrom(
"Officer", "LED_BY", cardinality=ZeroOrOne)
complaint = RelationshipFrom("Complaint", "EXAMINED_BY")

def __repr__(self):
"""Represent instance as a unique string."""
return f"<Investigation {self.uid}>"


class Penalty(StructuredNode):
class Penalty(StructuredNode, JsonSerializable):
__property_order__ = [
"uid", "penalty", "date_assessed",
"crb_plea", "crb_case_status",
"crb_disposition", "agency_disposition"
]

uid = UniqueIdProperty()
description = StringProperty()
penalty = StringProperty()
date_assessed = DateProperty()
crb_plea = StringProperty()
crb_case_status = StringProperty()
crb_disposition = StringProperty()
agency_disposition = StringProperty()

# Relationships
officer = RelationshipFrom("Officer", "RECEIVED")
officer = RelationshipFrom("models.officer.Officer", "RECEIVED")
complaint = RelationshipFrom("Complaint", "RESULTS_IN")

def __repr__(self):
Expand Down
27 changes: 26 additions & 1 deletion backend/database/models/litigation.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,34 @@ class LegalCaseType(str, PropertyEnum):
CRIMINAL = "CRIMINAL"


class CourtLevel(str, PropertyEnum):
MUNICIPAL_OR_COUNTY = "Municipal or County"
STATE_TRIAL = "State Trial Court"
STATE_INTERMEDIATE_APPELLATE = "State Intermediate Appellate"
STATE_HIGHEST = "State Highest"
FEDERAL_DISTRICT = "Federal District"
FEDERAL_APPELLATE = "Federal Appellate"
US_SUPREME_COURT = "U.S. Supreme"


class Litigation(StructuredNode, JsonSerializable):
"""
Represents a legal case or litigation.
"""
__property_order__ = [
"uid", "case_type", "case_title", "state",
"court_name", "court_level", "jurisdiction",
"docket_number", "description", "start_date",
"settlement_date", "settlement_amount",
"url"
]
__hidden_properties__ = ["citations"]

uid = UniqueIdProperty()
case_title = StringProperty()
docket_number = StringProperty()
court_level = StringProperty()
court_name = StringProperty()
court_level = StringProperty(choices=CourtLevel.choices())
jurisdiction = StringProperty()
state = StringProperty()
description = StringProperty()
Expand All @@ -42,6 +63,10 @@ def __repr__(self):


class Document(StructuredNode, JsonSerializable):
__property_order__ = [
"uid", "title", "description", "url"
]

uid = UniqueIdProperty()
title = StringProperty()
description = StringProperty()
Expand Down
9 changes: 9 additions & 0 deletions backend/database/models/officer.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ class StateID(StructuredNode, JsonSerializable):
law enforcement agencies. For example, in New York, this would be
the Tax ID Number.
"""
__property_order__ = [
"uid", "state", "id_name", "value"
]

id_name = StringProperty() # e.g. "Tax ID Number"
state = StringProperty(choices=State.choices()) # e.g. "NY"
value = StringProperty() # e.g. "958938"
Expand All @@ -41,6 +45,7 @@ class Officer(StructuredNode, JsonSerializable):
ethnicity = StringProperty(choices=Ethnicity.choices())
gender = StringProperty(choices=Gender.choices())
date_of_birth = DateProperty()
year_of_birth = StringProperty()

# Relationships
state_ids = RelationshipTo('StateID', "HAS_STATE_ID")
Expand All @@ -54,6 +59,10 @@ class Officer(StructuredNode, JsonSerializable):
'backend.database.models.complaint.Investigation', "LEAD_BY")
commands = Relationship(
'backend.database.models.agency.Unit', "COMMANDS")
articles = RelationshipTo(
'backend.database.models.attachment.Article', "MENTIONED_IN")
attachments = RelationshipTo(
'backend.database.models.attachment.Attachment', "REFERENCED_IN")
citations = RelationshipTo(
'backend.database.models.source.Source', "UPDATED_BY", model=Citation)

Expand Down
Loading
Loading