Exemple #1
0
    def configure_admin(self):
        """Configure admin ux.

        Register templates and views for admin interface.
        """

        from websauna.system.admin import views
        from websauna.system.admin import subscribers
        from websauna.system.admin.admin import Admin
        from websauna.system.admin.interfaces import IAdmin
        from websauna.system.admin.interfaces import IAdmin
        from websauna.system.admin.utils import get_admin

        # Register default Admin provider
        config = self.config
        config.registry.registerUtility(Admin, IAdmin)

        # Set up model lookup
        configure_model_admin(config)

        config.add_jinja2_search_path('websauna.system.admin:templates', name='.html')
        config.add_jinja2_search_path('websauna.system.admin:templates', name='.txt')

        config.add_route('admin_home', '/admin/', factory="websauna.system.admin.utils.get_admin")
        config.add_route('admin', "/admin/*traverse", factory="websauna.system.admin.utils.get_admin")

        config.add_panel('websauna.system.admin.views.default_model_admin_panel')
        config.scan(views)
        config.scan(subscribers)

        # Add request.admin variable
        self.config.add_request_method(get_admin, 'admin', reify=True)
    def configure_admin(self):
        """Configure admin ux.

        Register templates and views for admin interface.
        """

        from websauna.system.admin import views
        from websauna.system.admin import subscribers
        from websauna.system.admin.admin import Admin
        from websauna.system.admin.interfaces import IAdmin
        from websauna.system.admin.interfaces import IAdmin
        from websauna.system.admin.utils import get_admin
        from websauna.system.admin.modeladmin import configure_model_admin

        # Register default Admin provider
        config = self.config
        config.registry.registerUtility(Admin, IAdmin)

        # Set up model lookup
        configure_model_admin(config)

        config.add_jinja2_search_path('websauna.system.admin:templates', name='.html')
        config.add_jinja2_search_path('websauna.system.admin:templates', name='.txt')

        config.add_route('admin_home', '/admin/', factory="websauna.system.admin.utils.get_admin")
        config.add_route('admin', "/admin/*traverse", factory="websauna.system.admin.utils.get_admin")

        config.add_panel('websauna.system.admin.views.default_model_admin_panel')
        config.scan(views)
        config.scan(subscribers)

        # Add request.admin variable
        self.config.add_request_method(get_admin, 'admin', reify=True)