55 lines
1.1 KiB
Python
Raw Permalink Normal View History

2023-10-14 23:04:19 +02:00
from pydantic import BaseModel, EmailStr
2023-10-13 18:17:38 +02:00
from pydantic_mongo import AbstractRepository, ObjectIdField
2023-10-25 23:42:34 +02:00
from datetime import datetime, date
2023-10-10 22:39:23 +02:00
2023-10-11 23:45:12 +02:00
class User(BaseModel):
2023-10-13 18:17:38 +02:00
id: ObjectIdField = None
2023-10-10 22:39:23 +02:00
username: str
2023-10-11 23:45:12 +02:00
password: str
2023-10-25 23:42:34 +02:00
firstName: str = ""
name: str = ""
2023-10-14 22:14:29 +02:00
roles: str = "User"
2023-10-22 18:58:35 +02:00
status: int = 0
2023-10-14 23:04:19 +02:00
email: EmailStr
2025-01-03 14:47:31 +01:00
birth: datetime | None = None
2023-10-23 23:45:13 +02:00
created_at: datetime = datetime.today()
2023-10-25 23:42:34 +02:00
connected_at: datetime | None = None
2023-11-04 20:45:07 +01:00
updated_at: datetime | None = None
2023-10-25 23:42:34 +02:00
deleted_at: datetime | None = None
2023-11-04 20:45:07 +01:00
disabled_at: datetime | None = None
2023-10-10 22:39:23 +02:00
2023-10-13 14:59:57 +02:00
class UserOut(BaseModel):
2023-10-13 18:17:38 +02:00
id: ObjectIdField = None
2023-10-13 14:59:57 +02:00
username: str
roles: str
2023-10-25 23:42:34 +02:00
firstName: str
name: str
2023-10-22 18:58:35 +02:00
status: int = 0
2023-10-14 23:04:19 +02:00
email: EmailStr
2023-10-13 14:59:57 +02:00
2023-10-14 21:28:21 +02:00
class UserIn(BaseModel):
username: str
2023-10-25 23:42:34 +02:00
name: str
firstName: str
2023-10-14 21:28:21 +02:00
roles: str
password: str
2023-10-25 23:42:34 +02:00
birth: str
2023-10-14 23:04:19 +02:00
email: EmailStr
2023-10-14 21:28:21 +02:00
2023-10-14 22:14:29 +02:00
class UserCreate(BaseModel):
username: str
password: str
2023-10-14 23:04:19 +02:00
email: EmailStr
2023-10-14 22:14:29 +02:00
2023-10-11 23:45:12 +02:00
class UserInDB(User):
2023-10-13 18:17:38 +02:00
password: str
2023-11-02 23:54:40 +01:00
class UserIDS(BaseModel):
ids: list[str]
2023-10-13 18:17:38 +02:00
class UserRepository(AbstractRepository[User]):
class Meta:
collection_name = "users"