Merge "Fix wrong link to VM in admin volume detail" into stable/pike

This commit is contained in:
Zuul 2018-02-05 04:03:21 +00:00 committed by Gerrit Code Review
commit 38843a5247
4 changed files with 49 additions and 4 deletions

View File

@ -0,0 +1,34 @@
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from openstack_dashboard.dashboards.project.volumes import tabs as project_tabs
class OverviewTab(project_tabs.OverviewTab):
def get_context_data(self, request):
return {
'volume': self.tab_group.kwargs['volume'],
'detail_url': {
'instance': 'horizon:admin:instances:detail',
'image': 'horizon:admin:images:detail',
'encryption': 'horizon:admin:volumes:encryption_detail',
}
}
class SnapshotTab(project_tabs.SnapshotTab):
pass
class VolumeDetailTabs(project_tabs.VolumeDetailTabs):
tabs = (OverviewTab, project_tabs.SnapshotTab)

View File

@ -33,6 +33,8 @@ from openstack_dashboard.dashboards.admin.volumes \
import forms as volumes_forms
from openstack_dashboard.dashboards.admin.volumes \
import tables as volumes_tables
from openstack_dashboard.dashboards.admin.volumes \
import tabs as volumes_tabs
from openstack_dashboard.dashboards.project.volumes \
import views as volumes_views
@ -108,6 +110,8 @@ class VolumesView(tables.PagedTableMixin, volumes_views.VolumeTableMixIn,
class DetailView(volumes_views.DetailView):
tab_group_class = volumes_tabs.VolumeDetailTabs
def get_context_data(self, **kwargs):
context = super(DetailView, self).get_context_data(**kwargs)
table = volumes_tables.VolumesTable(self.request)

View File

@ -27,7 +27,14 @@ class OverviewTab(tabs.Tab):
template_name = ("project/volumes/_detail_overview.html")
def get_context_data(self, request):
return {"volume": self.tab_group.kwargs['volume']}
return {
'volume': self.tab_group.kwargs['volume'],
'detail_url': {
'instance': 'horizon:project:instances:detail',
'image': 'horizon:project:images:images:detail',
'encryption': 'horizon:project:volumes:encryption_detail',
}
}
class SnapshotTab(tabs.TableTab):

View File

@ -31,7 +31,7 @@
<dd>{{ volume.is_bootable|yesno|capfirst }}</dd>
<dt>{% trans "Encrypted" %}</dt>
{% if volume.encrypted %}
<dd><a href="{% url 'horizon:project:volumes:encryption_detail' volume.id %}">{% trans "Yes" %}</a></dd>
<dd><a href="{% url detail_url.encryption volume.id %}">{% trans "Yes" %}</a></dd>
{% else %}
<dd>{% trans "No" %}</dd>
{% endif %}
@ -45,7 +45,7 @@
{% for attachment in volume.attachments %}
<dt>{% trans "Attached To" %}</dt>
<dd>
{% url 'horizon:project:instances:detail' attachment.server_id as instance_url %}
{% url detail_url.instance attachment.server_id as instance_url %}
{% blocktrans trimmed with instance_name=attachment.instance.name device=attachment.device %}
<a href="{{ instance_url }}">{{ instance_name }}</a> on {{ device }}
{% endblocktrans %}
@ -62,7 +62,7 @@
<dl class="dl-horizontal">
<dt>{% trans "Image" %}</dt>
<dd>
{% url 'horizon:project:images:images:detail' volume.volume_image_metadata.image_id as image_url %}
{% url detail_url.image volume.volume_image_metadata.image_id as image_url %}
<a href="{{ image_url }}">{{ volume.volume_image_metadata.image_name }}</a>
</dd>
</dl>