coleifer / flask-peewee

flask integration for peewee, including admin, authentication, rest api and more
http://flask-peewee.readthedocs.org/
MIT License
777 stars 179 forks source link

Multiple Admin sites with different registered models #148

Open narzeja opened 10 years ago

narzeja commented 10 years ago

I wish to built a site that enables two or more Admin sites, such that one contains one set of models and the other contains a different (or overlapping) set of models. However, the navigation menu and links on the sites are screwed up, and doesn't behave as I would expect: when navigating the models on adminsite1, I get shown the navigation menu from adminsite2, and the title of both sites is the branding of adminsite2.

I wish to do something like this (models omitted):

from app import app, db
from models import SomeModel1, SomeModel2, Users
from flask_peewee.auth import Auth
from flask_peewee.admin import Admin
auth = Auth(app, db, user_model=Users)

adminsite1 = Admin(app, auth, prefix='/admin1', name='admin1', branding='Admin1')
adminsite2 = Admin(app, auth, prefix='/admin2', name='admin2', branding='Admin2')

auth.register_admin(adminsite1)
auth.register_admin(adminsite2)
adminsite1.register(SomeModel1)
adminsite2.register(SomeModel2)

auth.setup()
adminsite1.setup()
adminsite2.setup()

What am I missing, or is this possible at all out-of-the-box?

Alternatively, I am looking for a way to control that only some users get access to all tables/models, while other users do not.