Compare commits
No commits in common. "985fa1907f9ead24509d866555fde9fba7b992b0" and "69807d034ebb79eab96be44e4c15fdd6ff7245b8" have entirely different histories.
985fa1907f
...
69807d034e
3 changed files with 7 additions and 25 deletions
|
|
@ -578,7 +578,7 @@ class ServiceInstance(ServalaModelMixin, models.Model):
|
||||||
}
|
}
|
||||||
|
|
||||||
class urls(urlman.Urls):
|
class urls(urlman.Urls):
|
||||||
base = "{self.organization.urls.instances}{self.name}-{self.pk}/"
|
base = "{self.organization.urls.instances}{self.name}/"
|
||||||
update = "{base}update/"
|
update = "{base}update/"
|
||||||
delete = "{base}delete/"
|
delete = "{base}delete/"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -96,7 +96,7 @@
|
||||||
{% for instance in service_instances %}
|
{% for instance in service_instances %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<a href="{{ instance.urls.base }}"
|
<a href="{% url 'frontend:organization.instance' organization=object.slug slug=instance.name %}"
|
||||||
class="fw-semibold text-decoration-none">{{ instance.name }}</a>
|
class="fw-semibold text-decoration-none">{{ instance.name }}</a>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
|
|
@ -117,13 +117,13 @@
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<div class="btn-group btn-group-sm" role="group">
|
<div class="btn-group btn-group-sm" role="group">
|
||||||
<a href="{{ instance.urls.base }}"
|
<a href="{% url 'frontend:organization.instance' organization=object.slug slug=instance.name %}"
|
||||||
class="btn btn-outline-primary btn-sm"
|
class="btn btn-outline-primary btn-sm"
|
||||||
title="{% translate 'View Details' %}">
|
title="{% translate 'View Details' %}">
|
||||||
<i class="bi bi-eye"></i>
|
<i class="bi bi-eye"></i>
|
||||||
</a>
|
</a>
|
||||||
{% if instance.has_change_permission %}
|
{% if instance.has_change_permission %}
|
||||||
<a href="{{ instance.urls.update }}"
|
<a href="{% url 'frontend:organization.instance.update' organization=object.slug slug=instance.name %}"
|
||||||
class="btn btn-outline-secondary btn-sm"
|
class="btn btn-outline-secondary btn-sm"
|
||||||
title="{% translate 'Edit' %}">
|
title="{% translate 'Edit' %}">
|
||||||
<i class="bi bi-pencil"></i>
|
<i class="bi bi-pencil"></i>
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
from django.contrib import messages
|
from django.contrib import messages
|
||||||
from django.core.exceptions import ValidationError
|
from django.core.exceptions import ValidationError
|
||||||
from django.http import HttpResponse, Http404
|
from django.http import HttpResponse
|
||||||
from django.shortcuts import redirect
|
from django.shortcuts import redirect
|
||||||
from django.utils.functional import cached_property
|
from django.utils.functional import cached_property
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
@ -178,7 +178,7 @@ class ServiceOfferingDetailView(OrganizationViewMixin, HtmxViewMixin, DetailView
|
||||||
class ServiceInstanceMixin:
|
class ServiceInstanceMixin:
|
||||||
model = ServiceInstance
|
model = ServiceInstance
|
||||||
context_object_name = "instance"
|
context_object_name = "instance"
|
||||||
pk_url_kwarg = "slug"
|
slug_field = "name"
|
||||||
|
|
||||||
def dispatch(self, *args, **kwargs):
|
def dispatch(self, *args, **kwargs):
|
||||||
self._has_warned = False
|
self._has_warned = False
|
||||||
|
|
@ -195,25 +195,7 @@ class ServiceInstanceMixin:
|
||||||
)
|
)
|
||||||
|
|
||||||
def get_object(self, **kwargs):
|
def get_object(self, **kwargs):
|
||||||
queryset = kwargs.get("queryset") or self.get_queryset()
|
instance = super().get_object(**kwargs)
|
||||||
|
|
||||||
# Get the slug from URL (format: "my-instance-123")
|
|
||||||
slug = self.kwargs.get(self.pk_url_kwarg)
|
|
||||||
if slug is None:
|
|
||||||
raise Http404("No slug provided in URL")
|
|
||||||
|
|
||||||
# Extract pk from the slug (everything after the last dash)
|
|
||||||
try:
|
|
||||||
pk_str = slug.rsplit("-", 1)[-1]
|
|
||||||
pk = int(pk_str)
|
|
||||||
except (ValueError, IndexError):
|
|
||||||
raise Http404(f"Invalid slug format: {slug}")
|
|
||||||
|
|
||||||
try:
|
|
||||||
instance = queryset.get(pk=pk)
|
|
||||||
except ServiceInstance.DoesNotExist:
|
|
||||||
raise Http404("Service instance not found")
|
|
||||||
|
|
||||||
if not instance.kubernetes_object and not self._has_warned:
|
if not instance.kubernetes_object and not self._has_warned:
|
||||||
messages.warning(
|
messages.warning(
|
||||||
self.request,
|
self.request,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue