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

View file

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

View file

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

View file

@ -2,7 +2,7 @@ from django.shortcuts import render
from hub.services.models import ComputePlan, VSHNAppCatPrice, VSHNAppCatUnitRate 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 # Get all compute plans and app catalog prices
compute_plans = ( compute_plans = (
ComputePlan.objects.all() ComputePlan.objects.all()
@ -11,7 +11,7 @@ def compute_plan_price_comparison(request):
) )
appcat_prices = ( appcat_prices = (
VSHNAppCatPrice.objects.all() VSHNAppCatPrice.objects.all()
.select_related("service") .select_related("service", "discount_model")
.prefetch_related("base_fees", "unit_rates") .prefetch_related("base_fees", "unit_rates")
) )
@ -55,6 +55,17 @@ def compute_plan_price_comparison(request):
VSHNAppCatPrice.ServiceLevel.choices VSHNAppCatPrice.ServiceLevel.choices
)[service_level] )[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( plan_data["calculated_prices"].append(
{ {
"service": price_config.service.name, "service": price_config.service.name,
@ -63,6 +74,9 @@ def compute_plan_price_comparison(request):
"units": units, "units": units,
"currency": currency, "currency": currency,
"price": final_price, "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, "show_sidebar": True,
"navigation_expanded": 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] IMPORT_EXPORT_FORMATS = [CSV]