diff --git a/website/legacy/urls.py b/website/legacy/urls.py index 6fa4786..c71904a 100644 --- a/website/legacy/urls.py +++ b/website/legacy/urls.py @@ -7,4 +7,5 @@ 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()), ] diff --git a/website/legacy/views.py b/website/legacy/views.py index 7ebcc82..b517583 100644 --- a/website/legacy/views.py +++ b/website/legacy/views.py @@ -3,7 +3,7 @@ from django.utils.decorators import method_decorator from django.views.decorators.cache import cache_control from django.views.generic import RedirectView -from website.blog.models import BlogPostListPage +from website.blog.models import BlogPostListPage, BlogPostTagListPage, BlogPostTagPage @method_decorator(cache_control(max_age=60 * 60), name="dispatch") @@ -16,3 +16,11 @@ class PostsFeedView(RedirectView): @method_decorator(cache_control(max_age=60 * 60), name="dispatch") class AllPagesFeedView(RedirectView): pattern_name = "feed" + + +@method_decorator(cache_control(max_age=60 * 60), name="dispatch") +class TagsView(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)