mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-11-15 01:05:42 +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 = jsonify({'error': 'forbidden'})
|
||||||
response.status_code = 403
|
response.status_code = 403
|
||||||
return response
|
return response
|
||||||
return render_template('403.html.j2'), 403
|
return render_template('403.html.j2', title='Forbidden'), 403
|
||||||
|
|
||||||
|
|
||||||
@main.app_errorhandler(404)
|
@main.app_errorhandler(404)
|
||||||
@ -19,7 +19,7 @@ def page_not_found(e):
|
|||||||
response = jsonify({'error': 'not found'})
|
response = jsonify({'error': 'not found'})
|
||||||
response.status_code = 404
|
response.status_code = 404
|
||||||
return response
|
return response
|
||||||
return render_template('404.html.j2'), 404
|
return render_template('404.html.j2', title='Not Found'), 404
|
||||||
|
|
||||||
|
|
||||||
@main.app_errorhandler(500)
|
@main.app_errorhandler(500)
|
||||||
@ -29,4 +29,4 @@ def internal_server_error(e):
|
|||||||
response = jsonify({'error': 'internal server error'})
|
response = jsonify({'error': 'internal server error'})
|
||||||
response.status_code = 500
|
response.status_code = 500
|
||||||
return response
|
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 flask import render_template
|
||||||
|
from ..models import User
|
||||||
|
from ..tables import AdminUserTable, AdminUserItem
|
||||||
from . import main
|
from . import main
|
||||||
from ..decorators import admin_required
|
from ..decorators import admin_required
|
||||||
from flask_login import login_required
|
from flask_login import login_required
|
||||||
@ -13,4 +15,8 @@ def index():
|
|||||||
@login_required
|
@login_required
|
||||||
@admin_required
|
@admin_required
|
||||||
def for_admins_only():
|
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" %}
|
{% extends "base.html.j2" %}
|
||||||
|
|
||||||
{% block title %}Opaque - Forbidden{% endblock %}
|
|
||||||
|
|
||||||
{% block page_content %}
|
{% block page_content %}
|
||||||
<div class="page-header">
|
<div class="page-header">
|
||||||
<h1>Forbidden</h1>
|
<p>This site is forbidden for you.</p>
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
{% extends "base.html.j2" %}
|
{% extends "base.html.j2" %}
|
||||||
|
|
||||||
{% block title %}Opaque - Page Not Found{% endblock %}
|
|
||||||
|
|
||||||
{% block page_content %}
|
{% block page_content %}
|
||||||
<div class="page-header">
|
<div class="page-header">
|
||||||
<h1>Not Found</h1>
|
<p>Site has not been found.</p>
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
{% extends "base.html.j2" %}
|
{% extends "base.html.j2" %}
|
||||||
|
|
||||||
{% block title %}Opaque - Internal Server Error{% endblock %}
|
|
||||||
|
|
||||||
{% block page_content %}
|
{% block page_content %}
|
||||||
<div class="page-header">
|
<div class="page-header">
|
||||||
<h1>Internal Server Error</h1>
|
<p>Internal Server Error. We are Sorry!</p>
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@ -60,6 +60,9 @@
|
|||||||
</li>
|
</li>
|
||||||
<li><a href="{{ url_for('main.index') }}"><i class="material-icons">opacity</i>Opaque</a></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>
|
<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>
|
</ul>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
{% extends "base.html.j2" %}
|
{% extends "base.html.j2" %}
|
||||||
|
|
||||||
{% block page_content %}
|
{% block page_content %}
|
||||||
<h1>Administration tools</h1>
|
|
||||||
<div class="col s12">
|
<div class="col s12">
|
||||||
<div class="card large">
|
<div class="card large">
|
||||||
<div class="card-content">
|
<div class="card-content">
|
||||||
<span class="card-title">User list</span>
|
<span class="card-title">User list</span>
|
||||||
|
{{ table }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -6,3 +6,4 @@ Flask-Migrate==2.5.2
|
|||||||
Flask-SQLAlchemy==2.4.0
|
Flask-SQLAlchemy==2.4.0
|
||||||
Flask-WTF==0.14.2
|
Flask-WTF==0.14.2
|
||||||
python-dotenv==0.10.3
|
python-dotenv==0.10.3
|
||||||
|
Flask-Table==0.5.0
|
||||||
|
Loading…
Reference in New Issue
Block a user