diff --git a/application/auth/templates/login.html b/application/auth/templates/login.html index 1f6f76f..9321ce2 100644 --- a/application/auth/templates/login.html +++ b/application/auth/templates/login.html @@ -80,6 +80,24 @@ + + + + + + +
+ {% for message in get_flashed_messages() %} + + {% endfor %} +
\ No newline at end of file diff --git a/application/auth/views.py b/application/auth/views.py index 44db250..0b9879a 100644 --- a/application/auth/views.py +++ b/application/auth/views.py @@ -29,6 +29,7 @@ def login(): @login_required def logout(): logout_user() + flash("Succesfully logged out") return redirect("/") diff --git a/application/dashboard/templates/add.html b/application/dashboard/templates/add.html index d58cd74..39330db 100644 --- a/application/dashboard/templates/add.html +++ b/application/dashboard/templates/add.html @@ -55,34 +55,4 @@ - - {% endblock %} \ No newline at end of file diff --git a/application/dashboard/templates/flash.html b/application/dashboard/templates/flash.html new file mode 100644 index 0000000..7fa451b --- /dev/null +++ b/application/dashboard/templates/flash.html @@ -0,0 +1,18 @@ + + + + + + +
+ {% for message in get_flashed_messages() %} + + {% endfor %} +
\ No newline at end of file diff --git a/application/dashboard/views.py b/application/dashboard/views.py index fb0c594..c8cc50f 100644 --- a/application/dashboard/views.py +++ b/application/dashboard/views.py @@ -7,11 +7,14 @@ from flask import ( send_from_directory, redirect, url_for + send_file, ) from application.dashboard.models import AllowedPlate, LoggedItem from application import db +import application from application.dashboard.forms import npForm from flask_login import login_required +from io import BytesIO dash_blueprint = Blueprint("dash", __name__, template_folder="templates") @@ -29,7 +32,6 @@ def dashboard(): @dash_blueprint.route("/add", methods=["GET", "POST"]) #@login_required def add(): - Plates = AllowedPlate.query.all() form = npForm() if form.validate_on_submit(): @@ -43,18 +45,8 @@ def add(): db.session.add(ap) db.session.commit() flash("Numberplate succesfully added") - - # Update the list on the page with JavaScript - if request.headers.get("X-Requested-With") == "XMLHttpRequest": - plates = AllowedPlate.query.order_by(AllowedPlate.id).all() - return jsonify( - { - "plates": [ - {"id": p.id, "plate": p.plate} for p in plates - ] - } - ) # form wasn't valid + Plates = AllowedPlate.query.all() return render_template( "add.html", form=npForm(formdata=None), plates=Plates )