Currently in a lot of parts of the code (Ex: all of the database files), we take the data directly from JSONs and pass it around into the controller or managers. Instead of passing this into the controllers, managers, it would be nice to pass the JSON into a pydantic model instead.
Example:
In database/users.py, the _new_user() function looks like this:
@classmethod
def _new_user(cls, _id: str, username: str, vendor_type: str) -> JSONDict:
return {
"_id": _id,
"username": username,
"contracts": [],
"group": Groups.CUSTOMER,
"vendor_type": vendor_type,
"roles": []
}
Instead we can define a model and use that
class MongoUser(BaseModel):
_id: str
username: str
contracts: List<str>
...
@classmethod
def _new_user(cls, _id: str, username: str, vendor_type: str) -> JSONDict:
return MongoUser(...)
Currently in a lot of parts of the code (Ex: all of the database files), we take the data directly from JSONs and pass it around into the controller or managers. Instead of passing this into the controllers, managers, it would be nice to pass the JSON into a pydantic model instead.
Example:
In
database/users.py, the_new_user()function looks like this:Instead we can define a model and use that