subdomains: Hardcode REALMS_HAVE_SUBDOMAINS in API docs.

This commit is contained in:
Tim Abbott 2017-10-01 22:59:20 -07:00
parent 262a0692ab
commit 66658bbf25
2 changed files with 10 additions and 26 deletions

View File

@ -108,16 +108,6 @@ class IntegrationTest(TestCase):
for integration in HUBOT_LOZENGES.values():
self.assertTrue(os.path.isfile(os.path.join(DEPLOY_ROOT, integration.logo)))
@override_settings(REALMS_HAVE_SUBDOMAINS=False)
def test_api_url_view_base(self):
# type: () -> None
context = dict() # type: Dict[str, Any]
add_api_uri_context(context, HostRequestMock())
self.assertEqual(context["external_api_path_subdomain"], "testserver/api")
self.assertEqual(context["external_api_uri_subdomain"], "http://testserver/api")
self.assertTrue(context["html_settings_links"])
@override_settings(REALMS_HAVE_SUBDOMAINS=True)
def test_api_url_view_subdomains_base(self):
# type: () -> None
context = dict() # type: Dict[str, Any]
@ -126,7 +116,6 @@ class IntegrationTest(TestCase):
self.assertEqual(context["external_api_uri_subdomain"], "http://testserver/api")
self.assertTrue(context["html_settings_links"])
@override_settings(REALMS_HAVE_SUBDOMAINS=True)
@override_settings(ROOT_DOMAIN_LANDING_PAGE=True)
def test_api_url_view_subdomains_homepage_base(self):
# type: () -> None
@ -136,7 +125,6 @@ class IntegrationTest(TestCase):
self.assertEqual(context["external_api_uri_subdomain"], "http://yourZulipDomain.testserver/api")
self.assertFalse(context["html_settings_links"])
@override_settings(REALMS_HAVE_SUBDOMAINS=True)
def test_api_url_view_subdomains_full(self):
# type: () -> None
context = dict() # type: Dict[str, Any]

View File

@ -17,22 +17,18 @@ from zerver.templatetags.app_filters import render_markdown_path
def add_api_uri_context(context, request):
# type: (Dict[str, Any], HttpRequest) -> None
if settings.REALMS_HAVE_SUBDOMAINS:
subdomain = get_subdomain(request)
if subdomain or not settings.ROOT_DOMAIN_LANDING_PAGE:
display_subdomain = subdomain
html_settings_links = True
else:
display_subdomain = 'yourZulipDomain'
html_settings_links = False
if display_subdomain != "":
external_api_path_subdomain = '%s.%s' % (display_subdomain,
settings.EXTERNAL_API_PATH)
else:
external_api_path_subdomain = settings.EXTERNAL_API_PATH
subdomain = get_subdomain(request)
if subdomain or not settings.ROOT_DOMAIN_LANDING_PAGE:
display_subdomain = subdomain
html_settings_links = True
else:
display_subdomain = 'yourZulipDomain'
html_settings_links = False
if display_subdomain != "":
external_api_path_subdomain = '%s.%s' % (display_subdomain,
settings.EXTERNAL_API_PATH)
else:
external_api_path_subdomain = settings.EXTERNAL_API_PATH
html_settings_links = True
external_api_uri_subdomain = '%s%s' % (settings.EXTERNAL_URI_SCHEME,
external_api_path_subdomain)