From ef8aef43b7dd18cfaecd9ff05318247b70a44e2d Mon Sep 17 00:00:00 2001 From: DaanoGames Date: Tue, 15 Apr 2025 11:35:01 +0200 Subject: [PATCH] added registerform --- application/dash/forms.py | 8 +++++++- application/dash/templates/admin.html | 6 ++++++ application/dash/views.py | 11 ++++++++++- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/application/dash/forms.py b/application/dash/forms.py index ffe3465..958fdac 100644 --- a/application/dash/forms.py +++ b/application/dash/forms.py @@ -1,5 +1,5 @@ from flask_wtf import FlaskForm # type: ignore -from wtforms import StringField, SubmitField, URLField +from wtforms import StringField, PasswordField, SubmitField, URLField, BooleanField from wtforms.validators import DataRequired @@ -7,3 +7,9 @@ class ServiceForm(FlaskForm): name = StringField("Service name:", validators=[DataRequired()]) url = URLField("Service URL:", validators=[DataRequired()]) submit = SubmitField("Add") + +class RegisterForm(FlaskForm): + username = StringField("Username", validators=[DataRequired()]) + password = PasswordField("Password", validators=[DataRequired()]) + admin = BooleanField("Admin") + submit = SubmitField("Add") \ No newline at end of file diff --git a/application/dash/templates/admin.html b/application/dash/templates/admin.html index dca647b..ab7bece 100644 --- a/application/dash/templates/admin.html +++ b/application/dash/templates/admin.html @@ -17,6 +17,12 @@ Register
{{ form.password.label }}
{{ form.password() }}
+
+ Confirm {{ form.password.label }}
{{ form.password() }} +
+
+ {{ form.admin }} {{ form.admin.label }} +
{{ form.submit() }}
diff --git a/application/dash/views.py b/application/dash/views.py index 7c5cebf..5f0fa1f 100644 --- a/application/dash/views.py +++ b/application/dash/views.py @@ -1,4 +1,5 @@ from flask import Blueprint, render_template +from application.dash.forms import RegisterForm from flask_login import login_required # type: ignore from application.dash.models import Service from application.decorators import admin_required @@ -16,6 +17,14 @@ def index(): @dash_blueprint.route("/admin", methods=["GET", "POST"]) -@admin_required +# @admin_required def admin(): + register_form = RegisterForm() + + if register_form.validate_on_submit: + username = register_form.username.data + password = register_form.password.data + check_admin = register_form.admin.data + + return render_template("admin.html")