# Path: makesite/modules/flask/base/ext.py
# def config_extensions(app):
# def config_babel(app):
#     def get_locale():


from flask_admin import AdminIndexView, Admin
from flask_admin.contrib.sqlamodel import ModelView
from flask_login import current_user
from ..ext import db
        from ..loader import loader

class StaffAdminView(AdminIndexView):
    " Staff admin home page. "

    def is_accessible(self):
        return current_user.is_authenticated() and current_user.permission('staff')


class AuthModelView(ModelView):
    def __init__(self, *args, **kwargs):
        self.role = kwargs.pop('role', None) or 'admin'
        super(AuthModelView, self).__init__(*args, **kwargs)

    def is_accessible(self):
        return current_user.is_authenticated() and current_user.permission(self.role)


class FlaskAdmin(Admin):

    def __init__(self, **kwargs):
        super(FlaskAdmin, self).__init__(index_view=StaffAdminView(), **kwargs)

    def init_app(self, app):
        self.app = None
        super(FlaskAdmin, self).init_app(app)

        loader.load_submod('admin')

    def add_model(self, model, view=None, role='admin', **kwargs):
        view = view or AuthModelView

# Path: makesite/modules/flask/base/ext.py
# def config_extensions(app):
# def config_babel(app):
#     def get_locale():


# Path: makesite/modules/flask/base/core/ext.py
from flask_admin import AdminIndexView, Admin
from flask_admin.contrib.sqlamodel import ModelView
from flask_login import current_user
from ..ext import db
        from ..loader import loader


class StaffAdminView(AdminIndexView):
    " Staff admin home page. "

    def is_accessible(self):
        return current_user.is_authenticated() and current_user.permission('staff')


class AuthModelView(ModelView):
    def __init__(self, *args, **kwargs):
        self.role = kwargs.pop('role', None) or 'admin'
        super(AuthModelView, self).__init__(*args, **kwargs)

    def is_accessible(self):
        return current_user.is_authenticated() and current_user.permission(self.role)


class FlaskAdmin(Admin):

    def __init__(self, **kwargs):
        super(FlaskAdmin, self).__init__(index_view=StaffAdminView(), **kwargs)

    def init_app(self, app):
        self.app = None
        super(FlaskAdmin, self).init_app(app)

        loader.load_submod('admin')

    def add_model(self, model, view=None, role='admin', **kwargs):
        view = view or AuthModelView

        self.add_view(view(model, db.session))