open-law/app/controllers/admin/custom_admin_index_view.py
2023-06-08 14:35:40 +03:00

17 lines
494 B
Python

from flask_admin import AdminIndexView
from flask_login import current_user
from flask import redirect, url_for
class CustomAdminIndexView(AdminIndexView):
def is_accessible(self):
return current_user.is_super_user
def is_visible(self):
# This view won't appear in the menu structure
return False
def inaccessible_callback(self, name, **kwargs):
# redirect to login page if user doesn't have access
return redirect(url_for("main.index"))