Пример #1
0
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)
Пример #2
0
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)
Пример #3
0
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
Пример #4
0
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
Пример #5
0
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