diff --git a/corporate/urls.py b/corporate/urls.py index c0c81164b8..e95a1a2ed1 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/", app_download_link_redirect), path("apps/", 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 fc4018296a..d82825f170 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.+)", "docs/(?P.+)", - "for/working-groups-and-communities/", "casper/(?P.+)", "static/(?P.+)", "flush_caches", diff --git a/zerver/lib/url_redirects.py b/zerver/lib/url_redirects.py index f106b3ec62..0a67cc393f 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 247ed6b6c8..fe5fa6c080 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)