Reuse Overview tab for Admin Volume Snapshots

Admin should reuse Project's Overview tab.

Change-Id: I2c8adff108593f539ddf28713de59b0f9f5c4dd1
Closes-Bug: #1642104
This commit is contained in:
Cindy Lu 2016-11-15 17:38:21 -08:00
parent 29beb99e93
commit 040210239f
5 changed files with 14 additions and 52 deletions

View File

@ -22,7 +22,7 @@ from openstack_dashboard.dashboards.project.volumes.snapshots \
class OverviewTab(overview_tab.OverviewTab):
name = _("Overview")
slug = "overview"
template_name = ("admin/volumes/snapshots/_detail_overview.html")
template_name = ("project/volumes/snapshots/_detail_overview.html")
def get_redirect_url(self):
return reverse('horizon:admin:volumes:index')

View File

@ -64,6 +64,15 @@ class UpdateStatusView(forms.ModalFormView):
class DetailView(views.DetailView):
tab_group_class = vol_snapshot_tabs.SnapshotDetailsTabs
volume_url = 'horizon:admin:volumes:volumes:detail'
def get_context_data(self, **kwargs):
context = super(DetailView, self).get_context_data(**kwargs)
snapshot = self.get_data()
snapshot.volume_url = reverse(self.volume_url,
args=(snapshot.volume_id,))
context["snapshot"] = snapshot
return context
@staticmethod
def get_redirect_url():

View File

@ -1,50 +0,0 @@
{% load i18n sizeformat parse_date %}
<h3>{% trans "Volume Snapshot Overview" %}</h3>
<div class="info row detail">
<h4>{% trans "Information" %}</h4>
<hr class="header_rule">
<dl class="dl-horizontal">
<dt>{% trans "Name" %}</dt>
<dd>{{ snapshot.name }}</dd>
<dt>{% trans "ID" %}</dt>
<dd>{{ snapshot.id }}</dd>
{% if snapshot.description %}
<dt>{% trans "Description" %}</dt>
<dd>{{ snapshot.description }}</dd>
{% endif %}
<dt>{% trans "Status" %}</dt>
<dd>{{ snapshot.status|capfirst }}</dd>
<dt>{% trans "Volume" %}</dt>
<dd>
<a href="{% url 'horizon:admin:volumes:volumes:detail' snapshot.volume_id %}">
{{ volume.name }}
</a>
</dd>
</dl>
</div>
<div class="specs row detail">
<h4>{% trans "Specs" %}</h4>
<hr class="header_rule">
<dl class="dl-horizontal">
<dt>{% trans "Size" %}</dt>
<dd>{{ snapshot.size }} {% trans "GiB" %}</dd>
<dt>{% trans "Created" %}</dt>
<dd>{{ snapshot.created_at|parse_date }}</dd>
</dl>
<h4>{% trans "Metadata" %}</h4>
<hr class="header_rule">
<dl class="dl-horizontal">
{% if snapshot.metadata.items %}
{% for key, value in snapshot.metadata.items %}
<dt>{{ key }}</dt>
<dd>{{ value }}</dd>
{% endfor %}
{% else %}
<dd>{% trans "None" %}</dd>
{% endif %}
</dl>
</div>

View File

@ -68,10 +68,13 @@ class DetailView(tabs.TabView):
tab_group_class = vol_snapshot_tabs.SnapshotDetailTabs
template_name = 'horizon/common/_detail.html'
page_title = "{{ snapshot.name|default:snapshot.id }}"
volume_url = 'horizon:project:volumes:volumes:detail'
def get_context_data(self, **kwargs):
context = super(DetailView, self).get_context_data(**kwargs)
snapshot = self.get_data()
snapshot.volume_url = reverse(self.volume_url,
args=(snapshot.volume_id,))
table = vol_snapshot_tables.VolumeSnapshotsTable(self.request)
context["snapshot"] = snapshot
context["url"] = self.get_redirect_url()

View File

@ -14,7 +14,7 @@
<dd>{{ snapshot.status|capfirst }}</dd>
<dt>{% trans "Volume" %}</dt>
<dd>
<a href="{% url 'horizon:project:volumes:volumes:detail' snapshot.volume_id %}">
<a href="{{ snapshot.volume_url }}">
{% if volume.name %}
{{ volume.name }}
{% else %}