mirror of
				https://github.com/zulip/zulip.git
				synced 2025-10-31 03:53:50 +00:00 
			
		
		
		
	templates: Add new context variables to all templates.
This adds a few new helpful context variables that we can use to compute URLs in all of our templates: * external_uri_scheme: http(s):// * server_uri: The base URL for the server's canonical name * realm_uri: The base URL for the user's realm This is preparatory work for making realm_uri != server_uri when we add support for subdomains.
This commit is contained in:
		| @@ -9,7 +9,14 @@ from zproject.backends import (password_auth_enabled, dev_auth_enabled, | ||||
|  | ||||
| def add_settings(request): | ||||
|     # type: (HttpRequest) -> Dict[str, Any] | ||||
|     realm = request.user.realm if hasattr(request.user, "realm") else None | ||||
|     if hasattr(request.user, "realm"): | ||||
|         realm = request.user.realm | ||||
|         realm_uri = realm.uri | ||||
|     else: | ||||
|         realm = None | ||||
|         # TODO: Figure out how to add an assertion that this is not used | ||||
|         realm_uri = settings.SERVER_URI | ||||
|  | ||||
|     return { | ||||
|         'custom_logo_url':           settings.CUSTOM_LOGO_URL, | ||||
|         'register_link_disabled':    settings.REGISTER_LINK_DISABLED, | ||||
| @@ -20,7 +27,10 @@ def add_settings(request): | ||||
|         'only_sso':                  settings.ONLY_SSO, | ||||
|         'external_api_path':         settings.EXTERNAL_API_PATH, | ||||
|         'external_api_uri':          settings.EXTERNAL_API_URI, | ||||
|         'external_host':             settings.EXTERNAL_HOST, | ||||
|         'external_uri_scheme':       settings.EXTERNAL_URI_SCHEME, | ||||
|         'realm_uri':                 realm_uri, | ||||
|         'server_uri':                settings.SERVER_URI, | ||||
|         'api_site_required':         settings.EXTERNAL_API_PATH != "api.zulip.com", | ||||
|         'email_integration_enabled': settings.EMAIL_GATEWAY_BOT != "", | ||||
|         'email_gateway_example':     settings.EMAIL_GATEWAY_EXAMPLE, | ||||
|   | ||||
		Reference in New Issue
	
	Block a user