fixed some bugs
This commit is contained in:
@@ -346,6 +346,30 @@ def create_app(
|
||||
def my_dub_shares(user: AuthenticatedUser = Depends(current_user)) -> List[UserDubShareSummary]:
|
||||
return [UserDubShareSummary(**row) for row in video_repository.list_user_dub_shares(user.id)]
|
||||
|
||||
@application.delete("/api/v1/me/results/{attempt_id}", status_code=204)
|
||||
def delete_my_result(
|
||||
attempt_id: str,
|
||||
user: AuthenticatedUser = Depends(current_user),
|
||||
) -> Response:
|
||||
deleted_result = video_repository.delete_user_result(user.id, attempt_id)
|
||||
if deleted_result is None:
|
||||
raise HTTPException(status_code=404, detail="Test result was not found.")
|
||||
if deleted_result["audio_filename"]:
|
||||
(service_settings.attempts_dir / Path(deleted_result["audio_filename"]).name).unlink(missing_ok=True)
|
||||
return Response(status_code=204)
|
||||
|
||||
@application.delete("/api/v1/me/dub-shares/{share_id}", status_code=204)
|
||||
def delete_my_dub_share(
|
||||
share_id: str,
|
||||
user: AuthenticatedUser = Depends(current_user),
|
||||
) -> Response:
|
||||
audio_filenames = video_repository.delete_user_dub_share(user.id, share_id)
|
||||
if audio_filenames is None:
|
||||
raise HTTPException(status_code=404, detail="Dubbing share was not found.")
|
||||
for filename in audio_filenames:
|
||||
(service_settings.dub_shares_dir / Path(filename).name).unlink(missing_ok=True)
|
||||
return Response(status_code=204)
|
||||
|
||||
@application.get("/admin", include_in_schema=False)
|
||||
def admin_page() -> FileResponse:
|
||||
page = static_dir / "admin.html"
|
||||
|
||||
Reference in New Issue
Block a user