allow to disable appcat price calculator
This commit is contained in:
parent
6ad8b9aa49
commit
01d35a461b
5 changed files with 49 additions and 3 deletions
|
@ -326,6 +326,7 @@ class VSHNAppCatPriceAdmin(admin.ModelAdmin):
|
|||
"discount_model",
|
||||
"admin_display_base_fees",
|
||||
"admin_display_unit_rates",
|
||||
"public_display_enabled",
|
||||
)
|
||||
list_filter = ("variable_unit", "service", "discount_model")
|
||||
search_fields = ("service__name",)
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
# Generated by Django 5.2 on 2025-06-04 15:45
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("services", "0032_externalpriceplans_service_level"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name="vshnappcatprice",
|
||||
name="public_display_enabled",
|
||||
field=models.BooleanField(
|
||||
default=True,
|
||||
help_text="Enable public display of price calculator on offering detail page",
|
||||
),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name="externalpriceplans",
|
||||
name="compare_to",
|
||||
field=models.ManyToManyField(
|
||||
blank=True, related_name="external_prices", to="services.computeplan"
|
||||
),
|
||||
),
|
||||
]
|
|
@ -310,6 +310,11 @@ class VSHNAppCatPrice(models.Model):
|
|||
default=1, help_text="Maximum supported replicas"
|
||||
)
|
||||
|
||||
public_display_enabled = models.BooleanField(
|
||||
default=True,
|
||||
help_text="Enable public display of price calculator on offering detail page",
|
||||
)
|
||||
|
||||
valid_from = models.DateTimeField(blank=True, null=True)
|
||||
valid_to = models.DateTimeField(blank=True, null=True)
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@
|
|||
<a class="d-flex align-items-center text-gray-500 h-32 lh-32" href="{{ link.url }}" target="_blank">
|
||||
<span class="pr-10">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-box-arrow-up-right" viewBox="0 0 16 16">
|
||||
<path fill-rule="evenodd" d="M8.636 3.5a.5.5 0 0 0-.5-.5H1.5A1.5 1.5 0 0 0 0 4.5v10A1.5 1.5 0 0 0 1.5 16h10a1.5 1.5 0 0 0 1.5-1.5V7.864a.5.5 0 0 0-1 0V14.5a.5.5 0 0 1-.5.5h-10a.5.5 0 0 1-.5-.5v-10a.5.5 0 0 1 .5-.5h6.636a.5.5 0 0 0 .5-.5" fill="#9A63EC"/>
|
||||
<path fill-rule="evenodd" d="M8.636 3.5a.5.5 0 0 0-.5-.5H1.5A1.5 1.5 0 0 0 0 4.5v10A1.5 1.5 0 0 0 1.5 16h10a.5.5 0 0 0 1.5-1.5V7.864a.5.5 0 0 0-1 0V14.5a.5.5 0 0 1-.5.5h-10a.5.5 0 0 1-.5-.5v-10a.5.5 0 0 1 .5-.5h6.636a.5.5 0 0 0 .5-.5" fill="#9A63EC"/>
|
||||
<path fill-rule="evenodd" d="M16 .5a.5.5 0 0 0-.5-.5h-5a.5.5 0 0 0 0 1h3.793L6.146 9.146a.5.5 0 1 0 .708.708L15 1.707V5.5a.5.5 0 0 0 1 0z" fill="#9A63EC"/>
|
||||
</svg>
|
||||
</span>
|
||||
|
@ -159,7 +159,7 @@
|
|||
|
||||
<!-- Price Calculator -->
|
||||
<div class="pt-24" id="plans" style="scroll-margin-top: 30px;">
|
||||
{% if offering.msp == "VS" and pricing_data_by_group_and_service_level %}
|
||||
{% if offering.msp == "VS" and price_calculator_enabled and pricing_data_by_group_and_service_level %}
|
||||
<!-- Interactive Price Calculator -->
|
||||
<h3 class="fs-24 fw-semibold lh-1 mb-12">Choose your Plan</h3>
|
||||
<div class="bg-light rounded-4 p-4 mb-4">
|
||||
|
|
|
@ -113,14 +113,26 @@ def offering_detail(request, provider_slug, service_slug):
|
|||
return generate_exoscale_marketplace_yaml(offering)
|
||||
|
||||
pricing_data_by_group_and_service_level = None
|
||||
price_calculator_enabled = False
|
||||
|
||||
# Generate pricing data for VSHN offerings
|
||||
if offering.msp == "VS":
|
||||
pricing_data_by_group_and_service_level = generate_pricing_data(offering)
|
||||
try:
|
||||
appcat_price = offering.service.vshn_appcat_price.get()
|
||||
price_calculator_enabled = appcat_price.public_display_enabled
|
||||
|
||||
# Only generate pricing data if public display is enabled
|
||||
if price_calculator_enabled:
|
||||
pricing_data_by_group_and_service_level = generate_pricing_data(
|
||||
offering
|
||||
)
|
||||
except VSHNAppCatPrice.DoesNotExist:
|
||||
pass
|
||||
|
||||
context = {
|
||||
"offering": offering,
|
||||
"pricing_data_by_group_and_service_level": pricing_data_by_group_and_service_level,
|
||||
"price_calculator_enabled": price_calculator_enabled,
|
||||
}
|
||||
return render(request, "services/offering_detail.html", context)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue