diff --git a/src/servala/core/forms.py b/src/servala/core/forms.py index 034d1c9..baa85fb 100644 --- a/src/servala/core/forms.py +++ b/src/servala/core/forms.py @@ -5,25 +5,14 @@ from django_jsonform.widgets import JSONFormWidget from servala.core.models import ControlPlane, ServiceDefinition CONTROL_PLANE_USER_INFO_SCHEMA = { - "type": "array", - "items": { - "type": "object", - "properties": { - "title": { - "type": "string", - "title": "Title", - }, - "content": { - "type": "string", - "title": "Content", - }, - "help_text": { - "type": "string", - "title": "Help Text (optional)", - }, + "type": "object", + "properties": { + "CNAME Record": { + "title": "CNAME Record", + "type": "string", }, - "required": ["title", "content"], }, + "additionalProperties": {"type": "string"}, } diff --git a/src/servala/core/migrations/0012_convert_user_info_to_array.py b/src/servala/core/migrations/0012_convert_user_info_to_array.py deleted file mode 100644 index 892949e..0000000 --- a/src/servala/core/migrations/0012_convert_user_info_to_array.py +++ /dev/null @@ -1,65 +0,0 @@ -# Generated by Django 5.2.7 on 2025-10-24 10:04 - -from django.db import migrations - - -def convert_user_info_to_array(apps, schema_editor): - """ - Convert user_info from object format {"key": "value"} to array format - [{"title": "key", "content": "value"}]. - """ - ControlPlane = apps.get_model("core", "ControlPlane") - - for control_plane in ControlPlane.objects.all(): - if not control_plane.user_info: - continue - - # If it's already an array (migration already run or new format), skip - if isinstance(control_plane.user_info, list): - continue - - # Convert from dict to array - if isinstance(control_plane.user_info, dict): - new_user_info = [] - for key, value in control_plane.user_info.items(): - new_user_info.append({"title": key, "content": value}) - - control_plane.user_info = new_user_info - control_plane.save(update_fields=["user_info"]) - - -def reverse_user_info_to_object(apps, schema_editor): - """ - Reverse the migration by converting array format back to object format. - Note: help_text will be lost during reversal. - """ - ControlPlane = apps.get_model("core", "ControlPlane") - - for control_plane in ControlPlane.objects.all(): - if not control_plane.user_info: - continue - - # If it's already an object, skip - if isinstance(control_plane.user_info, dict): - continue - - # Convert from array to dict - if isinstance(control_plane.user_info, list): - new_user_info = {} - for item in control_plane.user_info: - if isinstance(item, dict) and "title" in item and "content" in item: - new_user_info[item["title"]] = item["content"] - - control_plane.user_info = new_user_info - control_plane.save(update_fields=["user_info"]) - - -class Migration(migrations.Migration): - - dependencies = [ - ("core", "0011_alter_organizationorigin_billing_entity"), - ] - - operations = [ - migrations.RunPython(convert_user_info_to_array, reverse_user_info_to_object), - ] diff --git a/src/servala/core/models/service.py b/src/servala/core/models/service.py index 3af8c89..42fc500 100644 --- a/src/servala/core/models/service.py +++ b/src/servala/core/models/service.py @@ -156,8 +156,7 @@ class ControlPlane(ServalaModelMixin, models.Model): blank=True, verbose_name=_("User Information"), help_text=_( - 'Array of info objects: [{"title": "…", "content": "…", "help_text": "…"}]. ' - "The help_text field is optional and will be shown as a hover popover on an info icon." + "Key-value information displayed to users when selecting this control plane" ), ) wildcard_dns = models.CharField( diff --git a/src/servala/frontend/templates/frontend/organizations/service_instance_detail.html b/src/servala/frontend/templates/frontend/organizations/service_instance_detail.html index 4aaef14..d375344 100644 --- a/src/servala/frontend/templates/frontend/organizations/service_instance_detail.html +++ b/src/servala/frontend/templates/frontend/organizations/service_instance_detail.html @@ -102,16 +102,7 @@ {% endif %} - {% if control_plane.user_info %} -
-
-

{% translate "Service Provider Zone Information" %}

-
-
- {% include "includes/control_plane_user_info.html" with control_plane=instance.context.control_plane %} -
-
- {% endif %} + {% include "includes/control_plane_user_info.html" with control_plane=instance.context.control_plane %} {% if instance.spec and spec_fieldsets %}
@@ -248,12 +239,3 @@
{% endblock content %} -{% block extra_js %} - -{% endblock extra_js %} diff --git a/src/servala/frontend/templates/frontend/organizations/service_offering_detail.html b/src/servala/frontend/templates/frontend/organizations/service_offering_detail.html index 3305328..842e610 100644 --- a/src/servala/frontend/templates/frontend/organizations/service_offering_detail.html +++ b/src/servala/frontend/templates/frontend/organizations/service_offering_detail.html @@ -7,13 +7,9 @@ {{ offering }} {% endblock page_title %} {% endblock html_title %} -{% partialdef control-plane-info inline=True %} -{% if selected_plane and selected_plane.user_info %} -
-
- {% include "includes/control_plane_user_info.html" with control_plane=selected_plane %} -
-
+{% partialdef control-plane-info %} +{% if selected_plane %} + {% include "includes/control_plane_user_info.html" with control_plane=selected_plane %} {% endif %} {% endpartialdef %} {% partialdef service-form %} @@ -34,99 +30,66 @@ {% endpartialdef %} {% block content %}
- {% if not has_control_planes %} - -
-
-
{% endblock content %} @@ -140,19 +103,4 @@ {% endif %} - {% endblock extra_js %} diff --git a/src/servala/frontend/templates/includes/control_plane_user_info.html b/src/servala/frontend/templates/includes/control_plane_user_info.html index a3a27f5..b9ffe99 100644 --- a/src/servala/frontend/templates/includes/control_plane_user_info.html +++ b/src/servala/frontend/templates/includes/control_plane_user_info.html @@ -1,26 +1,26 @@ {% load i18n %} +{% comment %} +Reusable snippet for displaying ControlPlane user_info +Usage: {% include "includes/control_plane_user_info.html" with control_plane=control_plane_object %} +{% endcomment %} {% if control_plane.user_info %} -
- {% for info in control_plane.user_info %} -
-
- - {{ info.title }} - - {% if info.help_text %} - - {% endif %} -
-
- {{ info.content }} -
+
+
+

{% translate "Service Provider Zone Information" %}

+
+
+
+ + + {% for key, value in control_plane.user_info.items %} + + + + + {% endfor %} + +
{{ key }}{{ value }}
- {% endfor %} +
{% endif %}