from django.shortcuts import render
from hub.services.models import Service, CloudProvider, ConsultingPartner, WebsiteFaq


def homepage(request):
    featured_services = Service.objects.filter(is_featured=True).prefetch_related(
        "categories"
    )[:4]

    featured_providers = CloudProvider.objects.filter(is_featured=True)[:4]

    featured_partners = ConsultingPartner.objects.filter(
        is_featured=True
    ).prefetch_related("services", "cloud_providers")[:4]

    websitefaqs = WebsiteFaq.objects.all().order_by("order")

    context = {
        "featured_services": featured_services,
        "featured_providers": featured_providers,
        "featured_partners": featured_partners,
        "websitefaqs": websitefaqs,
    }

    return render(request, "pages/homepage.html", context)


def about(request):
    return render(request, "pages/about.html")
