This commit is contained in:
@@ -1247,6 +1247,31 @@ def register_web_routes(app, dependencies):
|
||||
async def api_movie_date_options(imdb_id: str):
|
||||
return {"options": [], "message": "Date options not available in web container. Use core container on port 8085."}
|
||||
|
||||
@app.delete("/api/movies/{imdb_id}")
|
||||
async def api_delete_movie(imdb_id: str):
|
||||
"""Delete a movie from the database"""
|
||||
db = dependencies["db"]
|
||||
|
||||
try:
|
||||
# Use the existing database method
|
||||
deleted = db.delete_movie(imdb_id)
|
||||
|
||||
if deleted:
|
||||
return {
|
||||
"success": True,
|
||||
"status": "success",
|
||||
"message": f"Deleted movie {imdb_id}",
|
||||
"imdb_id": imdb_id
|
||||
}
|
||||
else:
|
||||
raise HTTPException(status_code=404, detail="Movie not found")
|
||||
|
||||
except HTTPException:
|
||||
raise # Re-raise HTTP exceptions
|
||||
except Exception as e:
|
||||
print(f"❌ Error deleting movie: {e}")
|
||||
raise HTTPException(status_code=500, detail=f"Failed to delete movie: {str(e)}")
|
||||
|
||||
# TV series endpoints
|
||||
@app.get("/api/series")
|
||||
async def api_series_list(skip: int = 0, limit: int = 50, search: str = None,
|
||||
|
||||
@@ -457,6 +457,6 @@
|
||||
<!-- Toast Notifications -->
|
||||
<div class="toast-container" id="toast-container"></div>
|
||||
|
||||
<script src="/static/js/app.js?v=2.8.2-20241025-auth-fix"></script>
|
||||
<script src="/static/js/app.js?v=2.8.2-20241025-movies-fix"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1322,24 +1322,15 @@ async function deleteMovie(imdbId) {
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await fetch(`/api/movies/${imdbId}`, {
|
||||
method: 'DELETE',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
const result = await apiCall(`/api/movies/${imdbId}`, {
|
||||
method: 'DELETE'
|
||||
});
|
||||
|
||||
const result = await response.json();
|
||||
|
||||
if (response.ok && result.success) {
|
||||
if (result.success) {
|
||||
showToast(`✅ Movie deleted successfully`, 'success');
|
||||
|
||||
// Refresh the movies table
|
||||
loadMovies(currentMoviesPage);
|
||||
|
||||
} else {
|
||||
const errorMsg = result.message || result.error || 'Unknown error';
|
||||
showToast(`❌ Failed to delete movie: ${errorMsg}`, 'error');
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user