mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-12-24 02:24:20 +00:00
Merge branch 'development' of gitlab.ub.uni-bielefeld.de:sfb1288inf/opaque into development
This commit is contained in:
commit
c2139500e2
@ -9,7 +9,7 @@ def forbidden(e):
|
||||
response = jsonify({'error': 'forbidden'})
|
||||
response.status_code = 403
|
||||
return response
|
||||
return render_template('403.html.j2'), 403
|
||||
return render_template('403.html.j2', title='Forbidden'), 403
|
||||
|
||||
|
||||
@main.app_errorhandler(404)
|
||||
@ -19,7 +19,7 @@ def page_not_found(e):
|
||||
response = jsonify({'error': 'not found'})
|
||||
response.status_code = 404
|
||||
return response
|
||||
return render_template('404.html.j2'), 404
|
||||
return render_template('404.html.j2', title='Not Found'), 404
|
||||
|
||||
|
||||
@main.app_errorhandler(500)
|
||||
@ -29,4 +29,4 @@ def internal_server_error(e):
|
||||
response = jsonify({'error': 'internal server error'})
|
||||
response.status_code = 500
|
||||
return response
|
||||
return render_template('500.html.j2'), 500
|
||||
return render_template('500.html.j2', title='Internal Server Error'), 500
|
||||
|
@ -1,4 +1,6 @@
|
||||
from flask import render_template
|
||||
from ..models import User
|
||||
from ..tables import AdminUserTable, AdminUserItem
|
||||
from . import main
|
||||
from ..decorators import admin_required
|
||||
from flask_login import login_required
|
||||
@ -13,4 +15,8 @@ def index():
|
||||
@login_required
|
||||
@admin_required
|
||||
def for_admins_only():
|
||||
return "For administrators!"
|
||||
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)
|
||||
return render_template('main/admin.html.j2', title='Administration Tools',
|
||||
table=table.__html__())
|
||||
|
29
app/tables.py
Normal file
29
app/tables.py
Normal file
@ -0,0 +1,29 @@
|
||||
from flask_table import Table, Col
|
||||
|
||||
|
||||
class AdminUserTable(Table):
|
||||
"""
|
||||
Declares the table describing colum by column.
|
||||
"""
|
||||
classes = ['highlight', 'responsive-table']
|
||||
username = Col('Username')
|
||||
email = Col('Email')
|
||||
role_id = Col('Role')
|
||||
confirmed = Col('Confrimed Status')
|
||||
|
||||
|
||||
class AdminUserItem(object):
|
||||
"""
|
||||
Describes one item like one row per table.
|
||||
"""
|
||||
|
||||
def __init__(self, username, email, role_id, confirmed):
|
||||
self.username = username
|
||||
self.email = email
|
||||
self.role_id = role_id
|
||||
self.confirmed = confirmed
|
||||
|
||||
if self.role_id == 1:
|
||||
self.role_id = 'User'
|
||||
elif self.role_id == 2:
|
||||
self.role_id = 'Admin'
|
@ -1,9 +1,7 @@
|
||||
{% extends "base.html.j2" %}
|
||||
|
||||
{% block title %}Opaque - Forbidden{% endblock %}
|
||||
|
||||
{% block page_content %}
|
||||
<div class="page-header">
|
||||
<h1>Forbidden</h1>
|
||||
<p>This site is forbidden for you.</p>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
@ -1,9 +1,7 @@
|
||||
{% extends "base.html.j2" %}
|
||||
|
||||
{% block title %}Opaque - Page Not Found{% endblock %}
|
||||
|
||||
{% block page_content %}
|
||||
<div class="page-header">
|
||||
<h1>Not Found</h1>
|
||||
<p>Site has not been found.</p>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
@ -1,9 +1,7 @@
|
||||
{% extends "base.html.j2" %}
|
||||
|
||||
{% block title %}Opaque - Internal Server Error{% endblock %}
|
||||
|
||||
{% block page_content %}
|
||||
<div class="page-header">
|
||||
<h1>Internal Server Error</h1>
|
||||
<p>Internal Server Error. We are Sorry!</p>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
@ -60,6 +60,9 @@
|
||||
</li>
|
||||
<li><a href="{{ url_for('main.index') }}"><i class="material-icons">opacity</i>Opaque</a></li>
|
||||
<li><a href="{{ url_for('auth.settings') }}"><i class="material-icons">settings</i>Settings</a></li>
|
||||
{% if current_user.is_administrator() %} <!-- Shows only for admins -->
|
||||
<li><a href="{{ url_for('main.for_admins_only') }}"><i class="material-icons">build</i>Administration</a></li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
</header>
|
||||
|
||||
|
@ -1,11 +1,11 @@
|
||||
{% extends "base.html.j2" %}
|
||||
|
||||
{% block page_content %}
|
||||
<h1>Administration tools</h1>
|
||||
<div class="col s12">
|
||||
<div class="card large">
|
||||
<div class="card-content">
|
||||
<span class="card-title">User list</span>
|
||||
{{ table }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -6,3 +6,4 @@ Flask-Migrate==2.5.2
|
||||
Flask-SQLAlchemy==2.4.0
|
||||
Flask-WTF==0.14.2
|
||||
python-dotenv==0.10.3
|
||||
Flask-Table==0.5.0
|
||||
|
Loading…
Reference in New Issue
Block a user