This commit is contained in:
@@ -1,11 +1,13 @@
|
||||
|
||||
from typing import List
|
||||
|
||||
from fastapi import APIRouter, HTTPException
|
||||
from fastapi import APIRouter, status, HTTPException
|
||||
|
||||
from kontor_model.db.models.media import MediaLofi
|
||||
from src.db.session import SessionDep
|
||||
from src.core.log_conf import logger
|
||||
from kontor_model.schema.media.lofi import MediaLofiResponse, lofi_to_response
|
||||
from kontor_model.db.repository.media.lofi import delete_medialofi
|
||||
|
||||
|
||||
router = APIRouter()
|
||||
@@ -40,3 +42,14 @@ def get_lofi(lofi_id: str, db: SessionDep) -> MediaLofiResponse:
|
||||
raise HTTPException(status_code=404, detail="MediaLofi could not be found")
|
||||
response = lofi_to_response(lofi)
|
||||
return response
|
||||
|
||||
@router.delete("/lofi/{lofi_id}", status_code=status.HTTP_204_NO_CONTENT)
|
||||
def delete_lofi(lofi_id: str, db: SessionDep):
|
||||
"""
|
||||
Delete MediaFile by given id.
|
||||
"""
|
||||
lofi = db.get(MediaLofi, lofi_id)
|
||||
if not lofi:
|
||||
raise HTTPException(status_code=404, detail="MediaLofi could not be found")
|
||||
logger.info("delete MediaLofi: %s", lofi_id)
|
||||
delete_medialofi(db=db, lofi_id=lofi.id)
|
||||
|
||||
Reference in New Issue
Block a user