Changeset View
Changeset View
Standalone View
Standalone View
swh/web/common/utils.py
Show First 20 Lines • Show All 241 Lines • ▼ Show 20 Lines | |||||
def context_processor(request): | def context_processor(request): | ||||
""" | """ | ||||
Django context processor used to inject variables | Django context processor used to inject variables | ||||
in all swh-web templates. | in all swh-web templates. | ||||
""" | """ | ||||
config = get_config() | config = get_config() | ||||
if request.user.is_authenticated and not hasattr(request.user, "backend"): | if ( | ||||
hasattr(request, "user") | |||||
and request.user.is_authenticated | |||||
and not hasattr(request.user, "backend") | |||||
): | |||||
# To avoid django.template.base.VariableDoesNotExist errors | # To avoid django.template.base.VariableDoesNotExist errors | ||||
# when rendering templates when standard Django user is logged in. | # when rendering templates when standard Django user is logged in. | ||||
request.user.backend = "django.contrib.auth.backends.ModelBackend" | request.user.backend = "django.contrib.auth.backends.ModelBackend" | ||||
return { | return { | ||||
"swh_object_icons": swh_object_icons, | "swh_object_icons": swh_object_icons, | ||||
"available_languages": None, | "available_languages": None, | ||||
"swh_client_config": config["client_config"], | "swh_client_config": config["client_config"], | ||||
"oidc_enabled": bool(config["keycloak"]["server_url"]), | "oidc_enabled": bool(config["keycloak"]["server_url"]), | ||||
▲ Show 20 Lines • Show All 88 Lines • Show Last 20 Lines |