documentation: Support having no sidebar for policies docs.

We document the sidebar as being optional, so make it so.
This commit is contained in:
Alex Vandiver 2023-12-18 20:57:47 +00:00 committed by Tim Abbott
parent 3fcb44e24d
commit 9c336e4374
4 changed files with 18 additions and 2 deletions

View File

@ -0,0 +1 @@
This is the custom privacy policy.

View File

@ -0,0 +1 @@
These are the custom terms and conditions.

View File

@ -694,6 +694,10 @@ class PrivacyTermsTest(ZulipTestCase):
response = self.client_get("/policies/terms")
self.assert_in_response(not_configured_message, response)
with self.settings(POLICIES_DIRECTORY="zerver/policies_minimal"):
response = self.client_get("/policies/terms")
self.assert_in_success_response(["These are the custom terms and conditions."], response)
with self.settings(POLICIES_DIRECTORY="corporate/policies"):
response = self.client_get("/policies/terms")
self.assert_in_success_response(["Kandra Labs"], response)
@ -704,6 +708,10 @@ class PrivacyTermsTest(ZulipTestCase):
response = self.client_get("/policies/privacy")
self.assert_in_response(not_configured_message, response)
with self.settings(POLICIES_DIRECTORY="zerver/policies_minimal"):
response = self.client_get("/policies/privacy")
self.assert_in_success_response(["This is the custom privacy policy."], response)
with self.settings(POLICIES_DIRECTORY="corporate/policies"):
response = self.client_get("/policies/privacy")
self.assert_in_success_response(["Kandra Labs"], response)

View File

@ -182,7 +182,10 @@ class MarkdownDirectoryView(ApiURLView):
context["doc_root"] = "/policies/"
context["doc_root_title"] = "Terms and policies"
sidebar_article = self.get_path("sidebar_index")
sidebar_index = sidebar_article.article_path
if sidebar_article.article_http_status == 200:
sidebar_index = sidebar_article.article_path
else:
sidebar_index = None
title_base = "Zulip terms and policies"
elif self.api_doc_view:
context["page_is_api_center"] = True
@ -234,7 +237,10 @@ class MarkdownDirectoryView(ApiURLView):
if endpoint_name and endpoint_method:
context["api_url_context"]["API_ENDPOINT_NAME"] = endpoint_name + ":" + endpoint_method
sidebar_html = render_markdown_path(sidebar_index)
if sidebar_index is not None:
sidebar_html = render_markdown_path(sidebar_index)
else:
sidebar_html = ""
tree = html.fragment_fromstring(sidebar_html, create_parent=True)
if not context.get("page_is_policy_center", False):
home_h1 = Element("h1")