From 040210239fdd8d531dd65d1bf7588df6f14dbbee Mon Sep 17 00:00:00 2001 From: Cindy Lu Date: Tue, 15 Nov 2016 17:38:21 -0800 Subject: [PATCH] Reuse Overview tab for Admin Volume Snapshots Admin should reuse Project's Overview tab. Change-Id: I2c8adff108593f539ddf28713de59b0f9f5c4dd1 Closes-Bug: #1642104 --- .../admin/volumes/snapshots/tabs.py | 2 +- .../admin/volumes/snapshots/views.py | 9 ++++ .../volumes/snapshots/_detail_overview.html | 50 ------------------- .../project/volumes/snapshots/views.py | 3 ++ .../volumes/snapshots/_detail_overview.html | 2 +- 5 files changed, 14 insertions(+), 52 deletions(-) delete mode 100644 openstack_dashboard/dashboards/admin/volumes/templates/volumes/snapshots/_detail_overview.html diff --git a/openstack_dashboard/dashboards/admin/volumes/snapshots/tabs.py b/openstack_dashboard/dashboards/admin/volumes/snapshots/tabs.py index e229f9ce37..c387f0b13b 100644 --- a/openstack_dashboard/dashboards/admin/volumes/snapshots/tabs.py +++ b/openstack_dashboard/dashboards/admin/volumes/snapshots/tabs.py @@ -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') diff --git a/openstack_dashboard/dashboards/admin/volumes/snapshots/views.py b/openstack_dashboard/dashboards/admin/volumes/snapshots/views.py index 8dc27197a2..8dc0eb0533 100644 --- a/openstack_dashboard/dashboards/admin/volumes/snapshots/views.py +++ b/openstack_dashboard/dashboards/admin/volumes/snapshots/views.py @@ -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(): diff --git a/openstack_dashboard/dashboards/admin/volumes/templates/volumes/snapshots/_detail_overview.html b/openstack_dashboard/dashboards/admin/volumes/templates/volumes/snapshots/_detail_overview.html deleted file mode 100644 index 9f8390d5bd..0000000000 --- a/openstack_dashboard/dashboards/admin/volumes/templates/volumes/snapshots/_detail_overview.html +++ /dev/null @@ -1,50 +0,0 @@ -{% load i18n sizeformat parse_date %} - -

{% trans "Volume Snapshot Overview" %}

- -
-

{% trans "Information" %}

-
-
-
{% trans "Name" %}
-
{{ snapshot.name }}
-
{% trans "ID" %}
-
{{ snapshot.id }}
- {% if snapshot.description %} -
{% trans "Description" %}
-
{{ snapshot.description }}
- {% endif %} -
{% trans "Status" %}
-
{{ snapshot.status|capfirst }}
-
{% trans "Volume" %}
-
- - {{ volume.name }} - -
-
-
- -
-

{% trans "Specs" %}

-
-
-
{% trans "Size" %}
-
{{ snapshot.size }} {% trans "GiB" %}
-
{% trans "Created" %}
-
{{ snapshot.created_at|parse_date }}
-
- -

{% trans "Metadata" %}

-
-
- {% if snapshot.metadata.items %} - {% for key, value in snapshot.metadata.items %} -
{{ key }}
-
{{ value }}
- {% endfor %} - {% else %} -
{% trans "None" %}
- {% endif %} -
-
diff --git a/openstack_dashboard/dashboards/project/volumes/snapshots/views.py b/openstack_dashboard/dashboards/project/volumes/snapshots/views.py index 97b205dcf8..4dfe0b7993 100644 --- a/openstack_dashboard/dashboards/project/volumes/snapshots/views.py +++ b/openstack_dashboard/dashboards/project/volumes/snapshots/views.py @@ -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() diff --git a/openstack_dashboard/dashboards/project/volumes/templates/volumes/snapshots/_detail_overview.html b/openstack_dashboard/dashboards/project/volumes/templates/volumes/snapshots/_detail_overview.html index 211d83517d..b14f9775cf 100644 --- a/openstack_dashboard/dashboards/project/volumes/templates/volumes/snapshots/_detail_overview.html +++ b/openstack_dashboard/dashboards/project/volumes/templates/volumes/snapshots/_detail_overview.html @@ -14,7 +14,7 @@
{{ snapshot.status|capfirst }}
{% trans "Volume" %}
- + {% if volume.name %} {{ volume.name }} {% else %}