Skip to content

Commit

Permalink
fix instance details page when instance has no service
Browse files Browse the repository at this point in the history
  • Loading branch information
Sispheor committed Dec 13, 2024
1 parent 5aab666 commit c5986cb
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
2 changes: 2 additions & 0 deletions service_catalog/models/instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ def __str__(self):
@property
def docs(self):
filtered_doc = list()
if self.service is None:
return filtered_doc
from service_catalog.api.serializers import InstanceSerializer
for doc in self.service.docs.all():
context = {
Expand Down
4 changes: 0 additions & 4 deletions service_catalog/views/instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,6 @@ def get_context_data(self, **kwargs):
type__in=[OperationType.UPDATE,
OperationType.DELETE])

# TODO: service form
# TODO: portfolio form
# TODO: tests

# filter operation with when condition
for operation in operations.all():
if not operation.when_instance_authorized(self.object):
Expand Down
17 changes: 9 additions & 8 deletions templates/service_catalog/instance_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,18 @@ <h3 class="card-title"><strong>{{ object.name }}</strong></h3>
<strong class="float-right">{{ object.id }}</strong>
</li>

{% if object.service %}
<li class="list-group-item">
<b>Service</b>
{% has_perm request.user "service_catalog.change_service" object.service as can_edit_service %}

{% if can_edit_service %}
<a href="{% url 'service_catalog:service_edit' object.service.id %}"
class="float-right">{{ object.service.name }}</a>
{% else %}
<a class="float-right">{{ object.service.name }}</a>
{% endif %}
{% if can_edit_service %}
<a href="{% url 'service_catalog:service_edit' object.service.id %}"
class="float-right">{{ object.service.name }}</a>
{% else %}
<a class="float-right">{{ object.service.name }}</a>
{% endif %}
</li>
{% endif %}
<li class="list-group-item">
<b>State</b> <strong
class="float-right text-{{ object.state |map_instance_state }}">{{ object.get_state_display }}</strong>
Expand Down Expand Up @@ -184,4 +185,4 @@ <h3 class="card-title">Admin spec</h3>
{% endblock %}
{% block custom_script %}
<script>add_tab_management();</script>
{% endblock %}
{% endblock %}

0 comments on commit c5986cb

Please sign in to comment.