def create_app(settings_override=None): app = factory.create_app(__name__, __path__, settings_override) admin = Admin(app, auth) register_admin(admin) admin.setup() return app
def setup_admin(): auth = Auth(app, db, user_model=User) admin = Admin(app, auth) admin.register(User, UserAdmin) admin.register(Photo, PhotoAdmin) auth.register_admin(admin) admin.setup() return auth, admin
def setup_admin(): auth = Auth(app, db) admin = Admin(app, auth) admin.register(Note, NoteAdmin) admin.register(Author, AuthorAdmin) auth.register_admin(admin) admin.setup() return auth, admin
class InitAdminDashboard(InitBaseExtension): name = 'admin' def init_app(self, app): # Инициируем Админку self.extension = Admin(app.web_app, app.auth) def configurate_extension(self): from ui.admin import get_admin_models for m in get_admin_models(): orm_m, adm_m = m if len(m) == 2 else [m[0], ModelAdmin] self.extension.register(orm_m, adm_m) self.extension.setup()
import psyc.models.execution as execution from gevent.wsgi import WSGIServer from flask_peewee.admin import Admin port = 9080 auth.User.create_table(fail_silently=True) url.Url.create_table(fail_silently=True) resource.Resource.create_table(fail_silently=True) catalog.Catalog.create_table(fail_silently=True) processor.Processor.create_table(fail_silently=True) execution.Execution.create_table(fail_silently=True) admin = Admin(app,auth) auth.register_admin(admin) admin.register(url.Url, url.UrlAdmin) admin.register(resource.Resource, resource.ResourceAdmin) admin.register(catalog.Catalog, catalog.CatalogAdmin) admin.register(processor.Processor, processor.ProcessorAdmin) admin.register(execution.Execution, execution.ExecutionAdmin) admin.setup() import psyc.rest import psyc.views catalog.register() #app.run(host='0.0.0.0', port=port, debug=True) http_server = WSGIServer(('', port), app) http_server.serve_forever()
def init_admin(app, auth, models): admin = Admin(app, auth) for model in models: admin.register(model) admin.setup()