Exemplo n.º 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 = 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 user.id is not None
            theme.set(cmk.gui.userdb.load_custom_attr(user.id, "ui_theme", lambda x: x))

            func()

            return response
Exemplo n.º 2
0
def test_theme_request_context_integration(my_theme, request_context):
    theme.from_config("facelift")

    theme.set("")
    assert theme.get() == "facelift"

    theme.set("not_existing")
    assert theme.get() == "facelift"

    theme.set("my_theme")
    assert theme.get() == "my_theme"
Exemplo n.º 3
0
def test_theme_request_context_integration(my_theme, register_builtin_html):
    theme.from_config("facelift", config.theme_choices())

    theme.set("")
    assert theme.get() == "facelift"

    theme.set("not_existing")
    assert theme.get() == "facelift"

    theme.set("my_theme")
    assert theme.get() == "my_theme"