blob: 14b9c6338b3e814642872cf8c60c69182e8012bd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
from app import app, login_manager, db
from flask import render_template, flash, url_for, redirect
import flask_login
from app.models import User
from flask_admin import Admin
from flask_admin.contrib.sqla import ModelView
admin = Admin(app, name="Admin", template_mode="bootstrap4")
class ModelView(ModelView): # skipcq: PYL-E0102
def is_accessible(self):
try:
if flask_login.current_user.get_role() == "SUPERUSER":
return True
return False
except AttributeError:
return False
admin.add_view(ModelView(User, db.session))
|