Example #1
0
    def _call_auth():
        with login.authenticate(request) as authenticated:
            if not authenticated:
                return _handle_not_authenticated()

            # When displaying the crash report message, the user authentication context
            # has already been left. We need to preserve this information to be able to
            # show the correct message for the current user.
            g.may_see_crash_reports = config.user.may(
                "general.see_crash_reports")

            # This may raise an exception with error messages, which will then be displayed to the user.
            _ensure_general_access()

            # Initialize the multisite cmk.gui.i18n. This will be replaced by
            # language settings stored in the user profile after the user
            # has been initialized
            _localize_request()

            # Update the UI theme with the attribute configured by the user.
            # Returns None on first load
            assert config.user.id is not None
            theme = cmk.gui.userdb.load_custom_attr(config.user.id, 'ui_theme',
                                                    lambda x: x)
            html.set_theme(theme)

            func()

            return html.response
Example #2
0
    def _call_auth():
        if not login.authenticate(request):
            _handle_not_authenticated()
            return

        # This may raise an exception with error messages, which will then be displayed to the user.
        _ensure_general_access()

        # Initialize the multisite cmk.gui.i18n. This will be replaced by
        # language settings stored in the user profile after the user
        # has been initialized
        _localize_request()

        # Update the UI theme with the attribute configured by the user
        html.set_theme(config.user.get_attribute("ui_theme"))

        func()
Example #3
0
    def _call_auth():
        if not login.authenticate(request):
            return _handle_not_authenticated()

        # This may raise an exception with error messages, which will then be displayed to the user.
        _ensure_general_access()

        # Initialize the multisite cmk.gui.i18n. This will be replaced by
        # language settings stored in the user profile after the user
        # has been initialized
        _localize_request()

        # Update the UI theme with the attribute configured by the user.
        # Returns None on first load
        assert config.user.id is not None
        theme = cmk.gui.userdb.load_custom_attr(config.user.id, 'ui_theme',
                                                lambda x: x)
        html.set_theme(theme)

        func()

        return html.response
Example #4
0
def test_html_set_theme(my_theme, register_builtin_html):
    html.set_theme(None)
    assert html.get_theme() == "facelift"

    html.set_theme("not_existing")
    assert html.get_theme() == "facelift"

    html.set_theme("my_theme")
    assert html.get_theme() == "my_theme"