aboutsummaryrefslogtreecommitdiffstats
path: root/pydis_site
diff options
context:
space:
mode:
authorGravatar ks129 <[email protected]>2021-05-03 20:43:52 +0300
committerGravatar ks129 <[email protected]>2021-05-03 20:43:52 +0300
commitb90037846fecddab6dd6399185e73d1d0e8f1e40 (patch)
treefa265933b20df2f80453364d65aab6529e2659cf /pydis_site
parentImplement hacky solution to allow prefix redirects (diff)
Add contributing pages prefix redirection and update tests
Diffstat (limited to 'pydis_site')
-rw-r--r--pydis_site/apps/redirect/redirects.yaml8
-rw-r--r--pydis_site/apps/redirect/tests.py16
2 files changed, 22 insertions, 2 deletions
diff --git a/pydis_site/apps/redirect/redirects.yaml b/pydis_site/apps/redirect/redirects.yaml
index 546e24ae..caaab1f1 100644
--- a/pydis_site/apps/redirect/redirects.yaml
+++ b/pydis_site/apps/redirect/redirects.yaml
@@ -51,3 +51,11 @@ events_code_jams_seven_redirect:
original_path: pages/code-jams/code-jam-7/
redirect_route: "events:page"
redirect_arguments: ["code-jams/7"]
+
+# Guides
+# Prefix redirects
+guides_pydis_guides_contributing_prefix_redirect:
+ original_path: pages/contributing/<path:path>/ # path:path will be joined together with static arguments.
+ redirect_route: "content:page_category"
+ redirect_arguments: ["guides/pydis-guides/contributing/"] # It is important to put / at end in prefix redirect!
+ prefix_redirect: true
diff --git a/pydis_site/apps/redirect/tests.py b/pydis_site/apps/redirect/tests.py
index ac60d1c8..0738a143 100644
--- a/pydis_site/apps/redirect/tests.py
+++ b/pydis_site/apps/redirect/tests.py
@@ -3,7 +3,10 @@ from django.conf import settings
from django.test import TestCase
from django.urls import reverse
-TESTING_ARGUMENTS = {"resources_resources_redirect": ("reading",)}
+TESTING_ARGUMENTS = {
+ "resources_resources_redirect": ("reading",),
+ "guides_pydis_guides_contributing_prefix_redirect": ("sir-lancebot/env-var-reference",),
+}
class RedirectTests(TestCase):
@@ -33,12 +36,21 @@ class RedirectTests(TestCase):
follow=True
)
+ if data.get("prefix_redirect", False):
+ expected_args = (
+ "".join(
+ tuple(data.get("redirect_arguments", ())) + TESTING_ARGUMENTS.get(name, ())
+ ),
+ )
+ else:
+ expected_args = TESTING_ARGUMENTS.get(name, ()) + tuple(data.get("redirect_arguments", ()))
+
self.assertEqual(1, len(resp.redirect_chain))
self.assertRedirects(
resp,
reverse(
f"home:{data['redirect_route']}",
- args=TESTING_ARGUMENTS.get(name, ()) + tuple(data.get("redirect_arguments", ()))
+ args=expected_args
),
status_code=301
)