show inactive plans in full pricelist

This commit is contained in:
Tobias Brunner 2025-06-20 15:59:16 +02:00
parent dc1842ef5a
commit 95e3449015
No known key found for this signature in database
2 changed files with 14 additions and 13 deletions

View file

@ -477,8 +477,13 @@
</thead>
<tbody>
{% for row in pricing_data %}
<tr class="servala-row {% if show_price_comparison and row.external_comparisons or row.internal_comparisons %}has-comparisons{% endif %}">
<td>{{ row.compute_plan }}</td>
<tr class="servala-row {% if not row.is_active %}text-muted opacity-50{% endif %} {% if show_price_comparison and row.external_comparisons or row.internal_comparisons %}has-comparisons{% endif %}">
<td>
{{ row.compute_plan }}
{% if not row.is_active %}
<span class="badge bg-secondary ms-1" title="This compute plan is not active and not available for new public offerings.">Inactive plan</span>
{% endif %}
</td>
<td>{{ row.cloud_provider }}</td>
<td>{{ row.vcpus }}</td>
<td>{{ row.ram }}</td>

View file

@ -2,12 +2,7 @@ import re
from django.shortcuts import render
from collections import defaultdict
from hub.services.models import (
ComputePlan,
VSHNAppCatPrice,
ExternalPricePlans,
StoragePlan,
)
from hub.services.models.pricing import ComputePlan, StoragePlan, ExternalPricePlans, VSHNAppCatPrice
from django.contrib.admin.views.decorators import staff_member_required
from django.db import models
@ -134,8 +129,8 @@ def pricelist(request):
filter_compute_plan_group = request.GET.get("compute_plan_group", "")
filter_service_level = request.GET.get("service_level", "")
# Fetch all active compute plans with related data (move as much sorting/filtering to DB as possible)
compute_plans_qs = ComputePlan.objects.filter(active=True)
# Fetch all compute plans (active and inactive) with related data
compute_plans_qs = ComputePlan.objects.all()
if filter_cloud_provider:
compute_plans_qs = compute_plans_qs.filter(cloud_provider__name=filter_cloud_provider)
if filter_compute_plan_group:
@ -352,6 +347,7 @@ def pricelist(request):
"internal_comparisons": internal_comparisons,
"mandatory_addons": mandatory_addons,
"optional_addons": optional_addons,
"is_active": plan.active,
})
# Order groups correctly, placing "No Group" last
ordered_groups_intermediate = {}
@ -368,9 +364,9 @@ def pricelist(request):
sl_key: list(plans_list)
for sl_key, plans_list in service_levels_dict.items()
}
# Get filter options for dropdowns
# Get filter options for dropdowns (include all providers/groups from all plans, not just active)
all_cloud_providers = (
ComputePlan.objects.filter(active=True)
ComputePlan.objects.all()
.values_list("cloud_provider__name", flat=True)
.distinct()
.order_by("cloud_provider__name")
@ -381,7 +377,7 @@ def pricelist(request):
.order_by("service__name")
)
all_compute_plan_groups = list(
ComputePlan.objects.filter(active=True, group__isnull=False)
ComputePlan.objects.filter(group__isnull=False)
.values_list("group__name", flat=True)
.distinct()
.order_by("group__name")