Afegir control visual de les lletres per a partitures
This commit is contained in:
@@ -33,11 +33,25 @@ def set_lyric(
|
||||
lyric_id: int,
|
||||
title: Annotated[str, Form()],
|
||||
content: Annotated[str, Form()],
|
||||
max_columns: Annotated[str | None, Form()] = None,
|
||||
):
|
||||
lyric = lyrics_service.get_lyric_by_id(lyric_id=lyric_id, tema_id=tema_id)
|
||||
if not lyric:
|
||||
raise HTTPException(status_code=404, detail="Could not find lyric!")
|
||||
new_lyric = lyrics_service.update_lyric(lyric=lyric, title=title, content=content)
|
||||
|
||||
# Parse max_columns from string to int if provided
|
||||
max_columns_int = None
|
||||
if max_columns is not None and max_columns.strip():
|
||||
try:
|
||||
max_columns_int = int(max_columns.strip())
|
||||
except ValueError:
|
||||
raise HTTPException(status_code=400, detail="max_columns must be a valid integer")
|
||||
|
||||
try:
|
||||
new_lyric = lyrics_service.update_lyric(lyric=lyric, title=title, content=content, max_columns=max_columns_int)
|
||||
except ValueError as e:
|
||||
raise HTTPException(status_code=400, detail=str(e))
|
||||
|
||||
return lyrics_fragments.lyric(request=request, logged_in=logged_in, lyric=new_lyric)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user