diff --git a/advlabdb/forms.py b/advlabdb/forms.py index bc47534..1f2d09d 100644 --- a/advlabdb/forms.py +++ b/advlabdb/forms.py @@ -7,7 +7,7 @@ from advlabdb.models import User class RegistrationForm(FlaskForm): email = StringField("Email", validators=[DataRequired(), Email()]) - admin = BooleanField("Admin") + admin = BooleanField("Admin", default=False) submit = SubmitField("Register") def validate_email(self, email): diff --git a/advlabdb/routes.py b/advlabdb/routes.py index 36b4330..8efddfa 100644 --- a/advlabdb/routes.py +++ b/advlabdb/routes.py @@ -93,9 +93,7 @@ def students(): tablesLabels.append("Part " + part.label + ":") tables.append(makeTable(headerAndDataList=headerAndDataList, rows=part.part_students)) - title = "Students" - return render_template(titleToTemplate(title) + ".html", - title=title, + return render_template("students.html", tables=tables, tablesLabels=tablesLabels, ) @@ -118,9 +116,7 @@ def assistants(): table = makeTable(headerAndDataList=headerAndDataList, rows=Assistant.query.filter(Assistant.user_id != None).all()) - title = "Assistants" - return render_template(titleToTemplate(title) + ".html", - title=title, + return render_template("assistants.html", table=table, ) @@ -143,9 +139,7 @@ def experiments(): tables.append(makeTable(headerAndDataList=headerAndDataList, rows=part.part_experiments)) - title = "Experiments" - return render_template(titleToTemplate(title) + ".html", - title=title, + return render_template("experiments.html", tables=tables, tablesLabels=tablesLabels, ) @@ -154,9 +148,7 @@ def experiments(): @app.route("/appointments") @roles_required("admin") def appointments(): - title = "Appointments" - return render_template(titleToTemplate(title) + ".html", - title=title, + return render_template("appointments.html", ) @@ -179,9 +171,7 @@ def groups(): tables.append(makeTable(headerAndDataList=headerAndDataList, rows=part.groups)) - title = "Groups" - return render_template(titleToTemplate(title) + ".html", - title=title, + return render_template("groups.html", tables=tables, tablesLabels=tablesLabels, ) @@ -202,9 +192,7 @@ def users(): rows=User.query.filter(User.active == True).all(), tableId="usersTab") - title = "Users" - return render_template(titleToTemplate(title) + ".html", - title=title, + return render_template("users.html", table=table, ) @@ -239,9 +227,7 @@ def semesters(): table = makeTable(headerAndDataList=headerAndDataList, rows=Semester.query.all()) - title = "Semesters" - return render_template(titleToTemplate(title) + ".html", - title=title, + return render_template("semesters.html", table=table, ) @@ -254,6 +240,7 @@ def set_semester(): @app.route("/register", methods=["GET", "POST"]) +@roles_required("admin") def register(): form = RegistrationForm() if form.validate_on_submit(): @@ -272,12 +259,10 @@ def register(): user_datastore.create_user(email=email, password=passwordHash, roles=roles) db.session.commit() return render_template("registered.html", - title="Registered", email=email, password=password, admin=admin, ) return render_template("register.html", - title="Register", form=form, ) diff --git a/advlabdb/templates/appointments.html b/advlabdb/templates/appointments.html index 39e893d..c0ecb70 100644 --- a/advlabdb/templates/appointments.html +++ b/advlabdb/templates/appointments.html @@ -1,3 +1,4 @@ +{% set title = "Appointments" %} {% extends "layout.html" %} {% block content %} {% endblock content %} diff --git a/advlabdb/templates/assistants.html b/advlabdb/templates/assistants.html index 31810f8..3768ea1 100644 --- a/advlabdb/templates/assistants.html +++ b/advlabdb/templates/assistants.html @@ -1,3 +1,4 @@ +{% set title = "Assistants" %} {% extends "layout.html" %} {% block content %} diff --git a/advlabdb/templates/experiments.html b/advlabdb/templates/experiments.html index f87c4aa..cc5acc6 100644 --- a/advlabdb/templates/experiments.html +++ b/advlabdb/templates/experiments.html @@ -1,3 +1,4 @@ +{% set title = "Experiments" %} {% extends "layout.html" %} {% block content %} diff --git a/advlabdb/templates/groups.html b/advlabdb/templates/groups.html index f87c4aa..e03ca1d 100644 --- a/advlabdb/templates/groups.html +++ b/advlabdb/templates/groups.html @@ -1,3 +1,4 @@ +{% set title = "Groups" %} {% extends "layout.html" %} {% block content %} diff --git a/advlabdb/templates/index.html b/advlabdb/templates/index.html index d2f6365..981c57d 100644 --- a/advlabdb/templates/index.html +++ b/advlabdb/templates/index.html @@ -1,3 +1,4 @@ +{% set title = "Home" %} {% extends "layout.html" %} {% block content %} Welcome on AdvLabDB! diff --git a/advlabdb/templates/register.html b/advlabdb/templates/register.html index 59c28f9..5a1549d 100644 --- a/advlabdb/templates/register.html +++ b/advlabdb/templates/register.html @@ -1,8 +1,8 @@ +{% set title = "Register" %} {% extends "layout.html" %} {% block content %}