mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2025-06-21 13:30:35 +00:00
Implement /admin using flask-admin. Overall cleanup
This commit is contained in:
20
app/extensions/nopaque_flask_admin_views.py
Normal file
20
app/extensions/nopaque_flask_admin_views.py
Normal file
@ -0,0 +1,20 @@
|
||||
from flask import abort
|
||||
from flask_admin import (
|
||||
AdminIndexView as _AdminIndexView,
|
||||
expose
|
||||
)
|
||||
from flask_admin.contrib.sqla import ModelView as _ModelView
|
||||
from flask_login import current_user
|
||||
|
||||
|
||||
class AdminIndexView(_AdminIndexView):
|
||||
@expose('/')
|
||||
def index(self):
|
||||
if not current_user.is_administrator:
|
||||
abort(403)
|
||||
return super().index()
|
||||
|
||||
|
||||
class ModelView(_ModelView):
|
||||
def is_accessible(self):
|
||||
return current_user.is_administrator
|
@ -1,2 +0,0 @@
|
||||
from .types import ContainerColumn
|
||||
from .types import IntEnumColumn
|
Reference in New Issue
Block a user