mirror of
https://github.com/StefBuwalda/WebTech.git
synced 2025-10-30 03:10:00 +00:00
added registerform
This commit is contained in:
@@ -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")
|
||||
@@ -17,6 +17,12 @@ Register
|
||||
<div>
|
||||
{{ form.password.label }} <br> {{ form.password() }}
|
||||
</div>
|
||||
<div>
|
||||
Confirm {{ form.password.label }} <br> {{ form.password() }}
|
||||
</div>
|
||||
<div>
|
||||
{{ form.admin }} {{ form.admin.label }}
|
||||
</div>
|
||||
<div class="submit">
|
||||
{{ form.submit() }}
|
||||
</div>
|
||||
|
||||
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user