2020-04-06 11:36:29 +02:00
|
|
|
from pydantic import BaseModel, EmailStr
|
2020-01-19 22:40:50 +01:00
|
|
|
|
|
|
|
|
|
|
|
# Shared properties
|
|
|
|
class UserBase(BaseModel):
|
2024-02-25 19:39:33 +01:00
|
|
|
email: EmailStr | None = None
|
|
|
|
is_active: bool | None = True
|
:recycle: Refactor backend, settings, DB sessions, types, configs, plugins (#158)
* :recycle: Refactor backend, update DB session handling
* :sparkles: Add mypy config and plugins
* :heavy_plus_sign: Use Python-jose instead of PyJWT
as it has some extra functionalities and features
* :sparkles: Add/update scripts for test, lint, format
* :wrench: Update lint and format configs
* :art: Update import format, comments, and types
* :art: Add types to config
* :sparkles: Add types for all the code, and small fixes
* :art: Use global imports to simplify exploring with Jupyter
* :recycle: Import schemas and models, instead of each class
* :truck: Rename db_session to db for simplicity
* :pushpin: Update dependencies installation for testing
2020-04-20 19:03:13 +02:00
|
|
|
is_superuser: bool = False
|
2024-02-25 19:39:33 +01:00
|
|
|
full_name: str | None = None
|
2020-01-19 22:40:50 +01:00
|
|
|
|
|
|
|
|
|
|
|
# Properties to receive via API on creation
|
2020-04-17 09:20:00 +02:00
|
|
|
class UserCreate(UserBase):
|
2020-04-06 11:36:29 +02:00
|
|
|
email: EmailStr
|
2020-01-19 22:40:50 +01:00
|
|
|
password: str
|
|
|
|
|
|
|
|
|
|
|
|
# Properties to receive via API on update
|
2020-04-17 09:20:00 +02:00
|
|
|
class UserUpdate(UserBase):
|
2024-02-25 19:39:33 +01:00
|
|
|
password: str | None = None
|
2020-01-19 22:40:50 +01:00
|
|
|
|
|
|
|
|
2020-04-17 09:20:00 +02:00
|
|
|
class UserInDBBase(UserBase):
|
2024-02-25 19:39:33 +01:00
|
|
|
id: int | None = None
|
2020-04-17 09:20:00 +02:00
|
|
|
|
|
|
|
class Config:
|
|
|
|
orm_mode = True
|
|
|
|
|
|
|
|
|
2020-01-19 22:40:50 +01:00
|
|
|
# Additional properties to return via API
|
2020-04-17 09:20:00 +02:00
|
|
|
class User(UserInDBBase):
|
2020-01-19 22:40:50 +01:00
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
# Additional properties stored in DB
|
2020-04-17 09:20:00 +02:00
|
|
|
class UserInDB(UserInDBBase):
|
2020-01-19 22:40:50 +01:00
|
|
|
hashed_password: str
|