Merge "Only show image name as a link when the image exists"

This commit is contained in:
Jenkins 2017-04-19 07:59:44 +00:00 committed by Gerrit Code Review
commit e7698f9e0e
3 changed files with 10 additions and 4 deletions

View File

@ -129,7 +129,7 @@ class Server(base.APIResourceWrapper):
from openstack_dashboard.api import glance
if not self.image:
return _("-")
return None
if hasattr(self.image, 'name'):
return self.image.name
if 'name' in self.image:
@ -140,7 +140,7 @@ class Server(base.APIResourceWrapper):
return image.name
except (glance_exceptions.ClientException,
horizon_exceptions.ServiceCatalogException):
return _("-")
return None
@property
def internal_name(self):

View File

@ -101,7 +101,13 @@
{% endwith %}
{% if instance.image %}
<dt>{% trans "Image Name" %}</dt>
<dd><a href="{{ instance.image_url }}">{{ instance.image_name }}</a></dd>
<dd>
{% if instance.image_name %}
<a href="{{ instance.image_url }}">{{ instance.image_name }}</a>
{% else %}
{% trans "-" %}
{% endif %}
</dd>
<dt>{% trans "Image ID" %}</dt>
<dd>{{ instance.image.id }}</dd>
{% else %}

View File

@ -59,7 +59,7 @@ class ServerWrapperTests(test.TestCase):
self.mox.ReplayAll()
server = api.nova.Server(server, self.request)
self.assertEqual('-', server.image_name)
self.assertEqual(None, server.image_name)
class ComputeApiTests(test.APITestCase):