mirror of
https://github.com/StefBuwalda/ProjectIOT.git
synced 2025-10-30 11:19:57 +00:00
Refactor
This commit is contained in:
2
app.py
2
app.py
@@ -2,7 +2,7 @@ from application import app
|
|||||||
from application.api.views import api_blueprint
|
from application.api.views import api_blueprint
|
||||||
from application.auth.views import auth_blueprint
|
from application.auth.views import auth_blueprint
|
||||||
from application.dashboard.views import dash_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(api_blueprint, url_prefix="/api")
|
||||||
app.register_blueprint(auth_blueprint, url_prefix="/auth")
|
app.register_blueprint(auth_blueprint, url_prefix="/auth")
|
||||||
|
|||||||
@@ -7,16 +7,17 @@ from application.dashboard.forms import npForm
|
|||||||
dash_blueprint = Blueprint("dash", __name__, template_folder="templates")
|
dash_blueprint = Blueprint("dash", __name__, template_folder="templates")
|
||||||
|
|
||||||
|
|
||||||
|
@dash_blueprint.route("/dashboard")
|
||||||
@dash_blueprint.route('/dashboard')
|
|
||||||
# @login_required
|
# @login_required
|
||||||
def dashboard():
|
def dashboard():
|
||||||
Plates = AllowedPlate.query.all()
|
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)
|
return render_template("dashboard.html", plates=Plates, logs=logs)
|
||||||
|
|
||||||
|
|
||||||
@dash_blueprint.route('/add', methods=['GET', 'POST'])
|
@dash_blueprint.route("/add", methods=["GET", "POST"])
|
||||||
# @login_required
|
# @login_required
|
||||||
def add():
|
def add():
|
||||||
Plates = AllowedPlate.query.all()
|
Plates = AllowedPlate.query.all()
|
||||||
@@ -28,13 +29,15 @@ def add():
|
|||||||
db.session.add(ap)
|
db.session.add(ap)
|
||||||
db.session.commit()
|
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()
|
plates = AllowedPlate.query.order_by(AllowedPlate.id).all()
|
||||||
return jsonify({
|
return jsonify(
|
||||||
'plates': [{'id': p.id, 'plate': p.plate} for p in plates]
|
{
|
||||||
})
|
"plates": [
|
||||||
|
{"id": p.id, "plate": p.plate} for p in plates
|
||||||
|
]
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
Plates = AllowedPlate.query.order_by(AllowedPlate.id).all()
|
Plates = AllowedPlate.query.order_by(AllowedPlate.id).all()
|
||||||
return render_template("add.html", form=form, plates=Plates)
|
return render_template("add.html", form=form, plates=Plates)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user