diff --git a/hub/services/admin/pricing.py b/hub/services/admin/pricing.py index 7ee0b51..6da4852 100644 --- a/hub/services/admin/pricing.py +++ b/hub/services/admin/pricing.py @@ -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",) diff --git a/hub/services/migrations/0033_vshnappcatprice_public_display_enabled_and_more.py b/hub/services/migrations/0033_vshnappcatprice_public_display_enabled_and_more.py new file mode 100644 index 0000000..6089f11 --- /dev/null +++ b/hub/services/migrations/0033_vshnappcatprice_public_display_enabled_and_more.py @@ -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" + ), + ), + ] diff --git a/hub/services/models/pricing.py b/hub/services/models/pricing.py index dc557ea..42b2778 100644 --- a/hub/services/models/pricing.py +++ b/hub/services/models/pricing.py @@ -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) diff --git a/hub/services/templates/services/offering_detail.html b/hub/services/templates/services/offering_detail.html index 37c87fa..134dc2f 100644 --- a/hub/services/templates/services/offering_detail.html +++ b/hub/services/templates/services/offering_detail.html @@ -61,7 +61,7 @@ - + @@ -159,7 +159,7 @@
- {% 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 %}

Choose your Plan

diff --git a/hub/services/views/offerings.py b/hub/services/views/offerings.py index 23ba569..4730b4a 100644 --- a/hub/services/views/offerings.py +++ b/hub/services/views/offerings.py @@ -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)