Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

urls: Extend documentation URL redirects system to corporate landing pages.

Lauryn Menard5a7aa8228acf
diff --git a/corporate/urls.py b/corporate/urls.py
index c0c81164b82..e95a1a2ed1a 100644
--- a/corporate/urls.py
+++ b/corporate/urls.py
@@ -23,6 +23,7 @@ from corporate.views.support import support_request
from corporate.views.upgrade import initial_upgrade, sponsorship, upgrade
from corporate.views.webhook import stripe_webhook
from zerver.lib.rest import rest_path
+from zerver.lib.url_redirects import LANDING_PAGE_REDIRECTS
i18n_urlpatterns: Any = [
# Zephyr/MIT
@@ -52,15 +53,11 @@ v1_api_and_json_patterns = [
landing_page_urls = [
# Landing page, features pages, signup form, etc.
path("hello/", hello_view),
- path("new-user/", RedirectView.as_view(url="/hello", permanent=True)),
path("features/", landing_view, {"template_name": "corporate/features.html"}),
path("plans/", plans_view, name="plans"),
path("apps/", apps_view),
path("apps/download/<platform>", app_download_link_redirect),
path("apps/<platform>", apps_view),
- path(
- "developer-community/", RedirectView.as_view(url="/development-community/", permanent=True)
- ),
path(
"development-community/",
landing_view,
@@ -79,17 +76,11 @@ landing_page_urls = [
landing_view,
{"template_name": "corporate/for/communities.html"},
),
- # We merged this into /for/communities.
- path(
- "for/working-groups-and-communities/",
- RedirectView.as_view(url="/for/communities/", permanent=True),
- ),
path("for/education/", landing_view, {"template_name": "corporate/for/education.html"}),
path("for/events/", landing_view, {"template_name": "corporate/for/events.html"}),
path("for/open-source/", landing_view, {"template_name": "corporate/for/open-source.html"}),
path("for/research/", landing_view, {"template_name": "corporate/for/research.html"}),
path("for/business/", landing_view, {"template_name": "corporate/for/business.html"}),
- path("for/companies/", RedirectView.as_view(url="/for/business/", permanent=True)),
# case-studies
path(
"case-studies/idrift/",
@@ -128,6 +119,12 @@ landing_page_urls = [
),
path("communities/", communities_view),
]
+
+# Redirects due to us having moved or combined landing pages:
+for redirect in LANDING_PAGE_REDIRECTS:
+ old_url = redirect.old_url.lstrip("/")
+ landing_page_urls += [path(old_url, RedirectView.as_view(url=redirect.new_url, permanent=True))]
+
i18n_urlpatterns += landing_page_urls
# Make a copy of i18n_urlpatterns so that they appear without prefix for English
diff --git a/zerver/lib/test_helpers.py b/zerver/lib/test_helpers.py
index fc4018296a9..d82825f170a 100644
--- a/zerver/lib/test_helpers.py
+++ b/zerver/lib/test_helpers.py
@@ -481,7 +481,6 @@ def write_instrumentation_reports(full_suite: bool, include_webhooks: bool) -> N
"confirmation_key/",
"node-coverage/(?P<path>.+)",
"docs/(?P<path>.+)",
- "for/working-groups-and-communities/",
"casper/(?P<path>.+)",
"static/(?P<path>.+)",
"flush_caches",
diff --git a/zerver/lib/url_redirects.py b/zerver/lib/url_redirects.py
index f106b3ec627..0a67cc393ff 100644
--- a/zerver/lib/url_redirects.py
+++ b/zerver/lib/url_redirects.py
@@ -51,6 +51,14 @@ HELP_DOCUMENTATION_REDIRECTS: List[URLRedirect] = [
URLRedirect("/help/web-public-streams", "/help/public-access-option"),
]
+LANDING_PAGE_REDIRECTS = [
+ # Add URL redirects for corporate landing pages here.
+ URLRedirect("/new-user/", "/hello"),
+ URLRedirect("/developer-community/", "/development-community"),
+ URLRedirect("/for/companies/", "/for/business"),
+ URLRedirect("/for/working-groups-and-communities/", "/for/communities"),
+]
+
DOCUMENTATION_REDIRECTS = (
API_DOCUMENTATION_REDIRECTS + POLICY_DOCUMENTATION_REDIRECTS + HELP_DOCUMENTATION_REDIRECTS
)
diff --git a/zerver/tests/test_urls.py b/zerver/tests/test_urls.py
index 247ed6b6c8f..fe5fa6c080d 100644
--- a/zerver/tests/test_urls.py
+++ b/zerver/tests/test_urls.py
@@ -9,6 +9,7 @@ from zerver.lib.test_classes import ZulipTestCase
from zerver.lib.url_redirects import (
API_DOCUMENTATION_REDIRECTS,
HELP_DOCUMENTATION_REDIRECTS,
+ LANDING_PAGE_REDIRECTS,
POLICY_DOCUMENTATION_REDIRECTS,
)
from zerver.models import Realm, Stream
@@ -176,3 +177,8 @@ class RedirectURLTest(ZulipTestCase):
for redirect in POLICY_DOCUMENTATION_REDIRECTS:
result = self.client_get(redirect.old_url, follow=True)
self.assert_in_success_response(["Policies", "Archive"], result)
+
+ def test_landing_page_redirects(self) -> None:
+ for redirect in LANDING_PAGE_REDIRECTS:
+ result = self.client_get(redirect.old_url, follow=True)
+ self.assert_in_success_response(["Download"], result)