home: Extract `get_apps_page_url` function from `zulip_default_context`.

This is a prep commit to extract the gear menu as a
handlebars template.

We are extracting it as a function so we can also use it as
a parameter in `page_params`.
This commit is contained in:
Riken Shah 2021-06-15 12:15:17 +00:00 committed by Tim Abbott
parent 5e4b1e1867
commit 61b30e61ad
1 changed files with 7 additions and 5 deletions

View File

@ -72,6 +72,12 @@ def get_valid_realm_from_request(request: HttpRequest) -> Realm:
return realm
def get_apps_page_url() -> str:
if settings.ZILENCER_ENABLED:
return "/apps/"
return "https://zulip.com/apps/" # nocoverage
def zulip_default_context(request: HttpRequest) -> Dict[str, Any]:
"""Context available to all Zulip Jinja2 templates that have a request
passed in. Designed to provide the long list of variables at the
@ -106,10 +112,6 @@ def zulip_default_context(request: HttpRequest) -> Dict[str, Any]:
find_team_link_disabled = False
allow_search_engine_indexing = True
apps_page_url = "https://zulip.com/apps/"
if settings.ZILENCER_ENABLED:
apps_page_url = "/apps/"
apps_page_web = settings.ROOT_DOMAIN_URI + "/accounts/go/"
user_is_authenticated = False
@ -150,7 +152,7 @@ def zulip_default_context(request: HttpRequest) -> Dict[str, Any]:
"realm_name": realm_name,
"realm_icon": realm_icon,
"root_domain_uri": settings.ROOT_DOMAIN_URI,
"apps_page_url": apps_page_url,
"apps_page_url": get_apps_page_url(),
"apps_page_web": apps_page_web,
"open_realm_creation": settings.OPEN_REALM_CREATION,
"development_environment": settings.DEVELOPMENT,