Esempio n. 1
0
 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()
Esempio n. 2
0
 def __init__(self):
     self.crud = events_crud
     self.participants = CRUD(participants_collection)
Esempio n. 3
0
 def __init__(self):
     self.crud = events_crud
     self.users = CRUD(users_collection)
     self.participants = CRUD(participants_collection)
     self.organizations = CRUD(organizations_collection)
Esempio n. 4
0
"""
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())
Esempio n. 5
0
    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):
Esempio n. 6
0
 def __init__(self):
     """
     Crud instance of the user collection.
     """
     self.crud = CRUD(users_collection)
Esempio n. 7
0
 def __init__(self):
     """
     Crud instance of the participants collection.
     """
     self.crud = CRUD(participants_collection)