blob: 7891e50fdaa553d50ba64258e30d18bd8706442f (
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):
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))
|