-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
46 changed files
with
645 additions
and
262 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
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,34 @@ | ||
from sqlalchemy import inspect | ||
from sqlalchemy.orm.properties import ColumnProperty | ||
|
||
from . import db | ||
|
||
|
||
class LogRecordResidents(db.Model): | ||
__tablename__ = "log_record_residents" | ||
|
||
id = db.Column(db.Integer, primary_key=True, nullable=False) | ||
log_record_id = db.Column( | ||
db.Integer, db.ForeignKey("log_records.log_id"), nullable=False | ||
) | ||
resident_id = db.Column(db.Integer, db.ForeignKey("residents.id"), nullable=False) | ||
|
||
def to_dict(self, include_relationships=False): | ||
# define the entities table | ||
cls = type(self) | ||
|
||
mapper = inspect(cls) | ||
formatted = {} | ||
for column in mapper.attrs: | ||
field = column.key | ||
attr = getattr(self, field) | ||
# if it's a regular column, extract the value | ||
if isinstance(column, ColumnProperty): | ||
formatted[field] = attr | ||
# otherwise, it's a relationship field | ||
# (currently not applicable, but may be useful for entity groups) | ||
elif include_relationships: | ||
# recursively format the relationship | ||
# don't format the relationship's relationships | ||
formatted[field] = [obj.to_dict() for obj in attr] | ||
return formatted |
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
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 |
---|---|---|
@@ -1,8 +1,11 @@ | ||
class UserDTO: | ||
def __init__(self, id, first_name, last_name, email, role, user_status): | ||
def __init__( | ||
self, id, first_name, last_name, email, role, user_status, last_modified | ||
): | ||
self.id = id | ||
self.first_name = first_name | ||
self.last_name = last_name | ||
self.email = email | ||
self.role = role | ||
self.user_status = user_status | ||
self.last_modified = last_modified |
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
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
Oops, something went wrong.