From 298010d18461d7bc1dc1d11fab73e64ad3d67f98 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Fri, 6 Oct 2023 21:27:39 +0100 Subject: [PATCH] Add redirects for categories page --- website/legacy/urls.py | 4 +++- website/legacy/views.py | 10 ++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/website/legacy/urls.py b/website/legacy/urls.py index c71904a..9d909bf 100644 --- a/website/legacy/urls.py +++ b/website/legacy/urls.py @@ -7,5 +7,7 @@ app_name = "legacy" urlpatterns = [ path("posts/index.xml", views.PostsFeedView.as_view()), path("index.xml", views.AllPagesFeedView.as_view()), - path("tags//", views.TagsView.as_view()), + path("tags//", views.TagView.as_view()), + path("tags/", views.TagView.as_view()), + path("categories/", views.TagView.as_view()), ] diff --git a/website/legacy/views.py b/website/legacy/views.py index b517583..02b1a87 100644 --- a/website/legacy/views.py +++ b/website/legacy/views.py @@ -19,8 +19,14 @@ class AllPagesFeedView(RedirectView): @method_decorator(cache_control(max_age=60 * 60), name="dispatch") -class TagsView(RedirectView): +class TagView(RedirectView): def get_redirect_url(self, slug: str) -> str: - get_object_or_404(BlogPostTagListPage) tag = get_object_or_404(BlogPostTagPage, slug=slug) return tag.get_url(request=self.request) + + +@method_decorator(cache_control(max_age=60 * 60), name="dispatch") +class TagsView(RedirectView): + def get_redirect_url(self) -> str: + tag_list = get_object_or_404(BlogPostTagListPage) + return tag_list.get_url(request=self.request)