some settings

This commit is contained in:
Tobias Brunner 2025-05-23 08:49:08 +02:00
parent 836187f2aa
commit b0a76b88b4
No known key found for this signature in database
5 changed files with 45 additions and 5 deletions

View file

@ -60,7 +60,8 @@ class Category(models.Model):
order = models.IntegerField(default=0)
class Meta:
verbose_name_plural = "Categories"
verbose_name = "Service Category"
verbose_name_plural = "Service Categories"
ordering = ["order", "name"]
def __str__(self):
@ -513,6 +514,9 @@ class ProgressiveDiscountModel(models.Model):
description = models.TextField(blank=True)
active = models.BooleanField(default=True)
class Meta:
verbose_name = "Discount Model"
def __str__(self):
return self.name
@ -611,6 +615,9 @@ class VSHNAppCatPrice(models.Model):
related_name="price_configs",
)
class Meta:
verbose_name = "AppCat Price"
def __str__(self):
return f"{self.service.name} - {self.get_variable_unit_display()} based pricing"

View file

@ -27,6 +27,10 @@
<th>CPU/Memory Ratio:</th>
<td>{{ plan_data.plan.cpu_mem_ratio }}</td>
</tr>
<tr>
<th>Term:</th>
<td>{{ plan_data.plan.get_term_display }}</td>
</tr>
<tr>
<th>Compute Plan Prices:</th>
<td>
@ -48,8 +52,11 @@
<th>Variable Unit</th>
<th>Service Level</th>
<th>Units</th>
<th>Plan Term</th>
<th>Service Term</th>
<th>Currency</th>
<th>Final Price</th>
<th>Discount</th>
</tr>
</thead>
<tbody>
@ -59,8 +66,17 @@
<td>{{ price.variable_unit }}</td>
<td>{{ price.service_level }}</td>
<td>{{ price.units }}</td>
<td>{{ price.plan_term }}</td>
<td>{{ price.service_term }}</td>
<td>{{ price.currency }}</td>
<td>{{ price.price }}</td>
<td>
{% if price.discount_model %}
{{ price.discount_model.name }}
{% else %}
-
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>

View file

@ -24,7 +24,7 @@ urlpatterns = [
path("subscribe/", views.subscribe, name="subscribe"),
path(
"pricelist/",
views.compute_plan_price_comparison,
views.pricelist,
name="pricelist",
),
]

View file

@ -2,7 +2,7 @@ from django.shortcuts import render
from hub.services.models import ComputePlan, VSHNAppCatPrice, VSHNAppCatUnitRate
def compute_plan_price_comparison(request):
def pricelist(request):
# Get all compute plans and app catalog prices
compute_plans = (
ComputePlan.objects.all()
@ -11,7 +11,7 @@ def compute_plan_price_comparison(request):
)
appcat_prices = (
VSHNAppCatPrice.objects.all()
.select_related("service")
.select_related("service", "discount_model")
.prefetch_related("base_fees", "unit_rates")
)
@ -55,6 +55,17 @@ def compute_plan_price_comparison(request):
VSHNAppCatPrice.ServiceLevel.choices
)[service_level]
# Include discount model information
discount_info = None
if (
price_config.discount_model
and price_config.discount_model.active
):
discount_info = {
"name": price_config.discount_model.name,
"description": price_config.discount_model.description,
}
plan_data["calculated_prices"].append(
{
"service": price_config.service.name,
@ -63,6 +74,9 @@ def compute_plan_price_comparison(request):
"units": units,
"currency": currency,
"price": final_price,
"plan_term": plan.get_term_display(),
"service_term": price_config.get_term_display(),
"discount_model": discount_info,
}
)

View file

@ -246,7 +246,10 @@ JAZZMIN_SETTINGS = {
],
"show_sidebar": True,
"navigation_expanded": True,
"hide_apps": ["hub.broker"],
"hide_apps": ["broker"],
"order_with_respect_to": ["services", "auth"],
"changeform_format_overrides": {"services.ProgressiveDiscountModel": "single"},
"related_modal_active": True,
}
IMPORT_EXPORT_FORMATS = [CSV]