Add redirects for categories page

This commit is contained in:
Jake Howard 2023-10-06 21:27:39 +01:00
parent 158ba9cbfc
commit 298010d184
Signed by: jake
GPG key ID: 57AFB45680EDD477
2 changed files with 11 additions and 3 deletions

View file

@ -7,5 +7,7 @@ app_name = "legacy"
urlpatterns = [ urlpatterns = [
path("posts/index.xml", views.PostsFeedView.as_view()), path("posts/index.xml", views.PostsFeedView.as_view()),
path("index.xml", views.AllPagesFeedView.as_view()), path("index.xml", views.AllPagesFeedView.as_view()),
path("tags/<slug:slug>/", views.TagsView.as_view()), path("tags/<slug:slug>/", views.TagView.as_view()),
path("tags/", views.TagView.as_view()),
path("categories/", views.TagView.as_view()),
] ]

View file

@ -19,8 +19,14 @@ class AllPagesFeedView(RedirectView):
@method_decorator(cache_control(max_age=60 * 60), name="dispatch") @method_decorator(cache_control(max_age=60 * 60), name="dispatch")
class TagsView(RedirectView): class TagView(RedirectView):
def get_redirect_url(self, slug: str) -> str: def get_redirect_url(self, slug: str) -> str:
get_object_or_404(BlogPostTagListPage)
tag = get_object_or_404(BlogPostTagPage, slug=slug) tag = get_object_or_404(BlogPostTagPage, slug=slug)
return tag.get_url(request=self.request) 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)