コード例 #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()
コード例 #2
0
 def __init__(self):
     self.crud = events_crud
     self.participants = CRUD(participants_collection)
コード例 #3
0
 def __init__(self):
     self.crud = events_crud
     self.users = CRUD(users_collection)
     self.participants = CRUD(participants_collection)
     self.organizations = CRUD(organizations_collection)
コード例 #4
0
ファイル: utils.py プロジェクト: debuggers-master/unu-api
"""
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())
コード例 #5
0
ファイル: services.py プロジェクト: debuggers-master/unu-api
    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):
コード例 #6
0
 def __init__(self):
     """
     Crud instance of the user collection.
     """
     self.crud = CRUD(users_collection)
コード例 #7
0
 def __init__(self):
     """
     Crud instance of the participants collection.
     """
     self.crud = CRUD(participants_collection)