From 79da565ea301155b4091e3bba975b09e796edf4f Mon Sep 17 00:00:00 2001 From: Stef Date: Sat, 12 Apr 2025 12:59:15 +0200 Subject: [PATCH] 123123123 --- app.py | 5 ++--- application/auth/views.py | 2 +- seed.py | 24 ++++++++++++++++++++++++ 3 files changed, 27 insertions(+), 4 deletions(-) create mode 100644 seed.py diff --git a/app.py b/app.py index 06cdc0e..85dcb01 100644 --- a/app.py +++ b/app.py @@ -5,12 +5,11 @@ from flask_login import current_user, login_required # home route @app.route("/") -@login_required def index(): if current_user.is_authenticated: - return redirect(url_for("application.dash")) + return redirect(url_for("dash.index")) else: - return redirect(url_for("application.auth")) + return redirect(url_for("auth.login")) # App deployment diff --git a/application/auth/views.py b/application/auth/views.py index 55b9b06..57a7068 100644 --- a/application/auth/views.py +++ b/application/auth/views.py @@ -25,7 +25,7 @@ def login(): user.password, password # type: ignore ): login_user(user) # type: ignore - return redirect(url_for("application.dash")) + return redirect("/") else: feedback = "Foutieve login." diff --git a/seed.py b/seed.py new file mode 100644 index 0000000..8ff1189 --- /dev/null +++ b/seed.py @@ -0,0 +1,24 @@ +from application import db, app +from application.dash.models import Service +from application.auth.models import User +from werkzeug.security import generate_password_hash + +""" +new_strikers = [ + se(name="Erik", strike="y", age=44), + Striker(name="Henk", strike="n", age=88), +] + +""" + +new_user = User(username="admin", password=generate_password_hash("admin")) + +with app.app_context(): + # Remove all existing + Service.query.delete() + User.query.delete() + db.session.commit() + # Then add new + # db.session.add_all(new_strikers) + db.session.add(new_user) + db.session.commit()