"""
Views for legal pages (Privacy Policy, Terms of Service)
"""

from django.views.generic import TemplateView
from django.utils.decorators import method_decorator
from django.views.decorators.cache import cache_page


class PrivacyPolicyView(TemplateView):
    """
    Privacy Policy page
    Cached for 24 hours (86400 seconds) to reduce database hits
    """
    template_name = 'legal/privacy.html'

    def get_context_data(self, **kwargs):
        context = super().get_context_data(**kwargs)
        context['page_title'] = 'Privacy Policy'
        context['meta_description'] = 'Privacy Policy for BMC Employee Utility App'
        return context

    @method_decorator(cache_page(86400))  # Cache for 24 hours
    def dispatch(self, *args, **kwargs):
        return super().dispatch(*args, **kwargs)


class TermsOfServiceView(TemplateView):
    """
    Terms of Service page
    Cached for 24 hours (86400 seconds) to reduce database hits
    """
    template_name = 'legal/terms.html'

    def get_context_data(self, **kwargs):
        context = super().get_context_data(**kwargs)
        context['page_title'] = 'Terms of Service'
        context['meta_description'] = 'Terms of Service for BMC Employee Utility App'
        return context

    @method_decorator(cache_page(86400))  # Cache for 24 hours
    def dispatch(self, *args, **kwargs):
        return super().dispatch(*args, **kwargs)
