commit 700980dda1558520adb8b647ec377148d59e504d
parent 3e9c41becd80978b4c8bb38622097b55f81bf1d1
Author: Friedel Schön <[email protected]>
Date: Sat, 16 Apr 2022 04:35:28 +0200
permissions-page -> admin-page & time to go sleepin
Diffstat:
5 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/pgmles/forms.py b/pgmles/forms.py
@@ -67,6 +67,6 @@ class SearchForm(FlaskForm):
username = StringField('Naam', validators=[ DataRequired(), Length(min=2, max=20)])
submit = SubmitField('Zoeken')
-class PermissionForm(FlaskForm):
+class AdminForm(FlaskForm):
type = SelectField('Type', choices=[('client', 'Klant'), ('teacher', 'Docent'), ('admin', 'Administrator')])
submit = SubmitField('Bewerken')
diff --git a/pgmles/routes.py b/pgmles/routes.py
@@ -8,7 +8,7 @@ from calendar import Calendar as Month
from datetime import datetime
from .server import app, bcrypt, db
-from .forms import LoginForm, NewCourseForm, PermissionForm, RegistrationForm, SearchForm, SubscribeForm, UnsubscribeForm, UpdateAccountForm
+from .forms import LoginForm, NewCourseForm, AdminForm, RegistrationForm, SearchForm, SubscribeForm, UnsubscribeForm, UpdateAccountForm
from .models import Course, CourseMember, User
@@ -200,9 +200,9 @@ def delete_course(course_id):
db.session.commit()
return redirect(url_for('course_overview'))
[email protected]("/permissions", methods=['GET','POST'])
[email protected]("/admin", methods=['GET','POST'])
@login_required
-def permissions():
+def admin():
if current_user.type != "admin":
abort(403)
form = SearchForm()
@@ -212,22 +212,22 @@ def permissions():
flash(f'Geen gebruker gevonden: {form.username.data}', 'danger')
else:
flash(f'Gebruiker gevonden: {form.username.data}', 'success')
- return redirect(url_for('update_permissions', user_id= user.id))
- return render_template('permissions.html', calendar=make_calendar(), form=form)
+ return redirect(url_for('admin_user', user_id= user.id))
+ return render_template('admin.html', calendar=make_calendar(), form=form)
[email protected]("/permissions/update/<int:user_id>", methods=['GET','POST'])
[email protected]("/admin/<int:user_id>", methods=['GET','POST'])
@login_required
-def update_permissions(user_id):
+def admin_user(user_id):
if current_user.type != "admin":
abort(403)
- form = PermissionForm()
+ form = AdminForm()
user = User.query.filter_by(id=user_id).first()
image_file = url_for('static', filename='profile_pics/' + user.image_file)
if form.validate_on_submit():
user.type = form.type.data
db.session.commit()
flash(f'De gebruiker {user.username} is nu een {user.type}', 'success')
- return redirect(url_for('permissions'))
+ return redirect(url_for('admin'))
elif request.method == 'GET':
form.type.data = user.type
- return render_template('updatepermissions.html', calendar=make_calendar(), form=form, user=user, image_file=image_file)
+ return render_template('admin_user.html', calendar=make_calendar(), form=form, user=user, image_file=image_file)
diff --git a/pgmles/templates/permissions.html b/pgmles/templates/admin.html
diff --git a/pgmles/templates/updatepermissions.html b/pgmles/templates/admin_user.html
diff --git a/pgmles/templates/layout.html b/pgmles/templates/layout.html
@@ -61,7 +61,7 @@
<ul class="list-group">
<li class="list-group-item list-group-item-light"><a href="{{ url_for('course_overview') }}">Lesoverzicht</a></li>
{% if current_user.type == 'admin' %}
- <li class="list-group-item list-group-item-light"><a href="{{ url_for('permissions') }}">Rechten bewerken</a></li>
+ <li class="list-group-item list-group-item-light"><a href="{{ url_for('admin') }}">Rechten bewerken</a></li>
{% endif %}
</ul>
</p>