def __init__(self) -> None: """ Crud instances of the collections needed. """ self.crud = CRUD(organizations_collection) self.users = CRUD(users_collection) self.events = CRUD(events_collection) self.backgroud_task = BackgroundTasks()
def __init__(self): self.crud = events_crud self.participants = CRUD(participants_collection)
def __init__(self): self.crud = events_crud self.users = CRUD(users_collection) self.participants = CRUD(participants_collection) self.organizations = CRUD(organizations_collection)
""" Commun utils to manage events. """ from uuid import uuid4 from db.db import get_collection, CRUD ########################################### ## Event Collection Instance ## ########################################### EVENTS_COLLECTION_NAME = "events" events_collection = get_collection(EVENTS_COLLECTION_NAME) events_crud = CRUD(events_collection) ########################################### ## Common Event Utilities ## ########################################### def _make_query(event_id: str) -> dict: """ Return the event query: {"eventId": event_id} """ return {"eventId": event_id} def _uuid() -> str: """ Return a unique uuid """ return str(uuid4())
detail="Invalid credentials", headers={"WWW-Authenticate": "Bearer"}, ) ########################################### ## Security Instances ## ########################################### pwd_context = CryptContext(schemes=["bcrypt"]) oauth2_scheme = OAuth2PasswordBearer(tokenUrl="login") ########################################### ## Users CRUD Instance ## ########################################### users_collection = get_collection("users") users_crud = CRUD(users_collection) ########################################### ## Token Schemas ## ########################################### class Token(BaseModel): """ Token base schema """ access_token: str = Field(description="The encoded jwt") token_type: str = Field(description="The token type: 'Bearer'") class TokenData(BaseModel):
def __init__(self): """ Crud instance of the user collection. """ self.crud = CRUD(users_collection)
def __init__(self): """ Crud instance of the participants collection. """ self.crud = CRUD(participants_collection)