def create_value(value: schemas.ValueCreate, db: Session = Depends(get_db), current_user: schemas.User = Depends( crud.get_current_active_user), request: Request = Request): if current_user and crud.is_permitted(request.method, current_user): return crud.create_value(db=db, value=value)
def create_principle(principle: schemas.PrincipleCreate, db: Session = Depends(get_db), current_user: schemas.User = Depends( crud.get_current_active_user), request: Request = Request): if current_user and crud.is_permitted(request.method, current_user): return crud.create_principle(db=db, principle=principle)
def read_values(skip: int = 0, limit: int = 100, db: Session = Depends(get_db), current_user: schemas.User = Depends( crud.get_current_active_user), request: Request = Request): if current_user and crud.is_permitted(request.method, current_user): values = crud.get_values(db, skip=skip, limit=limit) return values
def read_value(value_id: int, db: Session = Depends(get_db), current_user: schemas.User = Depends( crud.get_current_active_user), request: Request = Request): if current_user and crud.is_permitted(request.method, current_user): db_value = crud.get_value(db, value_id=value_id) if db_value is None: raise HTTPException(status_code=404, detail="Value not found") return db_value
def delete_principle(principle_id: int, db: Session = Depends(get_db), current_user: schemas.User = Depends( crud.get_current_active_user), request: Request = Request): if current_user and crud.is_permitted(request.method, current_user): db_principle = crud.delete_principle(db, principle_id=principle_id) if db_principle is None: raise HTTPException(status_code=404, detail="Principle not found") return db_principle