This commit is contained in:
@@ -52,9 +52,9 @@
|
|||||||
- name: Verify that web and db services are running
|
- name: Verify that web and db services are running
|
||||||
ansible.builtin.assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- pythonapp.State == 'running'
|
- "movie-db-web" in compose_output.services
|
||||||
vars:
|
- compose_output.services["movie-db-web"].state == "running"
|
||||||
pythonapp: >-
|
- "movie-db-db" in compose_output.services
|
||||||
{{ compose_output.containers | selectattr("Service","equalto", "movie-db-web") | first }}
|
- compose_output.services["movie-db-db"].state == "running"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
10
main.py
10
main.py
@@ -3,6 +3,7 @@ from flask import render_template, redirect, url_for, flash
|
|||||||
from flask_login import LoginManager, login_user, logout_user, login_required, current_user
|
from flask_login import LoginManager, login_user, logout_user, login_required, current_user
|
||||||
|
|
||||||
import moviedb_func
|
import moviedb_func
|
||||||
|
from moviedb_func import delete_movie_by_id
|
||||||
|
|
||||||
app = flask.Flask(__name__)
|
app = flask.Flask(__name__)
|
||||||
app.secret_key = "Start1234!"
|
app.secret_key = "Start1234!"
|
||||||
@@ -121,6 +122,15 @@ def save_manual():
|
|||||||
|
|
||||||
return redirect("/")
|
return redirect("/")
|
||||||
|
|
||||||
|
@app.route("/delete_movie/<int:movie_id>", methods=["POST"])
|
||||||
|
@login_required
|
||||||
|
def delete_movie(movie_id):
|
||||||
|
if moviedb_func.delete_movie_by_id(movie_id):
|
||||||
|
flash("Film erfolgreich gelöscht!")
|
||||||
|
else:
|
||||||
|
flash("Fehler beim Löschen des Films.")
|
||||||
|
return redirect(url_for("index"))
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
moviedb_func.create_movie_database()
|
moviedb_func.create_movie_database()
|
||||||
|
|||||||
@@ -415,6 +415,12 @@ def get_user_by_id(user_id, db_name="movie_db.db"):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
def delete_movie_by_id(movie_id: int, db_name: str = "movie_db.db"):
|
||||||
|
SQL = "DELETE FROM movie_list WHERE id = ?"
|
||||||
|
with DBcm.UseDatabase(db_name) as db:
|
||||||
|
db.execute(SQL, (movie_id,))
|
||||||
|
return db.rowcount > 0
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
create_movie_database()
|
create_movie_database()
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
<th>Regie</th>
|
<th>Regie</th>
|
||||||
<th>Medium</th>
|
<th>Medium</th>
|
||||||
<th>Erscheinungsjahr</th>
|
<th>Erscheinungsjahr</th>
|
||||||
|
<th>Aktionen</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@@ -32,6 +33,11 @@
|
|||||||
<td>{{list_all.get("regie")}}</td>
|
<td>{{list_all.get("regie")}}</td>
|
||||||
<td>{{list_all.get("medium")}}</td>
|
<td>{{list_all.get("medium")}}</td>
|
||||||
<td>{{list_all.get("release_year")}}</td>
|
<td>{{list_all.get("release_year")}}</td>
|
||||||
|
<td>
|
||||||
|
<form action="{{ url_for('delete_movie', movie_id=list_all.get('id')) }}" method="post">
|
||||||
|
<button type="submit" class="btn btn-danger btn-sm">X</button>
|
||||||
|
</form>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
Reference in New Issue
Block a user