discount_details URL parameter for pricelist

This commit is contained in:
Tobias Brunner 2025-05-23 17:12:05 +02:00
parent 19b36b9a2c
commit 5b4392f838
No known key found for this signature in database
2 changed files with 11 additions and 1 deletions

View file

@ -50,8 +50,10 @@
<th>SLA Base</th> <th>SLA Base</th>
<th>SLA Per Unit</th> <th>SLA Per Unit</th>
<th>SLA Price</th> <th>SLA Price</th>
{% if show_discount_details %}
<th>Discount Model</th> <th>Discount Model</th>
<th>Discount Details</th> <th>Discount Details</th>
{% endif %}
<th class="table-warning">Final Price</th> <th class="table-warning">Final Price</th>
</tr> </tr>
</thead> </thead>
@ -73,6 +75,7 @@
<td>{{ row.sla_base|floatformat:2 }}</td> <td>{{ row.sla_base|floatformat:2 }}</td>
<td>{{ row.sla_per_unit|floatformat:4 }}</td> <td>{{ row.sla_per_unit|floatformat:4 }}</td>
<td>{{ row.sla_price|floatformat:2 }}</td> <td>{{ row.sla_price|floatformat:2 }}</td>
{% if show_discount_details %}
<td> <td>
{% if row.has_discount %} {% if row.has_discount %}
{{ row.discount_model }} {{ row.discount_model }}
@ -98,6 +101,7 @@
<small class="text-muted">No discount applied</small> <small class="text-muted">No discount applied</small>
{% endif %} {% endif %}
</td> </td>
{% endif %}
<td class="table-warning fw-bold">{{ row.final_price|floatformat:2 }}</td> <td class="table-warning fw-bold">{{ row.final_price|floatformat:2 }}</td>
</tr> </tr>
{% endfor %} {% endfor %}

View file

@ -12,6 +12,9 @@ def natural_sort_key(name):
def pricelist(request): def pricelist(request):
"""Generate comprehensive price list grouped by compute plan groups and service levels""" """Generate comprehensive price list grouped by compute plan groups and service levels"""
# Check if discount details should be shown
show_discount_details = request.GET.get("discount_details", "").lower() == "true"
# Fetch all active compute plans with related data # Fetch all active compute plans with related data
compute_plans = ( compute_plans = (
ComputePlan.objects.filter(active=True) ComputePlan.objects.filter(active=True)
@ -223,5 +226,8 @@ def pricelist(request):
for sl_key, plans_list in service_levels_dict.items() for sl_key, plans_list in service_levels_dict.items()
} }
context = {"pricing_data_by_group_and_service_level": final_context_data} context = {
"pricing_data_by_group_and_service_level": final_context_data,
"show_discount_details": show_discount_details,
}
return render(request, "services/pricelist.html", context) return render(request, "services/pricelist.html", context)