mirror of
https://codeberg.org/Mo8it/AdvLabDB.git
synced 2024-11-08 21:21:06 +00:00
24 lines
588 B
Python
24 lines
588 B
Python
from flask_admin import AdminIndexView
|
|
from flask_security import current_user
|
|
from flask_admin.contrib.sqla import ModelView
|
|
|
|
|
|
def adminViewIsAccessible():
|
|
return current_user.has_role("admin")
|
|
|
|
|
|
class SecureAdminIndexView(AdminIndexView):
|
|
def is_accessible(self):
|
|
return adminViewIsAccessible()
|
|
|
|
|
|
class SecureModelView(ModelView):
|
|
can_export = True
|
|
can_set_page_size = True
|
|
|
|
list_template = "admin_list.html"
|
|
create_template = "admin_create.html"
|
|
edit_template = "admin_edit.html"
|
|
|
|
def is_accessible(self):
|
|
return adminViewIsAccessible()
|