diff --git a/app.py b/app.py index 44067d6..dc8f7eb 100644 --- a/app.py +++ b/app.py @@ -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") diff --git a/application/dashboard/views.py b/application/dashboard/views.py index 9044e15..eca9e8f 100644 --- a/application/dashboard/views.py +++ b/application/dashboard/views.py @@ -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) -