Beispiel #1
0

# The current service attached to the request stack.
def _get_current_service():
    return _lookup_req_object('service')


current_service = LocalProxy(_get_current_service)

# The current organisation attached to the request stack.
current_organisation = LocalProxy(partial(_lookup_req_object, 'organisation'))

navigation = {
    'casework_navigation': CaseworkNavigation(),
    'main_navigation': MainNavigation(),
    'header_navigation': HeaderNavigation(),
    'org_navigation': OrgNavigation(),
}


def get_current_locale(application):
    requestLang = request.accept_languages.best_match(application.config['LANGUAGES'])
    if requestLang is None:
        requestLang = "en"

    if request.args.get('lang') and request.args.get('lang') in ["en", "fr"]:
        lang = request.args.get('lang')
    else:
        lang = session.get("userlang", requestLang)

    session["userlang"] = lang
Beispiel #2
0
)
from tests.conftest import (
    ORGANISATION_ID,
    SERVICE_ONE_ID,
    active_caseworking_user,
    app_,
    normalize_spaces,
)

all_endpoints = [
    rule.endpoint for rule in next(app_(None)).url_map.iter_rules()
]

navigation_instances = (
    MainNavigation(),
    HeaderNavigation(),
    OrgNavigation(),
    CaseworkNavigation(),
)


@pytest.mark.parametrize('navigation_instance', navigation_instances)
def test_navigation_items_are_properly_defined(navigation_instance):
    for endpoint in navigation_instance.endpoints_with_navigation:
        assert (endpoint in all_endpoints
                ), '{} is not a real endpoint (in {}.mapping)'.format(
                    endpoint,
                    type(navigation_instance).__name__)
        assert (endpoint
                not in navigation_instance.endpoints_without_navigation
                ), '{} is listed in {}.mapping and {}.exclude'.format(
Beispiel #3
0
login_manager = LoginManager()
csrf = CSRFProtect()


# The current service attached to the request stack.
def _get_current_service():
    return _lookup_req_object("service")


current_service = LocalProxy(_get_current_service)

# The current organisation attached to the request stack.
current_organisation = LocalProxy(partial(_lookup_req_object, "organisation"))

navigation = {
    "header_navigation": HeaderNavigation(),
    "admin_navigation": AdminNavigation(),
    "org_navigation": OrgNavigation(),
    "main_navigation": MainNavigation(),
}


def get_current_locale(application):
    requestLang = request.accept_languages.best_match(
        application.config["LANGUAGES"])
    if requestLang is None:
        requestLang = "en"

    if request.args.get("lang") and request.args.get("lang") in ["en", "fr"]:
        lang = request.args.get("lang")
    else: