from django.shortcuts import render
from courses.models import Course, Category

def landing_view(request):
    """
    Vista principal de la Landing Page ejecutiva / portal institucional de Lo Justo E-Learning.
    """
    stats_data = {
        "courses_count": Course.objects.filter(is_published=True).count() or 15,
        "categories_count": Category.objects.count() or 4,
    }
    return render(request, "pages/landing.html", {"stats": stats_data})

def corporate_view(request):
    """
    Vista dedicada para Planes Corporativos y Capacitación a Equipos/Empresas.
    """
    submitted = False
    if request.method == "POST":
        # Simulación de recepción de solicitud corporativa
        submitted = True
        
    return render(request, "pages/corporate.html", {"submitted": submitted})

def custom_csrf_failure_view(request, reason=""):
    """
    Vista personalizada para errores 403 CSRF.
    """
    return render(request, "pages/errors/403_csrf.html", {"reason": reason}, status=403)
