from django.urls import reverse
from django.views.generic import RedirectView


class CategoryRedirectView(RedirectView):
    permanent = True
    query_string = True

    def get_redirect_url(self, *args, **kwargs):
        # Use reverse to build the URL, which handles encoding properly
        return reverse("catalogue:category", kwargs=kwargs)


class CatalogueIndexRedirectView(RedirectView):
    permanent = True
    query_string = True

    def get_redirect_url(self, *args, **kwargs):
        # Use reverse to build the URL for the catalogue index
        return reverse("catalogue:index")
