2013-04-23 18:51:17 +02:00
|
|
|
from __future__ import absolute_import
|
|
|
|
|
2016-08-08 11:27:28 +02:00
|
|
|
from typing import Dict, Any
|
|
|
|
from django.http import HttpRequest
|
2012-10-15 22:52:08 +02:00
|
|
|
from django.conf import settings
|
2016-11-08 10:00:31 +01:00
|
|
|
|
2016-11-02 21:41:10 +01:00
|
|
|
from zerver.models import get_realm_by_string_id
|
2016-07-20 13:33:27 +02:00
|
|
|
from zproject.backends import (password_auth_enabled, dev_auth_enabled,
|
|
|
|
google_auth_enabled, github_auth_enabled)
|
2016-11-02 21:41:10 +01:00
|
|
|
from zerver.lib.utils import get_subdomain
|
2012-10-15 22:52:08 +02:00
|
|
|
|
2016-11-08 10:00:31 +01:00
|
|
|
|
2012-10-30 21:20:52 +01:00
|
|
|
def add_settings(request):
|
2016-08-08 11:27:28 +02:00
|
|
|
# type: (HttpRequest) -> Dict[str, Any]
|
2016-11-08 10:00:31 +01:00
|
|
|
realm = None
|
2016-08-14 00:57:45 +02:00
|
|
|
if hasattr(request.user, "realm"):
|
|
|
|
realm = request.user.realm
|
2016-11-08 10:00:31 +01:00
|
|
|
elif settings.REALMS_HAVE_SUBDOMAINS:
|
|
|
|
subdomain = get_subdomain(request)
|
|
|
|
realm = get_realm_by_string_id(subdomain)
|
|
|
|
|
|
|
|
if realm is not None:
|
2016-08-14 00:57:45 +02:00
|
|
|
realm_uri = realm.uri
|
|
|
|
else:
|
|
|
|
realm_uri = settings.SERVER_URI
|
|
|
|
|
2012-10-17 20:34:38 +02:00
|
|
|
return {
|
2016-07-19 06:56:45 +02:00
|
|
|
'custom_logo_url': settings.CUSTOM_LOGO_URL,
|
2016-07-19 06:52:34 +02:00
|
|
|
'register_link_disabled': settings.REGISTER_LINK_DISABLED,
|
2016-09-14 07:49:51 +02:00
|
|
|
'login_link_disabled': settings.LOGIN_LINK_DISABLED,
|
|
|
|
'about_link_disabled': settings.ABOUT_LINK_DISABLED,
|
2016-07-19 06:49:47 +02:00
|
|
|
'show_oss_announcement': settings.SHOW_OSS_ANNOUNCEMENT,
|
2015-08-20 03:52:21 +02:00
|
|
|
'zulip_admin': settings.ZULIP_ADMINISTRATOR,
|
2016-05-11 19:01:53 +02:00
|
|
|
'terms_of_service': settings.TERMS_OF_SERVICE,
|
2015-08-20 03:52:21 +02:00
|
|
|
'login_url': settings.HOME_NOT_LOGGED_IN,
|
|
|
|
'only_sso': settings.ONLY_SSO,
|
|
|
|
'external_api_path': settings.EXTERNAL_API_PATH,
|
|
|
|
'external_api_uri': settings.EXTERNAL_API_URI,
|
2016-08-14 00:57:45 +02:00
|
|
|
'external_host': settings.EXTERNAL_HOST,
|
2015-08-20 03:52:21 +02:00
|
|
|
'external_uri_scheme': settings.EXTERNAL_URI_SCHEME,
|
2016-08-14 00:57:45 +02:00
|
|
|
'realm_uri': realm_uri,
|
|
|
|
'server_uri': settings.SERVER_URI,
|
2015-08-20 03:52:21 +02:00
|
|
|
'api_site_required': settings.EXTERNAL_API_PATH != "api.zulip.com",
|
2013-12-04 22:35:38 +01:00
|
|
|
'email_integration_enabled': settings.EMAIL_GATEWAY_BOT != "",
|
2015-08-20 03:52:21 +02:00
|
|
|
'email_gateway_example': settings.EMAIL_GATEWAY_EXAMPLE,
|
2016-06-03 01:02:58 +02:00
|
|
|
'open_realm_creation': settings.OPEN_REALM_CREATION,
|
2015-08-20 03:52:21 +02:00
|
|
|
'password_auth_enabled': password_auth_enabled(realm),
|
2016-11-02 21:41:10 +01:00
|
|
|
'dev_auth_enabled': dev_auth_enabled(realm),
|
|
|
|
'google_auth_enabled': google_auth_enabled(realm),
|
|
|
|
'github_auth_enabled': github_auth_enabled(realm),
|
2016-06-18 18:57:22 +02:00
|
|
|
'development_environment': settings.DEVELOPMENT,
|
2016-08-19 03:36:07 +02:00
|
|
|
'support_email': settings.ZULIP_ADMINISTRATOR,
|
2012-10-17 20:34:38 +02:00
|
|
|
}
|
2013-06-17 18:01:22 +02:00
|
|
|
|
2016-11-08 10:00:31 +01:00
|
|
|
|
2013-06-17 18:01:22 +02:00
|
|
|
def add_metrics(request):
|
2016-08-08 11:27:28 +02:00
|
|
|
# type: (HttpRequest) -> Dict[str, str]
|
2013-06-17 18:01:22 +02:00
|
|
|
return {
|
2013-10-29 22:21:17 +01:00
|
|
|
'dropboxAppKey': settings.DROPBOX_APP_KEY
|
2013-06-17 18:01:22 +02:00
|
|
|
}
|