mirror of
https://github.com/StefBuwalda/WebTech.git
synced 2025-10-30 11:19:58 +00:00
added registerform
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
from flask_wtf import FlaskForm # type: ignore
|
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
|
from wtforms.validators import DataRequired
|
||||||
|
|
||||||
|
|
||||||
@@ -7,3 +7,9 @@ class ServiceForm(FlaskForm):
|
|||||||
name = StringField("Service name:", validators=[DataRequired()])
|
name = StringField("Service name:", validators=[DataRequired()])
|
||||||
url = URLField("Service URL:", validators=[DataRequired()])
|
url = URLField("Service URL:", validators=[DataRequired()])
|
||||||
submit = SubmitField("Add")
|
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>
|
<div>
|
||||||
{{ form.password.label }} <br> {{ form.password() }}
|
{{ form.password.label }} <br> {{ form.password() }}
|
||||||
</div>
|
</div>
|
||||||
|
<div>
|
||||||
|
Confirm {{ form.password.label }} <br> {{ form.password() }}
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
{{ form.admin }} {{ form.admin.label }}
|
||||||
|
</div>
|
||||||
<div class="submit">
|
<div class="submit">
|
||||||
{{ form.submit() }}
|
{{ form.submit() }}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from flask import Blueprint, render_template
|
from flask import Blueprint, render_template
|
||||||
|
from application.dash.forms import RegisterForm
|
||||||
from flask_login import login_required # type: ignore
|
from flask_login import login_required # type: ignore
|
||||||
from application.dash.models import Service
|
from application.dash.models import Service
|
||||||
from application.decorators import admin_required
|
from application.decorators import admin_required
|
||||||
@@ -16,6 +17,14 @@ def index():
|
|||||||
|
|
||||||
|
|
||||||
@dash_blueprint.route("/admin", methods=["GET", "POST"])
|
@dash_blueprint.route("/admin", methods=["GET", "POST"])
|
||||||
@admin_required
|
# @admin_required
|
||||||
def admin():
|
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")
|
return render_template("admin.html")
|
||||||
|
|||||||
Reference in New Issue
Block a user