Skip to content

Commit 7c8b0ce

Browse files
committed
added redirects from old guidance pages
1 parent eb033f0 commit 7c8b0ce

File tree

5 files changed

+22
-207
lines changed

5 files changed

+22
-207
lines changed

application/routers/guidance_.py

+22
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import os
22
import logging
33
from fastapi import APIRouter, Request
4+
from starlette.responses import RedirectResponse
45
from application.core.templates import templates
56

67
router = APIRouter()
@@ -66,6 +67,13 @@ def get_breadcrumbs(path):
6667
return crumb_dict
6768

6869

70+
def handleGuidanceRedirects(url_path, redirects):
71+
for redirect in redirects:
72+
if redirect["from"] == url_path:
73+
return RedirectResponse(url=redirect["to"], status_code=301)
74+
return False
75+
76+
6977
@router.get("/{url_path:path}")
7078
async def catch_all(request: Request, url_path: str):
7179
index_file = "index"
@@ -77,6 +85,20 @@ async def catch_all(request: Request, url_path: str):
7785
elif url_path[-1] == "/":
7886
url_path += index_file
7987

88+
# Some redirects from old guidance
89+
90+
# introduction
91+
shouldRedirect = handleGuidanceRedirects(
92+
url_path,
93+
[
94+
{"from": "introduction", "to": "/guidance"},
95+
{"from": "how-to-provide-data", "to": "/guidance"},
96+
],
97+
)
98+
99+
if shouldRedirect:
100+
return shouldRedirect
101+
80102
# build string of the URL path and then the system path to the template file
81103
root_url_path = "pages/guidance/"
82104
url_path_to_file = root_url_path + url_path

application/templates/pages/guidance/how-to-provide-data.html

-22
This file was deleted.

application/templates/pages/guidance/how-to-provide-data.md

-101
This file was deleted.

application/templates/pages/guidance/introduction.html

-24
This file was deleted.

application/templates/pages/guidance/introduction.md

-60
This file was deleted.

0 commit comments

Comments
 (0)