~homeworkprod/byceps

8707e7c503eec7665771a59ee6d7d6e87daf4641 — Jochen Kupperschmidt 9 months ago 6197890
Hard-code redirect from admin app root URL path to global dashboard

The redirect for site apps can still be configured.
2 files changed, 9 insertions(+), 4 deletions(-)

M byceps/application.py
M config/admin_dev.py
M byceps/application.py => byceps/application.py +9 -2
@@ 24,6 24,7 @@ from .redis import redis
from .util.l10n import set_locale
from .util import templatefilters
from .util.templating import SiteTemplateOverridesLoader
from .util.views import redirect_to


def create_app(


@@ 86,8 87,6 @@ def _add_static_file_url_rules(app: Flask) -> None:
def init_app(app: Flask) -> None:
    """Initialize application."""
    with app.app_context():
        _set_url_root_path(app)

        app_mode = config.get_app_mode()
        if app_mode.is_admin():
            _init_admin_app(app)


@@ 99,6 98,12 @@ def init_app(app: Flask) -> None:

def _init_admin_app(app: Flask) -> None:
    """Initialize admin application."""
    app.add_url_rule(
        '/',
        endpoint='root',
        view_func=lambda: redirect_to('admin_dashboard.view_global'),
    )

    if app.config['RQ_DASHBOARD_ENABLED']:
        import rq_dashboard



@@ 107,6 112,8 @@ def _init_admin_app(app: Flask) -> None:

def _init_site_app(app: Flask) -> None:
    """Initialize site application."""
    _set_url_root_path(app)

    # Incorporate site-specific template overrides.
    app.jinja_loader = SiteTemplateOverridesLoader()


M config/admin_dev.py => config/admin_dev.py +0 -2
@@ 12,5 12,3 @@ APP_MODE = 'admin'
MAIL_DEBUG = True
MAIL_DEFAULT_SENDER = 'BYCEPS <noreply@admin.example>'
MAIL_SUPPRESS_SEND = True

ROOT_REDIRECT_TARGET = 'admin/dashboard'