Skip to content

Commit

Permalink
Move Neomodel class extensions to schemas.py
Browse files Browse the repository at this point in the history
  • Loading branch information
DMalone87 committed Sep 29, 2024
1 parent 8df5a6c commit 300f1d4
Show file tree
Hide file tree
Showing 9 changed files with 265 additions and 204 deletions.
2 changes: 1 addition & 1 deletion backend/database/models/agency.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from backend.database.neo_classes import JsonSerializable, PropertyEnum
from backend.schemas import JsonSerializable, PropertyEnum
from neomodel import (
StructuredNode,
StructuredRel,
Expand Down
2 changes: 1 addition & 1 deletion backend/database/models/attachment.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from backend.database.neo_classes import JsonSerializable
from backend.schemas import JsonSerializable
from neomodel import (
StringProperty,
UniqueIdProperty,
Expand Down
2 changes: 1 addition & 1 deletion backend/database/models/complaint.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Define the Classes for Complaints."""
from backend.database.neo_classes import JsonSerializable, PropertyEnum
from backend.schemas import JsonSerializable, PropertyEnum
from neomodel import (
StructuredNode,
StructuredRel,
Expand Down
2 changes: 1 addition & 1 deletion backend/database/models/litigation.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from backend.database.neo_classes import JsonSerializable, PropertyEnum
from backend.schemas import JsonSerializable, PropertyEnum
from neomodel import (
StructuredNode,
StringProperty,
Expand Down
2 changes: 1 addition & 1 deletion backend/database/models/officer.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from backend.database.neo_classes import JsonSerializable, PropertyEnum
from backend.schemas import JsonSerializable, PropertyEnum

from neomodel import (
StructuredNode,
Expand Down
6 changes: 5 additions & 1 deletion backend/database/models/partner.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations # allows type hinting of class itself
# from ..core import db, CrudMixin
from backend.database.neo_classes import JsonSerializable, PropertyEnum
from backend.schemas import JsonSerializable, PropertyEnum
from datetime import datetime
from neomodel import (
StructuredNode, StructuredRel,
Expand Down Expand Up @@ -95,6 +95,10 @@ def __repr__(self):


class Partner(StructuredNode, JsonSerializable):
__property_order__ = [
"uid", "name", "url",
"contact_email"
]
uid = UniqueIdProperty()

name = StringProperty(unique_index=True)
Expand Down
18 changes: 17 additions & 1 deletion backend/database/models/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import bcrypt
from werkzeug.security import generate_password_hash, check_password_hash
from backend.database.neo_classes import JsonSerializable, PropertyEnum
from backend.schemas import JsonSerializable, PropertyEnum
from neomodel import (
Relationship, StructuredNode,
StringProperty, DateProperty, BooleanProperty,
Expand Down Expand Up @@ -30,6 +30,13 @@ def get_value(self):

# Define the User data-model.
class User(StructuredNode, JsonSerializable):
__hidden_properties__ = ["password_hash"]
__property_order__ = [
"uid", "first_name", "last_name",
"email", "email_confirmed_at",
"phone_number", "role", "active"
]

uid = UniqueIdProperty()
active = BooleanProperty(default=True)

Expand Down Expand Up @@ -94,6 +101,15 @@ def send_password_reset(self):
"""
pass

@property
def role_enum(self) -> UserRole:
"""
Get the user's role as an enum.
Returns:
UserRole: The user's role as an enum.
"""
return UserRole(self.role)

@classmethod
def hash_password(cls, pw: str) -> str:
"""
Expand Down
192 changes: 0 additions & 192 deletions backend/database/neo_classes.py

This file was deleted.

Loading

0 comments on commit 300f1d4

Please sign in to comment.