style offering listing

This commit is contained in:
Tobias Brunner 2025-02-25 10:45:03 +01:00
parent 3efa5326c6
commit 06c532c0ad
No known key found for this signature in database
2 changed files with 193 additions and 153 deletions

View file

@ -1,10 +1,6 @@
from django.shortcuts import render, get_object_or_404
from django.db.models import Q
from hub.services.models import (
ServiceOffering,
CloudProvider,
Category,
)
from hub.services.models import ServiceOffering, CloudProvider, Category, Service
def offering_list(request):
@ -22,6 +18,7 @@ def offering_list(request):
cloud_providers = CloudProvider.objects.all()
categories = Category.objects.filter(parent=None).prefetch_related("children")
services = Service.objects.all().order_by("name") # Add this line
# Handle cloud provider filter
if request.GET.get("cloud_provider"):
@ -37,6 +34,11 @@ def offering_list(request):
Q(service__categories=category) | Q(service__categories__in=subcategories)
).distinct()
# Add service filter handling
if request.GET.get("service"):
service_id = request.GET.get("service")
offerings = offerings.filter(service_id=service_id)
# Handle search
if request.GET.get("search"):
query = request.GET.get("search")
@ -50,6 +52,7 @@ def offering_list(request):
"offerings": offerings,
"cloud_providers": cloud_providers,
"categories": categories,
"services": services,
}
return render(request, "services/offering_list.html", context)