api_url_context: Replace `uri` with `url`.

In #23380 we want to change all occurrences of `uri` with `url`.
This commit changes the occurrences in a context key `api_uri_context`
and a function name `add_api_uri_context`.
This commit is contained in:
AcKindle3 2023-04-25 20:28:23 -04:00 committed by Tim Abbott
parent 98c9a0366a
commit 0a1ccb3d89
3 changed files with 16 additions and 16 deletions

View File

@ -20,7 +20,7 @@
{% elif page_is_help_center %} {% elif page_is_help_center %}
{{ render_markdown_path(sidebar_index) }} {{ render_markdown_path(sidebar_index) }}
{% else %} {% else %}
{{ render_markdown_path(sidebar_index, context=api_uri_context) }} {{ render_markdown_path(sidebar_index, context=api_url_context) }}
{% endif %} {% endif %}
{% if not page_is_policy_center %} {% if not page_is_policy_center %}
@ -38,9 +38,9 @@
{% if page_is_policy_center %} {% if page_is_policy_center %}
{{ render_markdown_path(article) }} {{ render_markdown_path(article) }}
{% elif page_is_help_center %} {% elif page_is_help_center %}
{{ render_markdown_path(article, context=api_uri_context, help_center=True) }} {{ render_markdown_path(article, context=api_url_context, help_center=True) }}
{% else %} {% else %}
{{ render_markdown_path(article, context=api_uri_context) }} {{ render_markdown_path(article, context=api_url_context) }}
{% endif %} {% endif %}
<div class="documentation-footer"> <div class="documentation-footer">

View File

@ -15,7 +15,7 @@ from zerver.lib.integrations import CATEGORIES, INTEGRATIONS, META_CATEGORY
from zerver.lib.test_classes import ZulipTestCase from zerver.lib.test_classes import ZulipTestCase
from zerver.lib.test_helpers import HostRequestMock from zerver.lib.test_helpers import HostRequestMock
from zerver.models import Realm, get_realm from zerver.models import Realm, get_realm
from zerver.views.documentation import add_api_uri_context from zerver.views.documentation import add_api_url_context
if TYPE_CHECKING: if TYPE_CHECKING:
from django.test.client import _MonkeyPatchedWSGIResponse as TestHttpResponse from django.test.client import _MonkeyPatchedWSGIResponse as TestHttpResponse
@ -356,7 +356,7 @@ class IntegrationTest(ZulipTestCase):
def test_api_url_view_subdomains_base(self) -> None: def test_api_url_view_subdomains_base(self) -> None:
context: Dict[str, Any] = {} context: Dict[str, Any] = {}
add_api_uri_context(context, HostRequestMock()) add_api_url_context(context, HostRequestMock())
self.assertEqual(context["api_url_scheme_relative"], "testserver/api") self.assertEqual(context["api_url_scheme_relative"], "testserver/api")
self.assertEqual(context["api_url"], "http://testserver/api") self.assertEqual(context["api_url"], "http://testserver/api")
self.assertTrue(context["html_settings_links"]) self.assertTrue(context["html_settings_links"])
@ -364,7 +364,7 @@ class IntegrationTest(ZulipTestCase):
@override_settings(ROOT_DOMAIN_LANDING_PAGE=True) @override_settings(ROOT_DOMAIN_LANDING_PAGE=True)
def test_api_url_view_subdomains_homepage_base(self) -> None: def test_api_url_view_subdomains_homepage_base(self) -> None:
context: Dict[str, Any] = {} context: Dict[str, Any] = {}
add_api_uri_context(context, HostRequestMock()) add_api_url_context(context, HostRequestMock())
self.assertEqual(context["api_url_scheme_relative"], "yourZulipDomain.testserver/api") self.assertEqual(context["api_url_scheme_relative"], "yourZulipDomain.testserver/api")
self.assertEqual(context["api_url"], "http://yourZulipDomain.testserver/api") self.assertEqual(context["api_url"], "http://yourZulipDomain.testserver/api")
self.assertFalse(context["html_settings_links"]) self.assertFalse(context["html_settings_links"])
@ -372,7 +372,7 @@ class IntegrationTest(ZulipTestCase):
def test_api_url_view_subdomains_full(self) -> None: def test_api_url_view_subdomains_full(self) -> None:
context: Dict[str, Any] = {} context: Dict[str, Any] = {}
request = HostRequestMock(host="mysubdomain.testserver") request = HostRequestMock(host="mysubdomain.testserver")
add_api_uri_context(context, request) add_api_url_context(context, request)
self.assertEqual(context["api_url_scheme_relative"], "mysubdomain.testserver/api") self.assertEqual(context["api_url_scheme_relative"], "mysubdomain.testserver/api")
self.assertEqual(context["api_url"], "http://mysubdomain.testserver/api") self.assertEqual(context["api_url"], "http://mysubdomain.testserver/api")
self.assertTrue(context["html_settings_links"]) self.assertTrue(context["html_settings_links"])

View File

@ -34,7 +34,7 @@ class DocumentationArticle:
endpoint_method: Optional[str] endpoint_method: Optional[str]
def add_api_uri_context(context: Dict[str, Any], request: HttpRequest) -> None: def add_api_url_context(context: Dict[str, Any], request: HttpRequest) -> None:
context.update(zulip_default_context(request)) context.update(zulip_default_context(request))
subdomain = get_subdomain(request) subdomain = get_subdomain(request)
@ -61,7 +61,7 @@ def add_api_uri_context(context: Dict[str, Any], request: HttpRequest) -> None:
class ApiURLView(TemplateView): class ApiURLView(TemplateView):
def get_context_data(self, **kwargs: Any) -> Dict[str, str]: def get_context_data(self, **kwargs: Any) -> Dict[str, str]:
context = super().get_context_data(**kwargs) context = super().get_context_data(**kwargs)
add_api_uri_context(context, self.request) add_api_url_context(context, self.request)
return context return context
@ -216,13 +216,13 @@ class MarkdownDirectoryView(ApiURLView):
context["PAGE_DESCRIPTION"] = request_notes.placeholder_open_graph_description context["PAGE_DESCRIPTION"] = request_notes.placeholder_open_graph_description
context["sidebar_index"] = sidebar_index context["sidebar_index"] = sidebar_index
# An "article" might require the api_uri_context to be rendered # An "article" might require the api_url_context to be rendered
api_uri_context: Dict[str, Any] = {} api_url_context: Dict[str, Any] = {}
add_api_uri_context(api_uri_context, self.request) add_api_url_context(api_url_context, self.request)
api_uri_context["run_content_validators"] = True api_url_context["run_content_validators"] = True
context["api_uri_context"] = api_uri_context context["api_url_context"] = api_url_context
if endpoint_name and endpoint_method: if endpoint_name and endpoint_method:
context["api_uri_context"]["API_ENDPOINT_NAME"] = endpoint_name + ":" + endpoint_method context["api_url_context"]["API_ENDPOINT_NAME"] = endpoint_name + ":" + endpoint_method
add_google_analytics_context(context) add_google_analytics_context(context)
return context return context
@ -304,7 +304,7 @@ def integration_doc(request: HttpRequest, integration_name: str = REQ()) -> Http
return HttpResponseNotFound() return HttpResponseNotFound()
context: Dict[str, Any] = {} context: Dict[str, Any] = {}
add_api_uri_context(context, request) add_api_url_context(context, request)
context["integration_name"] = integration.name context["integration_name"] = integration.name
context["integration_display_name"] = integration.display_name context["integration_display_name"] = integration.display_name