This commit is contained in:
2025-05-28 11:59:35 +02:00
parent 42ea35bd47
commit d5b42a7550
2 changed files with 16 additions and 13 deletions

2
app.py
View File

@@ -2,7 +2,7 @@ from application import app
from application.api.views import api_blueprint
from application.auth.views import auth_blueprint
from application.dashboard.views import dash_blueprint
from flask import redirect, url_for, render_template
from flask import redirect, url_for
app.register_blueprint(api_blueprint, url_prefix="/api")
app.register_blueprint(auth_blueprint, url_prefix="/auth")

View File

@@ -7,17 +7,18 @@ from application.dashboard.forms import npForm
dash_blueprint = Blueprint("dash", __name__, template_folder="templates")
@dash_blueprint.route('/dashboard')
#@login_required
@dash_blueprint.route("/dashboard")
# @login_required
def dashboard():
Plates = AllowedPlate.query.all()
logs = LoggedItem.query.order_by(LoggedItem.dateLogged.desc()).limit(50).all()
logs = (
LoggedItem.query.order_by(LoggedItem.dateLogged.desc()).limit(50).all()
)
return render_template("dashboard.html", plates=Plates, logs=logs)
@dash_blueprint.route('/add', methods=['GET', 'POST'])
#@login_required
@dash_blueprint.route("/add", methods=["GET", "POST"])
# @login_required
def add():
Plates = AllowedPlate.query.all()
form = npForm()
@@ -28,13 +29,15 @@ def add():
db.session.add(ap)
db.session.commit()
if request.headers.get('X-Requested-With') == 'XMLHttpRequest':
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]
})
return jsonify(
{
"plates": [
{"id": p.id, "plate": p.plate} for p in plates
]
}
)
Plates = AllowedPlate.query.order_by(AllowedPlate.id).all()
return render_template("add.html", form=form, plates=Plates)