diff --git a/backend/database/models/agency.py b/backend/database/models/agency.py index 6b7152f85..7af4f0168 100644 --- a/backend/database/models/agency.py +++ b/backend/database/models/agency.py @@ -1,5 +1,6 @@ from backend.schemas import JsonSerializable, PropertyEnum from backend.database.models.types.enums import State +from backend.database.models.source import Citation from neomodel import ( StructuredNode, @@ -29,6 +30,8 @@ class UnitMembership(StructuredRel, JsonSerializable): class Unit(StructuredNode, JsonSerializable): + __hidden_properties__ = ["citations"] + uid = UniqueIdProperty() name = StringProperty() website_url = StringProperty() @@ -51,12 +54,16 @@ class Unit(StructuredNode, JsonSerializable): officers = RelationshipTo( "backend.database.models.officer.Officer", "MEMBER_OF", model=UnitMembership) + citations = RelationshipTo( + 'backend.database.models.source.Source', "UPDATED_BY", model=Citation) def __repr__(self): return f"" class Agency(StructuredNode, JsonSerializable): + __hidden_properties__ = ["citations"] + uid = UniqueIdProperty() name = StringProperty() website_url = StringProperty() @@ -71,6 +78,8 @@ class Agency(StructuredNode, JsonSerializable): # Relationships units = RelationshipTo("Unit", "ESTABLISHED") + citations = RelationshipTo( + 'backend.database.models.source.Source', "UPDATED_BY", model=Citation) def __repr__(self): return f"" diff --git a/backend/database/models/litigation.py b/backend/database/models/litigation.py index 056620ed6..7a4981bbe 100644 --- a/backend/database/models/litigation.py +++ b/backend/database/models/litigation.py @@ -1,4 +1,5 @@ from backend.schemas import JsonSerializable, PropertyEnum +from backend.database.models.source import Citation from neomodel import ( StructuredNode, StringProperty, @@ -14,6 +15,8 @@ class LegalCaseType(str, PropertyEnum): class Litigation(StructuredNode, JsonSerializable): + __hidden_properties__ = ["citations"] + uid = UniqueIdProperty() case_title = StringProperty() docket_number = StringProperty() @@ -31,6 +34,8 @@ class Litigation(StructuredNode, JsonSerializable): documents = RelationshipTo("Document", "RELATED_TO") dispositions = RelationshipTo("Disposition", "YIELDED") defendants = RelationshipTo("Officer", "NAMED_IN") + citations = RelationshipTo( + 'backend.database.models.source.Source', "UPDATED_BY", model=Citation) def __repr__(self): return f"" @@ -43,7 +48,7 @@ class Document(StructuredNode, JsonSerializable): url = StringProperty() -class Disposition(StructuredNode): +class Disposition(StructuredNode, JsonSerializable): description = StringProperty() date = DateProperty() disposition = StringProperty() diff --git a/backend/database/models/officer.py b/backend/database/models/officer.py index c723b9b2e..6f818b3f8 100644 --- a/backend/database/models/officer.py +++ b/backend/database/models/officer.py @@ -1,5 +1,6 @@ from backend.schemas import JsonSerializable from backend.database.models.types.enums import State, Ethnicity, Gender +from backend.database.models.source import Citation from neomodel import ( StructuredNode, @@ -30,6 +31,7 @@ class Officer(StructuredNode, JsonSerializable): "last_name", "suffix", "ethnicity", "gender", "date_of_birth" ] + __hidden_properties__ = ["citations"] uid = UniqueIdProperty() first_name = StringProperty() @@ -52,6 +54,8 @@ class Officer(StructuredNode, JsonSerializable): 'backend.database.models.complaint.Investigation', "LEAD_BY") commands = Relationship( 'backend.database.models.agency.Unit', "COMMANDS") + citations = RelationshipTo( + 'backend.database.models.source.Source', "UPDATED_BY", model=Citation) def __repr__(self): return f"" diff --git a/backend/database/models/source.py b/backend/database/models/source.py index 381a26e12..e266b50d9 100644 --- a/backend/database/models/source.py +++ b/backend/database/models/source.py @@ -105,6 +105,17 @@ def __repr__(self): id={self.uid}>" +class Citation(StructuredRel, JsonSerializable): + uid = UniqueIdProperty() + date = DateTimeProperty(default=datetime.now()) + url = StringProperty() + diff = StringProperty() + + def __repr__(self): + """Represent instance as a unique string.""" + return f"" + + class Source(StructuredNode, JsonSerializable): __property_order__ = [ "uid", "name", "url",