2019-07-19 11:28:17 +00:00
|
|
|
from flask import render_template
|
2019-07-10 12:36:31 +00:00
|
|
|
from ..models import User
|
|
|
|
from ..tables import AdminUserTable, AdminUserItem
|
2019-07-05 12:47:35 +00:00
|
|
|
from . import main
|
2019-07-09 13:41:16 +00:00
|
|
|
from ..decorators import admin_required
|
2019-07-19 11:28:17 +00:00
|
|
|
from flask_login import login_required
|
2019-07-05 12:47:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
@main.route('/')
|
|
|
|
def index():
|
2019-07-09 14:59:04 +00:00
|
|
|
return render_template('main/index.html.j2', title='Portal')
|
2019-07-09 13:41:16 +00:00
|
|
|
|
|
|
|
|
2019-07-12 15:23:11 +00:00
|
|
|
@main.route('/about')
|
|
|
|
def about():
|
|
|
|
return render_template('main/about.html.j2', title='About')
|
|
|
|
|
|
|
|
|
2019-07-17 11:34:20 +00:00
|
|
|
@main.route('/admin', methods=['GET', 'POST'])
|
2019-07-09 13:41:16 +00:00
|
|
|
@login_required
|
|
|
|
@admin_required
|
|
|
|
def for_admins_only():
|
2019-07-11 13:43:48 +00:00
|
|
|
"""
|
|
|
|
View for admin page only accesible by admins.
|
|
|
|
"""
|
2019-07-10 12:36:31 +00:00
|
|
|
users = User.query.order_by(User.username).all()
|
|
|
|
items = [AdminUserItem(u.username, u.email, u.role_id, u.confirmed) for u in users]
|
|
|
|
table = AdminUserTable(items)
|
2019-07-12 15:23:11 +00:00
|
|
|
return render_template('main/admin.html.j2', title='Administration tools',
|
2019-07-19 11:28:17 +00:00
|
|
|
table=table.__html__())
|