This commit is contained in:
@@ -14,9 +14,6 @@ ENV PATH="/root/.local/bin:${PATH}"
|
||||
WORKDIR /app
|
||||
|
||||
COPY ./pyproject.toml .
|
||||
#RUN --mount=type=bind,source=/home/tpeetz/projects/kontor/kontor-model,target=/container/kontor-model uv add /container/kontor-model
|
||||
#COPY ../kontor-model/ /container
|
||||
RUN uv add /container/kontor-model
|
||||
RUN uv sync
|
||||
|
||||
# ------------------------------- Production Stage ------------------------------ ##
|
||||
|
||||
@@ -32,5 +32,13 @@ dependencies = [
|
||||
"kontor-model",
|
||||
]
|
||||
|
||||
[tool.uv.sources]
|
||||
kontor-model = { path = "../kontor-model", editable = true }
|
||||
[[tool.uv.index]]
|
||||
name = "nexus"
|
||||
url = "https://nexus.thpeetz.de/repository/pypi-group/simple"
|
||||
publish-url = "https://nexus.thpeetz.de/repository/pypi-internal/"
|
||||
default = true
|
||||
|
||||
|
||||
[[tool.uv.index]]
|
||||
name = "nexus-proxy"
|
||||
url = "https://nexus.thpeetz.de/repository/pypi-proxy/simple"
|
||||
|
||||
@@ -6,8 +6,16 @@ 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
|
||||
from kontor_model.schema.media.lofi import (
|
||||
MediaLofiModel,
|
||||
MediaLofiResponse,
|
||||
lofi_to_response,
|
||||
lofi_to_model
|
||||
)
|
||||
from kontor_model.db.repository.media.lofi import (
|
||||
import_medialofi,
|
||||
delete_medialofi
|
||||
)
|
||||
|
||||
|
||||
router = APIRouter()
|
||||
@@ -53,3 +61,31 @@ def delete_lofi(lofi_id: str, db: SessionDep):
|
||||
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)
|
||||
|
||||
@router.put("/lofi/{lofi_id}", response_model=MediaLofiResponse)
|
||||
def update_lofi(lofi_id: str, db: SessionDep, info: MediaLofiResponse) -> MediaLofiResponse:
|
||||
"""
|
||||
Update MediaLofi with given id and data.
|
||||
"""
|
||||
media_lofi = db.get(MediaLofi, lofi_id)
|
||||
if not media_lofi:
|
||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="MediaLofi could not be found")
|
||||
lofi_to_model(info, media_lofi)
|
||||
db.add(media_lofi)
|
||||
db.commit()
|
||||
media_lofi = db.get(MediaLofi, lofi_id)
|
||||
if not media_lofi:
|
||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="MediaLofi could not be found")
|
||||
response = lofi_to_response(media_lofi)
|
||||
return response
|
||||
|
||||
|
||||
@router.post("/lofi", status_code=status.HTTP_201_CREATED)
|
||||
def add_lofi(new_lofi: MediaLofiModel, db: SessionDep) -> MediaLofiResponse:
|
||||
logger.info("add medialofi %s", new_lofi)
|
||||
try:
|
||||
medialofi: MediaLofi = import_medialofi(db, new_lofi)
|
||||
except:
|
||||
raise HTTPException(status_code=409, detail="MediaLofi duplicate")
|
||||
response = lofi_to_response(medialofi)
|
||||
return response
|
||||
|
||||
Generated
+1005
-594
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user