Skip to content

Commit

Permalink
Fix SA Warning (#359)
Browse files Browse the repository at this point in the history
* Fixes a warning about
`Attorney.legal_case_plaintiff` and
`Attorney.legal_case_defendant` being created improperly.

* Convert relationships to strings in the
legal_case model.

* Set User email column to `cache_ok` = true

* This time, with feeling...
  • Loading branch information
DMalone87 authored Mar 15, 2024
1 parent 7fc87ef commit 725694c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 10 deletions.
1 change: 0 additions & 1 deletion backend/database/models/attorney.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@

class Attorney(db.Model):
id = db.Column(db.Integer, primary_key=True)
legal_case_id = db.Column(db.Integer, db.ForeignKey("legal_case.id"))
text_contents = db.Column(db.String)
10 changes: 2 additions & 8 deletions backend/database/models/legal_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@


class LegalCaseType(str, enum.Enum):
# TODO: Do we want string enumerations to be all caps? i.e. CIVIL = "CIVIL"
CIVIL = "CIVIL"
CRIMINAL = "CRIMINAL"

Expand All @@ -15,15 +14,10 @@ class LegalCase(db.Model):
jurisdiction = db.Column(db.String)
judge = db.Column(db.String)
docket_number = db.Column(db.String)
# TODO: Foreign key to officer/victim?
defendant = db.Column(db.String)
defendant_council = db.relationship(
"Attorney", backref="legal_case_defendant", uselist=False
)
defendant_council = db.Column(db.String)
plaintiff = db.Column(db.String)
plaintiff_council = db.relationship(
"Attorney", backref="legal_case_plaintiff", uselist=False
)
plaintiff_council = db.Column(db.String)
start_date = db.Column(db.DateTime)
end_date = db.Column(db.DateTime)
outcome = db.Column(db.String)
4 changes: 3 additions & 1 deletion backend/database/models/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class CI_String(TypeDecorator):
"""Case-insensitive String subclass definition"""

impl = String
cache_ok = True

def __init__(self, length, **kwargs):
if kwargs.get("collate"):
Expand Down Expand Up @@ -69,7 +70,8 @@ class User(db.Model, UserMixin, CrudMixin):
# User authentication information. The collation="NOCASE" is required
# to search case insensitively when USER_IFIND_MODE is "nocase_collation".
email = db.Column(
CI_String(255, collate="NOCASE"), nullable=False, unique=True
CI_String(255, collate="NOCASE"),
nullable=False, unique=True
)
email_confirmed_at = db.Column(db.DateTime())
password = db.Column(db.String(255), nullable=False, server_default="")
Expand Down

0 comments on commit 725694c

Please sign in to comment.