This commit is contained in:
2025-04-12 12:26:02 +02:00
parent 97e4b7fe0a
commit 1a59cc4153
12 changed files with 98 additions and 13 deletions

View File

@@ -17,8 +17,7 @@ migrate = Migrate(app, db)
# bp import
from application.auth.views import auth_blueprint
# from application.strike.views import strike_blueprint
from application.dash.views import dash_blueprint
# Login manager
from application.auth.models import User
@@ -35,5 +34,5 @@ def load_user(user_id): # type: ignore
# Blueprint magic
# app.register_blueprint(strike_blueprint, url_prefix="/staking")
app.register_blueprint(dash_blueprint, url_prefix="/dash")
app.register_blueprint(auth_blueprint, url_prefix="/auth")

View File

@@ -25,7 +25,7 @@ def login():
user.password, password # type: ignore
):
login_user(user) # type: ignore
return redirect(url_for("staking.strikers"))
return redirect(url_for("application.dash"))
else:
feedback = "Foutieve login."

View File

@@ -0,0 +1,9 @@
from flask_wtf import FlaskForm
from wtforms import StringField, SubmitField, URLField
from wtforms.validators import DataRequired
class ServiceForm(FlaskForm):
name = StringField("Service name:", validators=[DataRequired()])
url = URLField("Service URL:", validators=[DataRequired()])
submit = SubmitField("Add")

View File

@@ -0,0 +1,7 @@
from application import db
class Service(db.Model):
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String, nullable=False)
url = db.Column(db.String, nullable=False)

View File

61
application/dash/views.py Normal file
View File

@@ -0,0 +1,61 @@
from flask import (
Blueprint,
render_template,
redirect,
url_for,
request,
flash,
session,
get_flashed_messages,
)
from application import db
from application.dash.models import Service
from application.dash.forms import ServiceForm
from flask_login import login_required, current_user
dash_blueprint = Blueprint("dash", __name__, template_folder="templates")
# Routes
"""
@strike_blueprint.route("/bedankt", methods=["GET"])
def thanks():
return render_template("bedankt.html")
"""
@dash_blueprint.route("/", methods=["GET", "POST"])
@login_required
def index():
session["_flashes"] = []
my_form = ServiceForm()
if request.method == "POST":
if my_form.validate_on_submit():
flash("Het formulier is succesvol gePOST")
session["naam"] = my_form.name.data
session["url"] = my_form.url.data
flash("De gegevens zijn in de sessie opgeslagen")
new_service = Service(name=my_form.name.data, url=my_form.url.data)
db.session.add(new_service)
db.session.commit()
flash("De gegevens zijn in de database opgeslagen")
return redirect(url_for("application.dash"))
else:
flash("Het formulier is niet goed ingevuld")
return render_template("dash.html", form=my_form)
"""
@strike_blueprint.route("/stakers")
@login_required
def strikers():
rows = Striker.query.all()
return render_template(
"strikers.html", rows=rows, user=current_user.username
)
"""

View File

@@ -7,7 +7,6 @@
<title>{% block title %}{% endblock %}</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
<link rel="stylesheet" href="{{url_for('static', filename='my.css')}}">
</head>
<body>

View File

@@ -1,9 +1,9 @@
{% extends 'base.html' %}
{% block title %}
Staak-app
Idk applicatie
{% endblock %}
{% block content %}
<h1>Welkom bij de staak-app!</h1>
<h1>Dit is de home page, hopelijk redirect de pagina</h1>
{% endblock %}