Reduce page title duplication in Images & Instance

Patch https://review.openstack.org/#/c/142802 adds a method of
reducing duplication of page title logic, this patch applies that change
to the project images, instances, and overview views.

Change-Id: I53b4ea3d20add1e5a5ba830535b81ae96bf0e554
Partial-Bug: 1413749
This commit is contained in:
Sam Betts 2015-02-10 14:13:14 +00:00
parent 8d49a2eeb2
commit 6997ddc6ee
12 changed files with 9 additions and 30 deletions

View File

@ -43,12 +43,14 @@ class CreateView(forms.ModalFormView):
template_name = 'project/images/images/create.html'
context_object_name = 'image'
success_url = reverse_lazy("horizon:project:images:index")
page_title = _("Create An Image")
class UpdateView(forms.ModalFormView):
form_class = project_forms.UpdateImageForm
template_name = 'project/images/images/update.html'
success_url = reverse_lazy("horizon:project:images:index")
page_title = _("Update Image")
@memoized.memoized_method
def get_object(self):

View File

@ -37,6 +37,7 @@ class CreateView(forms.ModalFormView):
form_class = project_forms.CreateSnapshot
template_name = 'project/images/snapshots/create.html'
success_url = reverse_lazy("horizon:project:images:index")
page_title = _("Create a Snapshot")
@memoized.memoized_method
def get_object(self):

View File

@ -2,10 +2,6 @@
{% load i18n %}
{% block title %}{% trans "Create An Image" %}{% endblock %}
{% block page_header %}
{% include "horizon/common/_page_header.html" with title=_("Create An Image") %}
{% endblock page_header %}
{% block main %}
{% include 'project/images/images/_create.html' %}
{% endblock %}

View File

@ -2,10 +2,6 @@
{% load i18n %}
{% block title %}{% trans "Update Image" %}{% endblock %}
{% block page_header %}
{% include "horizon/common/_page_header.html" with title=_("Update Image") %}
{% endblock page_header %}
{% block main %}
{% include 'project/images/images/_update.html' %}
{% endblock %}

View File

@ -2,10 +2,6 @@
{% load i18n %}
{% block title %}{% trans "Images" %}{% endblock %}
{% block page_header %}
{% include "horizon/common/_page_header.html" with title=_("Images") %}
{% endblock page_header %}
{% block main %}
{{ table.render }}
{% endblock %}

View File

@ -2,10 +2,6 @@
{% load i18n %}
{% block title %}{% trans "Create Snapshot" %}{% endblock %}
{% block page_header %}
{% include "horizon/common/_page_header.html" with title=_("Create a Snapshot") %}
{% endblock page_header %}
{% block main %}
{% include 'project/images/snapshots/_create.html' %}
{% endblock %}

View File

@ -35,6 +35,7 @@ from openstack_dashboard.dashboards.project.images.images \
class IndexView(tables.DataTableView):
table_class = images_tables.ImagesTable
template_name = 'project/images/index.html'
page_title = _("Images")
def has_prev_data(self, table):
return getattr(self, "_prev_%s" % table.name, False)

View File

@ -2,10 +2,6 @@
{% load i18n %}
{% block title %}{% trans "Instance Admin Password" %}{% endblock %}
{% block page_header %}
{% include "horizon/common/_page_header.html" with title=_("Retrieve Instance Password") %}
{% endblock %}
{% block main %}
{% include "project/instances/_decryptpassword.html" %}
{% endblock %}

View File

@ -2,10 +2,6 @@
{% load i18n %}
{% block title %}{% trans "Instances" %}{% endblock %}
{% block page_header %}
{% include "horizon/common/_page_header.html" with title=_("Instances") %}
{% endblock page_header %}
{% block main %}
{{ table.render }}
{% endblock %}

View File

@ -2,10 +2,6 @@
{% load i18n %}
{% block title %}{% trans "Rebuild Instance" %}{% endblock %}
{% block page_header %}
{% include "horizon/common/_page_header.html" with title=_("Rebuild Instance") %}
{% endblock %}
{% block main %}
{% include "project/instances/_rebuild.html" %}
{% endblock %}

View File

@ -51,6 +51,7 @@ from openstack_dashboard.dashboards.project.instances \
class IndexView(tables.DataTableView):
table_class = project_tables.InstancesTable
template_name = 'project/instances/index.html'
page_title = _("Instances")
def has_more_data(self, table):
return self._more
@ -221,6 +222,7 @@ class RebuildView(forms.ModalFormView):
form_class = project_forms.RebuildInstanceForm
template_name = 'project/instances/rebuild.html'
success_url = reverse_lazy('horizon:project:instances:index')
page_title = _("Rebuild Instance")
def get_context_data(self, **kwargs):
context = super(RebuildView, self).get_context_data(**kwargs)
@ -236,6 +238,7 @@ class DecryptPasswordView(forms.ModalFormView):
form_class = project_forms.DecryptPasswordInstanceForm
template_name = 'project/instances/decryptpassword.html'
success_url = reverse_lazy('horizon:project:instances:index')
page_title = _("Retrieve Instance Password")
def get_context_data(self, **kwargs):
context = super(DecryptPasswordView, self).get_context_data(**kwargs)

View File

@ -20,9 +20,9 @@
from django.template.defaultfilters import capfirst # noqa
from django.template.defaultfilters import floatformat # noqa
from django.utils.translation import ugettext_lazy as _
from django.views.generic import TemplateView # noqa
from horizon.utils import csvbase
from horizon import views
from openstack_dashboard import usage
@ -56,5 +56,5 @@ class ProjectOverview(usage.UsageView):
return self.usage.get_instances()
class WarningView(TemplateView):
class WarningView(views.HorizonTemplateView):
template_name = "project/_warning.html"