parent
b9ff0e61da
commit
4bf35260ad
6 changed files with 62 additions and 17 deletions
|
|
@ -176,7 +176,6 @@ class ServiceAdmin(admin.ModelAdmin):
|
|||
|
||||
def get_form(self, request, obj=None, **kwargs):
|
||||
form = super().get_form(request, obj, **kwargs)
|
||||
# JSON schema for external_links field
|
||||
external_links_schema = {
|
||||
"type": "array",
|
||||
"title": "External Links",
|
||||
|
|
@ -209,7 +208,6 @@ class CloudProviderAdmin(admin.ModelAdmin):
|
|||
|
||||
def get_form(self, request, obj=None, **kwargs):
|
||||
form = super().get_form(request, obj, **kwargs)
|
||||
# JSON schema for external_links field
|
||||
external_links_schema = {
|
||||
"type": "array",
|
||||
"title": "External Links",
|
||||
|
|
@ -372,3 +370,23 @@ class ServiceOfferingAdmin(admin.ModelAdmin):
|
|||
search_fields = ("description",)
|
||||
autocomplete_fields = ("service", "provider")
|
||||
inlines = (ControlPlaneCRDInline,)
|
||||
|
||||
def get_form(self, request, obj=None, **kwargs):
|
||||
form = super().get_form(request, obj, **kwargs)
|
||||
external_links_schema = {
|
||||
"type": "array",
|
||||
"title": "External Links",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"title": "Link",
|
||||
"properties": {
|
||||
"url": {"type": "string", "format": "uri", "title": "URL"},
|
||||
"title": {"type": "string", "title": "Title"},
|
||||
},
|
||||
"required": ["url", "title"],
|
||||
},
|
||||
}
|
||||
form.base_fields["external_links"].widget = JSONFormWidget(
|
||||
schema=external_links_schema
|
||||
)
|
||||
return form
|
||||
|
|
|
|||
|
|
@ -0,0 +1,23 @@
|
|||
# Generated by Django 5.2.7 on 2025-10-17 02:23
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("core", "0011_organizationinvitation"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name="serviceoffering",
|
||||
name="external_links",
|
||||
field=models.JSONField(
|
||||
blank=True,
|
||||
help_text='JSON array of link objects: {"url": "…", "title": "…"}. ',
|
||||
null=True,
|
||||
verbose_name="External links",
|
||||
),
|
||||
),
|
||||
]
|
||||
|
|
@ -511,6 +511,12 @@ class ServiceOffering(ServalaModelMixin, models.Model):
|
|||
verbose_name=_("Provider"),
|
||||
)
|
||||
description = models.TextField(blank=True, verbose_name=_("Description"))
|
||||
external_links = models.JSONField(
|
||||
null=True,
|
||||
blank=True,
|
||||
verbose_name=_("External links"),
|
||||
help_text=('JSON array of link objects: {"url": "…", "title": "…"}. '),
|
||||
)
|
||||
osb_plan_id = models.CharField(
|
||||
max_length=100,
|
||||
null=True,
|
||||
|
|
|
|||
|
|
@ -32,13 +32,7 @@
|
|||
<h6 class="mb-3">{% translate "External Links" %}</h6>
|
||||
<div class="d-flex flex-wrap gap-2">
|
||||
{% for link in service.external_links %}
|
||||
<a href="{{ link.url }}"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
class="btn btn-outline-primary btn-sm">
|
||||
{{ link.title }}
|
||||
<i class="bi bi-box-arrow-up-right ms-1"></i>
|
||||
</a>
|
||||
{% include "includes/external_link.html" %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -64,19 +64,16 @@
|
|||
{{ select_form }}
|
||||
</form>
|
||||
{% endif %}
|
||||
{% if service.external_links %}
|
||||
{% if service.external_links or offering.external_links %}
|
||||
<div class="row mt-3">
|
||||
<div class="col-12">
|
||||
<h6 class="mb-3">{% translate "External Links" %}</h6>
|
||||
<div class="d-flex flex-wrap gap-2">
|
||||
{% for link in service.external_links %}
|
||||
<a href="{{ link.url }}"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
class="btn btn-outline-primary btn-sm">
|
||||
{{ link.title }}
|
||||
<i class="bi bi-box-arrow-up-right ms-1"></i>
|
||||
</a>
|
||||
{% include "includes/external_link.html" %}
|
||||
{% endfor %}
|
||||
{% for link in offering.external_links %}
|
||||
{% include "includes/external_link.html" %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,7 @@
|
|||
<a href="{{ link.url }}"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
class="btn btn-outline-primary btn-sm">
|
||||
{{ link.title }}
|
||||
<i class="bi bi-box-arrow-up-right ms-1"></i>
|
||||
</a>
|
||||
Loading…
Add table
Add a link
Reference in a new issue