backend for queues & minor front tweaks
This commit is contained in:
41
backend/app/views/queue/api.py
Normal file
41
backend/app/views/queue/api.py
Normal file
@ -0,0 +1,41 @@
|
||||
from datetime import datetime, timedelta, timezone
|
||||
from typing import Annotated, Union
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from fastapi import APIRouter, Depends, HTTPException, status
|
||||
from fastapi.security import OAuth2PasswordRequestForm
|
||||
|
||||
|
||||
from pydantic import BaseModel
|
||||
|
||||
from ...config import jwt_config
|
||||
from ...dependencies import get_db
|
||||
from . import schemas
|
||||
from . import services
|
||||
|
||||
from ..auth import services as auth_services
|
||||
from ..auth import schemas as auth_schemas
|
||||
|
||||
|
||||
router = APIRouter(
|
||||
prefix="/queue",
|
||||
tags=["queue"],
|
||||
dependencies=[Depends(get_db)],
|
||||
responses={404: {"description": "Not found"}},
|
||||
)
|
||||
|
||||
|
||||
@router.get("/")
|
||||
async def user_queues_list(
|
||||
queues: Annotated[schemas.Queue, Depends(services.get_user_queues)],
|
||||
) -> list[schemas.QueueInDb]:
|
||||
return queues
|
||||
|
||||
|
||||
@router.post("/")
|
||||
async def create_queue(
|
||||
new_queue: schemas.Queue,
|
||||
current_user: Annotated[auth_schemas.User, Depends(auth_services.get_current_user)],
|
||||
db: Annotated[Session, Depends(get_db)],
|
||||
) -> schemas.QueueInDb:
|
||||
return services.create_queue(new_queue=new_queue, current_user=current_user, db=db)
|
||||
Reference in New Issue
Block a user