mirror of
https://github.com/StefBuwalda/ProjectIOT.git
synced 2025-10-30 11:19:57 +00:00
Merge branch 'main' of https://github.com/StefBuwalda/ProjectIOT
This commit is contained in:
@@ -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
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user