Rendering code refactor
This commit is contained in:
@@ -48,6 +48,12 @@ def contingut(request: Request, logged_in: auth.LoggedIn, tema_id: int):
|
||||
|
||||
@router.delete("/api/tema/{tema_id}")
|
||||
def delete_tema(_: auth.RequireLogin, tema_id: int):
|
||||
tema = temes_q.get_tema_by_id(tema_id)
|
||||
if not tema:
|
||||
raise HTTPException(status_code=404, detail="Could not find tune")
|
||||
tema = temes_q.tema_compute_stats(tema=tema)
|
||||
if tema.stats:
|
||||
raise HTTPException(status_code=400, detail="Can't delete a tune that has been played in a set!")
|
||||
temes_w.delete_tema(tema_id=tema_id)
|
||||
files_service.clean_orphan_files()
|
||||
return HTMLResponse(headers={
|
||||
|
||||
Reference in New Issue
Block a user