This commit is contained in:
gavinvanderbij
2025-06-06 08:41:55 +02:00
5 changed files with 41 additions and 42 deletions

View File

@@ -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
)