diff --git a/horizon/forms/views.py b/horizon/forms/views.py
index 63d8d48d31..e137f0edce 100644
--- a/horizon/forms/views.py
+++ b/horizon/forms/views.py
@@ -18,9 +18,9 @@ import os
from django.conf import settings
from django import http
from django.utils.translation import ugettext_lazy as _
-from django.views import generic
from horizon import exceptions
+from horizon import views
ADD_TO_FIELD_HEADER = "HTTP_X_HORIZON_ADD_TO_FIELD"
@@ -77,7 +77,7 @@ class ModalFormMixin(object):
return context
-class ModalFormView(ModalBackdropMixin, ModalFormMixin, generic.FormView):
+class ModalFormView(ModalBackdropMixin, ModalFormMixin, views.HorizonFormView):
"""The main view class from which all views which handle forms in Horizon
should inherit. It takes care of all details with processing
:class:`~horizon.forms.base.SelfHandlingForm` classes, and modal concerns
diff --git a/horizon/tables/views.py b/horizon/tables/views.py
index 7873712227..d8d800cef1 100644
--- a/horizon/tables/views.py
+++ b/horizon/tables/views.py
@@ -15,7 +15,8 @@
from collections import defaultdict
from django import shortcuts
-from django.views import generic
+
+from horizon import views
from horizon.templatetags.horizon import has_permissions # noqa
@@ -125,7 +126,7 @@ class MultiTableMixin(object):
return handled
-class MultiTableView(MultiTableMixin, generic.TemplateView):
+class MultiTableView(MultiTableMixin, views.HorizonTemplateView):
"""A class-based generic view to handle the display and processing of
multiple :class:`~horizon.tables.DataTable` classes in a single view.
@@ -136,6 +137,7 @@ class MultiTableView(MultiTableMixin, generic.TemplateView):
which returns a set of data for that table; and specify a template for
the ``template_name`` attribute.
"""
+
def construct_tables(self):
tables = self.get_tables().values()
# Early out before data is loaded
diff --git a/horizon/tabs/views.py b/horizon/tabs/views.py
index 6b88a04f6a..6122d72f0b 100644
--- a/horizon/tabs/views.py
+++ b/horizon/tabs/views.py
@@ -11,14 +11,14 @@
# under the License.
from django import http
-from django.views import generic
from horizon import exceptions
from horizon import tables
from horizon.tabs.base import TableTab # noqa
+from horizon import views
-class TabView(generic.TemplateView):
+class TabView(views.HorizonTemplateView):
"""A generic class-based view for displaying a
:class:`horizon.tabs.TabGroup`.
diff --git a/horizon/templates/base.html b/horizon/templates/base.html
index 1b0d2df8e8..58b36e7bf0 100644
--- a/horizon/templates/base.html
+++ b/horizon/templates/base.html
@@ -33,7 +33,9 @@
- {% block page_header %}{% endblock %}
+ {% block page_header %}
+ {% include "horizon/common/_page_header.html" with title=page_title %}
+ {% endblock %}
{% block main %}{% endblock %}
diff --git a/horizon/test/tests/views.py b/horizon/test/tests/views.py
new file mode 100644
index 0000000000..edfcc6bd06
--- /dev/null
+++ b/horizon/test/tests/views.py
@@ -0,0 +1,92 @@
+# Copyright 2015 Cisco Systems, Inc.
+#
+# 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 horizon.test import helpers as test
+from horizon import views
+
+from django import forms
+from django.test import client
+from django.views import generic
+
+FAKENAME = "FakeName"
+
+
+class ViewData(object):
+
+ template_name = 'fake'
+
+ def get_context_data(self, **kwargs):
+ context = super(ViewData, self).get_context_data(**kwargs)
+ context['object'] = {'name': 'myName'}
+ return context
+
+
+class PageWithNoTitle(ViewData, views.HorizonTemplateView):
+ pass
+
+
+class PageWithTitle(ViewData, views.HorizonTemplateView):
+ page_title = "A Title"
+
+
+class PageWithTitleData(ViewData, views.HorizonTemplateView):
+ page_title = "A Title: {{ object.name }}"
+
+
+class FormWithTitle(ViewData, views.HorizonFormView):
+ form_class = forms.Form
+ page_title = "A Title: {{ object.name }}"
+
+
+class ViewWithTitle(views.PageTitleMixin, generic.TemplateView):
+ page_title = "Fake"
+
+
+class PageTitleTests(test.TestCase):
+
+ def setUp(self):
+ super(PageTitleTests, self).setUp()
+ self.request = client.RequestFactory().get('fake')
+
+ def _dispatch(self, viewClass):
+ p = viewClass()
+ p.request = self.request
+ return p.dispatch(self.request)
+
+ def test_render_title(self):
+ tm = ViewWithTitle()
+ context = tm.render_title({})
+ self.assertEqual("Fake", context['page_title'])
+
+ def test_render_title_override(self):
+ tm = ViewWithTitle()
+ context = tm.render_title({'page_title': "ekaF"})
+ self.assertEqual("ekaF", context['page_title'])
+
+ def test_no_title_set(self):
+ res = self._dispatch(PageWithNoTitle)
+ self.assertEqual("", res.context_data['page_title'])
+
+ def test_title_set(self):
+ res = self._dispatch(PageWithTitle)
+ self.assertEqual("A Title", res.context_data['page_title'])
+
+ def test_title_with_data(self):
+ res = self._dispatch(PageWithTitleData)
+ self.assertEqual("A Title: myName", res.context_data['page_title'])
+
+ def test_form_with_title(self):
+ res = self._dispatch(FormWithTitle)
+ self.assertEqual("A Title: myName", res.context_data['page_title'])
diff --git a/horizon/views.py b/horizon/views.py
index 29c54549a9..5aadaefd40 100644
--- a/horizon/views.py
+++ b/horizon/views.py
@@ -13,18 +13,44 @@
# under the License.
from django import shortcuts
+from django import template
from django.views import generic
import horizon
from horizon import exceptions
+class PageTitleMixin(object):
+ page_title = ""
+
+ def render_title(self, context):
+ if "page_title" not in context:
+ con = template.Context(context)
+ # NOTE(sambetts): Cast to unicode to ensure lazy translations
+ # are handled correctly.
+ temp = template.Template(unicode(self.page_title))
+ context["page_title"] = temp.render(con)
+ return context
+
+ def render_to_response(self, context):
+ context = self.render_title(context)
+ return super(PageTitleMixin, self).render_to_response(context)
+
+
+class HorizonTemplateView(PageTitleMixin, generic.TemplateView):
+ pass
+
+
+class HorizonFormView(PageTitleMixin, generic.FormView):
+ pass
+
+
def user_home(request):
"""Reversible named view to direct a user to the appropriate homepage."""
return shortcuts.redirect(horizon.get_user_home(request.user))
-class APIView(generic.TemplateView):
+class APIView(HorizonTemplateView):
"""A quick class-based view for putting API data into a template.
Subclasses must define one method, ``get_data``, and a template name
@@ -34,6 +60,7 @@ class APIView(generic.TemplateView):
the :func:`horizon.exceptions.handle` error handler if not otherwise
caught.
"""
+
def get_data(self, request, context, *args, **kwargs):
"""This method should handle any necessary API calls, update the
context object, and return the context object at the end.
diff --git a/openstack_dashboard/dashboards/admin/metadata_defs/templates/metadata_defs/detail.html b/openstack_dashboard/dashboards/admin/metadata_defs/templates/metadata_defs/detail.html
index c39a19e964..45ddbb76d7 100644
--- a/openstack_dashboard/dashboards/admin/metadata_defs/templates/metadata_defs/detail.html
+++ b/openstack_dashboard/dashboards/admin/metadata_defs/templates/metadata_defs/detail.html
@@ -3,10 +3,6 @@
{% block title %}{% trans "Namespace Details" %}{% endblock %}
-{% block page_header %}
- {% include "horizon/common/_page_header.html" with title=_("Namespace Details: ")|add:namespace.namespace|default:_("None") %}
-{% endblock page_header %}
-
{% block main %}
diff --git a/openstack_dashboard/dashboards/admin/metadata_defs/views.py b/openstack_dashboard/dashboards/admin/metadata_defs/views.py
index dce599611d..f4d1c45940 100644
--- a/openstack_dashboard/dashboards/admin/metadata_defs/views.py
+++ b/openstack_dashboard/dashboards/admin/metadata_defs/views.py
@@ -86,9 +86,9 @@ class CreateView(forms.ModalFormView):
class DetailView(tabs.TabView):
redirect_url = constants.METADATA_INDEX_URL
-
tab_group_class = admin_tabs.NamespaceDetailTabs
template_name = constants.METADATA_DETAIL_TEMPLATE
+ page_title = _("Namespace Details: {{ namespace.namespace }}")
def get_context_data(self, **kwargs):
context = super(DetailView, self).get_context_data(**kwargs)
diff --git a/openstack_dashboard/dashboards/admin/overview/templates/overview/usage.html b/openstack_dashboard/dashboards/admin/overview/templates/overview/usage.html
index 04f2233a3c..414f3ea69c 100644
--- a/openstack_dashboard/dashboards/admin/overview/templates/overview/usage.html
+++ b/openstack_dashboard/dashboards/admin/overview/templates/overview/usage.html
@@ -2,10 +2,6 @@
{% load i18n %}
{% block title %}{% trans "Usage Overview" %}{% endblock %}
-{% block page_header %}
- {% include "horizon/common/_page_header.html" with title=_("Overview") %}
-{% endblock page_header %}
-
{% block main %}
{% if monitoring %}
diff --git a/openstack_dashboard/dashboards/admin/volumes/templates/volumes/volumes/detail.html b/openstack_dashboard/dashboards/admin/volumes/templates/volumes/volumes/detail.html
index 6c6687990c..18cf6ccda5 100644
--- a/openstack_dashboard/dashboards/admin/volumes/templates/volumes/volumes/detail.html
+++ b/openstack_dashboard/dashboards/admin/volumes/templates/volumes/volumes/detail.html
@@ -2,10 +2,6 @@
{% load i18n %}
{% block title %}{% trans "Volume Details" %}{% endblock %}
-{% block page_header %}
- {% include "horizon/common/_page_header.html" with title=page_title %}
-{% endblock page_header %}
-
{% block main %}
diff --git a/openstack_dashboard/dashboards/admin/volumes/volumes/views.py b/openstack_dashboard/dashboards/admin/volumes/volumes/views.py
index 745d00045d..4033920aee 100644
--- a/openstack_dashboard/dashboards/admin/volumes/volumes/views.py
+++ b/openstack_dashboard/dashboards/admin/volumes/volumes/views.py
@@ -28,14 +28,6 @@ from openstack_dashboard.dashboards.project.volumes.volumes \
class DetailView(volumes_views.DetailView):
template_name = "admin/volumes/volumes/detail.html"
- def get_context_data(self, **kwargs):
- context = super(DetailView, self).get_context_data(**kwargs)
- volume = context["volume"]
- context["page_title"] = _("Volume Details: "
- "%(volume_name)s") % {'volume_name':
- volume.name}
- return context
-
def get_redirect_url(self):
return reverse('horizon:admin:volumes:index')
diff --git a/openstack_dashboard/dashboards/identity/groups/templates/groups/manage.html b/openstack_dashboard/dashboards/identity/groups/templates/groups/manage.html
index d665442139..47beff395c 100644
--- a/openstack_dashboard/dashboards/identity/groups/templates/groups/manage.html
+++ b/openstack_dashboard/dashboards/identity/groups/templates/groups/manage.html
@@ -2,10 +2,6 @@
{% load i18n %}
{% block title %}{% trans 'Group Management' %}{% endblock %}
-{% block page_header %}
- {% include "horizon/common/_page_header.html" with title=page_title %}
-{% endblock page_header %}
-
{% block main %}
{{ group_members_table.render }}
{% endblock %}
diff --git a/openstack_dashboard/dashboards/identity/groups/views.py b/openstack_dashboard/dashboards/identity/groups/views.py
index d50a052eb2..4b9097576a 100644
--- a/openstack_dashboard/dashboards/identity/groups/views.py
+++ b/openstack_dashboard/dashboards/identity/groups/views.py
@@ -120,14 +120,11 @@ class GroupManageMixin(object):
class ManageMembersView(GroupManageMixin, tables.DataTableView):
table_class = project_tables.GroupMembersTable
template_name = constants.GROUPS_MANAGE_VIEW_TEMPLATE
+ page_title = _("Group Management: {{ group.name }}")
def get_context_data(self, **kwargs):
context = super(ManageMembersView, self).get_context_data(**kwargs)
- group = self._get_group()
- context['group'] = group
- context['page_title'] = _("Group Management: "
- "%(group_name)s") % {'group_name':
- group.name}
+ context['group'] = self._get_group()
return context
def get_data(self):
diff --git a/openstack_dashboard/dashboards/project/access_and_security/security_groups/views.py b/openstack_dashboard/dashboards/project/access_and_security/security_groups/views.py
index 603085b8d5..aa3f499c80 100644
--- a/openstack_dashboard/dashboards/project/access_and_security/security_groups/views.py
+++ b/openstack_dashboard/dashboards/project/access_and_security/security_groups/views.py
@@ -40,6 +40,8 @@ from openstack_dashboard.dashboards.project.access_and_security.\
class DetailView(tables.DataTableView):
table_class = project_tables.RulesTable
template_name = 'project/access_and_security/security_groups/detail.html'
+ page_title = _("Manage Security Group Rules: "
+ "{{ security_group.name }} ({{ security_group.id }})")
@memoized.memoized_method
def _get_data(self):
@@ -61,13 +63,7 @@ class DetailView(tables.DataTableView):
def get_context_data(self, **kwargs):
context = super(DetailView, self).get_context_data(**kwargs)
- security_group = self._get_data()
- security_group_name_id = "%s (%s)" % (security_group.name,
- security_group.id)
- context["security_group"] = security_group
- context["page_title"] = _(
- "Manage Security Group Rules: %(security_group)s") % {
- 'security_group': security_group_name_id}
+ context["security_group"] = self._get_data()
return context
diff --git a/openstack_dashboard/dashboards/project/access_and_security/templates/access_and_security/security_groups/detail.html b/openstack_dashboard/dashboards/project/access_and_security/templates/access_and_security/security_groups/detail.html
index 16d65b78fb..2a73220f42 100644
--- a/openstack_dashboard/dashboards/project/access_and_security/templates/access_and_security/security_groups/detail.html
+++ b/openstack_dashboard/dashboards/project/access_and_security/templates/access_and_security/security_groups/detail.html
@@ -2,10 +2,6 @@
{% load i18n %}
{% block title %}{% trans "Manage Security Group Rules" %}{% endblock %}
-{% block page_header %}
- {% include "horizon/common/_page_header.html" with title=page_title %}
-{% endblock page_header %}
-
{% block main %}
diff --git a/openstack_dashboard/dashboards/project/database_backups/templates/database_backups/details.html b/openstack_dashboard/dashboards/project/database_backups/templates/database_backups/details.html
index a5bd62ac8a..3567fa066c 100644
--- a/openstack_dashboard/dashboards/project/database_backups/templates/database_backups/details.html
+++ b/openstack_dashboard/dashboards/project/database_backups/templates/database_backups/details.html
@@ -2,10 +2,6 @@
{% load i18n sizeformat %}
{% block title %}{% trans "Backup Details" %}{% endblock %}
-{% block page_header %}
- {% include "horizon/common/_page_header.html" with title=page_title %}
-{% endblock page_header %}
-
{% block main %}
diff --git a/openstack_dashboard/dashboards/project/database_backups/views.py b/openstack_dashboard/dashboards/project/database_backups/views.py
index dc1825d029..d64e591ee8 100644
--- a/openstack_dashboard/dashboards/project/database_backups/views.py
+++ b/openstack_dashboard/dashboards/project/database_backups/views.py
@@ -75,6 +75,7 @@ class BackupView(horizon_workflows.WorkflowView):
class DetailView(horizon_views.APIView):
template_name = "project/database_backups/details.html"
+ page_title = _("Backup Details: {{ backup.name }}")
def get_data(self, request, context, *args, **kwargs):
backup_id = kwargs.get("backup_id")
@@ -103,8 +104,4 @@ class DetailView(horizon_views.APIView):
instance = None
context['backup'] = backup
context['instance'] = instance
- context['page_title'] = _("Backup Details: "
- "%(backup_name)s") % {'backup_name':
- backup.name}
-
return context
diff --git a/openstack_dashboard/dashboards/project/databases/templates/databases/detail.html b/openstack_dashboard/dashboards/project/databases/templates/databases/detail.html
index 16a984b4b4..62ff753782 100644
--- a/openstack_dashboard/dashboards/project/databases/templates/databases/detail.html
+++ b/openstack_dashboard/dashboards/project/databases/templates/databases/detail.html
@@ -2,10 +2,6 @@
{% load i18n sizeformat %}
{% block title %}{% trans "Instance Details" %}{% endblock %}
-{% block page_header %}
- {% include "horizon/common/_page_header.html" with title=page_title %}
-{% endblock page_header %}
-
{% block main %}
diff --git a/openstack_dashboard/dashboards/project/databases/views.py b/openstack_dashboard/dashboards/project/databases/views.py
index 310961f1a7..85729b4930 100644
--- a/openstack_dashboard/dashboards/project/databases/views.py
+++ b/openstack_dashboard/dashboards/project/databases/views.py
@@ -96,6 +96,7 @@ class LaunchInstanceView(horizon_workflows.WorkflowView):
class DetailView(horizon_tabs.TabbedTableView):
tab_group_class = tabs.InstanceDetailTabs
template_name = 'project/databases/detail.html'
+ page_title = _("Instance Details: {{ instance.name }}")
def get_context_data(self, **kwargs):
context = super(DetailView, self).get_context_data(**kwargs)
@@ -104,9 +105,6 @@ class DetailView(horizon_tabs.TabbedTableView):
context["instance"] = instance
context["url"] = self.get_redirect_url()
context["actions"] = table.render_row_actions(instance)
- context["page_title"] = _("Instance Details: "
- "%(instance_name)s") % {'instance_name':
- instance.name}
return context
@memoized.memoized_method
diff --git a/openstack_dashboard/dashboards/project/firewalls/templates/firewalls/updatefirewall.html b/openstack_dashboard/dashboards/project/firewalls/templates/firewalls/updatefirewall.html
index dbb6acbf82..f4211ca65d 100644
--- a/openstack_dashboard/dashboards/project/firewalls/templates/firewalls/updatefirewall.html
+++ b/openstack_dashboard/dashboards/project/firewalls/templates/firewalls/updatefirewall.html
@@ -2,10 +2,6 @@
{% load i18n %}
{% block title %}{% trans "Edit Firewall" %}{% endblock %}
-{% block page_header %}
- {% include "horizon/common/_page_header.html" with title=page_title %}
-{% endblock page_header %}
-
{% block main %}
{% include 'project/firewalls/_updatefirewall.html' %}
{% endblock %}
diff --git a/openstack_dashboard/dashboards/project/firewalls/templates/firewalls/updatepolicy.html b/openstack_dashboard/dashboards/project/firewalls/templates/firewalls/updatepolicy.html
index 52560b3508..e1cecf53a9 100644
--- a/openstack_dashboard/dashboards/project/firewalls/templates/firewalls/updatepolicy.html
+++ b/openstack_dashboard/dashboards/project/firewalls/templates/firewalls/updatepolicy.html
@@ -2,10 +2,6 @@
{% load i18n %}
{% block title %}{% trans "Edit Policy" %}{% endblock %}
-{% block page_header %}
- {% include "horizon/common/_page_header.html" with title=page_title %}
-{% endblock page_header %}
-
{% block main %}
{% include 'project/firewalls/_updatepolicy.html' %}
{% endblock %}
diff --git a/openstack_dashboard/dashboards/project/firewalls/templates/firewalls/updaterule.html b/openstack_dashboard/dashboards/project/firewalls/templates/firewalls/updaterule.html
index 9b39068c8b..ad230898ef 100644
--- a/openstack_dashboard/dashboards/project/firewalls/templates/firewalls/updaterule.html
+++ b/openstack_dashboard/dashboards/project/firewalls/templates/firewalls/updaterule.html
@@ -2,10 +2,6 @@
{% load i18n %}
{% block title %}{% trans "Edit Rule" %}{% endblock %}
-{% block page_header %}
- {% include "horizon/common/_page_header.html" with title=page_title %}
-{% endblock page_header %}
-
{% block main %}
{% include 'project/firewalls/_updaterule.html' %}
{% endblock %}
diff --git a/openstack_dashboard/dashboards/project/firewalls/views.py b/openstack_dashboard/dashboards/project/firewalls/views.py
index 947f619e4e..02c6abcb46 100644
--- a/openstack_dashboard/dashboards/project/firewalls/views.py
+++ b/openstack_dashboard/dashboards/project/firewalls/views.py
@@ -121,12 +121,12 @@ class UpdateRuleView(forms.ModalFormView):
template_name = "project/firewalls/updaterule.html"
context_object_name = 'rule'
success_url = reverse_lazy("horizon:project:firewalls:index")
+ page_title = _("Edit Rule")
def get_context_data(self, **kwargs):
context = super(UpdateRuleView, self).get_context_data(**kwargs)
context['rule_id'] = self.kwargs['rule_id']
obj = self._get_object()
- context['page_title'] = _("Edit Rule")
if obj:
context['name'] = obj.name_or_id
context['page_title'] = _("Edit Rule "
@@ -159,12 +159,12 @@ class UpdatePolicyView(forms.ModalFormView):
template_name = "project/firewalls/updatepolicy.html"
context_object_name = 'policy'
success_url = reverse_lazy("horizon:project:firewalls:index")
+ page_title = _("Edit Policy")
def get_context_data(self, **kwargs):
context = super(UpdatePolicyView, self).get_context_data(**kwargs)
context["policy_id"] = self.kwargs['policy_id']
obj = self._get_object()
- context['page_title'] = _("Edit Policy")
if obj:
context['name'] = obj.name_or_id
context['page_title'] = _("Edit Policy %s") % obj.name
@@ -192,12 +192,12 @@ class UpdateFirewallView(forms.ModalFormView):
template_name = "project/firewalls/updatefirewall.html"
context_object_name = 'firewall'
success_url = reverse_lazy("horizon:project:firewalls:index")
+ page_title = _("Edit Firewall")
def get_context_data(self, **kwargs):
context = super(UpdateFirewallView, self).get_context_data(**kwargs)
context["firewall_id"] = self.kwargs['firewall_id']
obj = self._get_object()
- context['page_title'] = _("Edit Firewall")
if obj:
context['name'] = obj.name
context['page_title'] = _("Edit Firewall %s") % obj.name
diff --git a/openstack_dashboard/dashboards/project/images/images/views.py b/openstack_dashboard/dashboards/project/images/images/views.py
index 97475b0a03..ca9e7800ad 100644
--- a/openstack_dashboard/dashboards/project/images/images/views.py
+++ b/openstack_dashboard/dashboards/project/images/images/views.py
@@ -83,6 +83,7 @@ class UpdateView(forms.ModalFormView):
class DetailView(tabs.TabView):
tab_group_class = project_tabs.ImageDetailTabs
template_name = 'project/images/images/detail.html'
+ page_title = _("Image Details: {{ image.name }}")
def get_context_data(self, **kwargs):
context = super(DetailView, self).get_context_data(**kwargs)
@@ -91,9 +92,6 @@ class DetailView(tabs.TabView):
context["image"] = image
context["url"] = self.get_redirect_url()
context["actions"] = table.render_row_actions(image)
- context["page_title"] = _("Image Details: "
- "%(image_name)s") % {'image_name':
- image.name}
return context
@staticmethod
diff --git a/openstack_dashboard/dashboards/project/images/templates/images/images/detail.html b/openstack_dashboard/dashboards/project/images/templates/images/images/detail.html
index dd0e163397..0823eefe64 100644
--- a/openstack_dashboard/dashboards/project/images/templates/images/images/detail.html
+++ b/openstack_dashboard/dashboards/project/images/templates/images/images/detail.html
@@ -3,10 +3,6 @@
{% block title %}{% trans "Image Details"%}{% endblock %}
-{% block page_header %}
- {% include "horizon/common/_page_header.html" with title=page_title %}
-{% endblock page_header %}
-
{% block main %}
diff --git a/openstack_dashboard/dashboards/project/instances/templates/instances/detail.html b/openstack_dashboard/dashboards/project/instances/templates/instances/detail.html
index 16a984b4b4..62ff753782 100644
--- a/openstack_dashboard/dashboards/project/instances/templates/instances/detail.html
+++ b/openstack_dashboard/dashboards/project/instances/templates/instances/detail.html
@@ -2,10 +2,6 @@
{% load i18n sizeformat %}
{% block title %}{% trans "Instance Details" %}{% endblock %}
-{% block page_header %}
- {% include "horizon/common/_page_header.html" with title=page_title %}
-{% endblock page_header %}
-
{% block main %}
diff --git a/openstack_dashboard/dashboards/project/instances/views.py b/openstack_dashboard/dashboards/project/instances/views.py
index 178f9f0de2..4917826733 100644
--- a/openstack_dashboard/dashboards/project/instances/views.py
+++ b/openstack_dashboard/dashboards/project/instances/views.py
@@ -252,6 +252,7 @@ class DetailView(tabs.TabView):
tab_group_class = project_tabs.InstanceDetailTabs
template_name = 'project/instances/detail.html'
redirect_url = 'horizon:project:instances:index'
+ page_title = _("Instance Details: {{ instance.name }}")
def get_context_data(self, **kwargs):
context = super(DetailView, self).get_context_data(**kwargs)
@@ -260,9 +261,6 @@ class DetailView(tabs.TabView):
table = project_tables.InstancesTable(self.request)
context["url"] = reverse(self.redirect_url)
context["actions"] = table.render_row_actions(instance)
- context["page_title"] = _("Instance Details: "
- "%(instance_name)s") % {'instance_name':
- instance.name}
return context
@memoized.memoized_method
diff --git a/openstack_dashboard/dashboards/project/networks/templates/networks/detail.html b/openstack_dashboard/dashboards/project/networks/templates/networks/detail.html
index 98fecf1233..4763f323b8 100644
--- a/openstack_dashboard/dashboards/project/networks/templates/networks/detail.html
+++ b/openstack_dashboard/dashboards/project/networks/templates/networks/detail.html
@@ -2,10 +2,6 @@
{% load i18n %}
{% block title %}{% trans "Network Details"%}{% endblock %}
-{% block page_header %}
- {% include "horizon/common/_page_header.html" with title=page_title %}
-{% endblock page_header %}
-
{% block main %}
diff --git a/openstack_dashboard/dashboards/project/networks/views.py b/openstack_dashboard/dashboards/project/networks/views.py
index ec2e26a977..08a817118d 100644
--- a/openstack_dashboard/dashboards/project/networks/views.py
+++ b/openstack_dashboard/dashboards/project/networks/views.py
@@ -94,6 +94,7 @@ class UpdateView(forms.ModalFormView):
class DetailView(tables.MultiTableView):
table_classes = (subnet_tables.SubnetsTable, port_tables.PortsTable)
template_name = 'project/networks/detail.html'
+ page_title = _("Network Details: {{ network.name }}")
def get_subnets_data(self):
try:
@@ -136,9 +137,6 @@ class DetailView(tables.MultiTableView):
table = project_tables.NetworksTable(self.request)
context["url"] = self.get_redirect_url()
context["actions"] = table.render_row_actions(network)
- context["page_title"] = _("Network Details: "
- "%(network_name)s") % {'network_name':
- network.name}
return context
@staticmethod
diff --git a/openstack_dashboard/dashboards/project/overview/templates/overview/usage.html b/openstack_dashboard/dashboards/project/overview/templates/overview/usage.html
index ee804f2131..df04febda2 100644
--- a/openstack_dashboard/dashboards/project/overview/templates/overview/usage.html
+++ b/openstack_dashboard/dashboards/project/overview/templates/overview/usage.html
@@ -2,10 +2,6 @@
{% load i18n %}
{% block title %}{% trans "Instance Overview" %}{% endblock %}
-{% block page_header %}
- {% include "horizon/common/_page_header.html" with title=_("Overview") %}
-{% endblock page_header %}
-
{% block main %}
{% include "horizon/common/_limit_summary.html" %}
diff --git a/openstack_dashboard/dashboards/project/stacks/templates/stacks/detail.html b/openstack_dashboard/dashboards/project/stacks/templates/stacks/detail.html
index d4a6c0dc7f..26f0b86808 100644
--- a/openstack_dashboard/dashboards/project/stacks/templates/stacks/detail.html
+++ b/openstack_dashboard/dashboards/project/stacks/templates/stacks/detail.html
@@ -2,10 +2,6 @@
{% load i18n sizeformat %}
{% block title %}{% trans "Stack Details" %}{% endblock %}
-{% block page_header %}
- {% include "horizon/common/_page_header.html" with title=page_title %}
-{% endblock page_header %}
-
{% block main %}
diff --git a/openstack_dashboard/dashboards/project/stacks/templates/stacks/resource.html b/openstack_dashboard/dashboards/project/stacks/templates/stacks/resource.html
index ca455e7bf9..8d374722e3 100644
--- a/openstack_dashboard/dashboards/project/stacks/templates/stacks/resource.html
+++ b/openstack_dashboard/dashboards/project/stacks/templates/stacks/resource.html
@@ -2,10 +2,6 @@
{% load i18n sizeformat %}
{% block title %}{% trans "Resource Details" %}{% endblock %}
-{% block page_header %}
- {% include "horizon/common/_page_header.html" with title=page_title %}
-{% endblock page_header %}
-
{% block main %}
diff --git a/openstack_dashboard/dashboards/project/stacks/views.py b/openstack_dashboard/dashboards/project/stacks/views.py
index 890cc398a1..a2e7b2d4cf 100644
--- a/openstack_dashboard/dashboards/project/stacks/views.py
+++ b/openstack_dashboard/dashboards/project/stacks/views.py
@@ -196,6 +196,7 @@ class EditStackView(CreateStackView):
class DetailView(tabs.TabView):
tab_group_class = project_tabs.StackDetailTabs
template_name = 'project/stacks/detail.html'
+ page_title = _("Stack Details: {{ stack.stack_name }}")
def get_context_data(self, **kwargs):
context = super(DetailView, self).get_context_data(**kwargs)
@@ -204,9 +205,6 @@ class DetailView(tabs.TabView):
context["stack"] = stack
context["url"] = self.get_redirect_url()
context["actions"] = table.render_row_actions(stack)
- context["page_title"] = _("Stack Details: "
- "%(stack_name)s") % {'stack_name':
- stack.stack_name}
return context
@memoized.memoized_method
diff --git a/openstack_dashboard/dashboards/project/volumes/backups/views.py b/openstack_dashboard/dashboards/project/volumes/backups/views.py
index fbbad2cf89..c33d39905e 100644
--- a/openstack_dashboard/dashboards/project/volumes/backups/views.py
+++ b/openstack_dashboard/dashboards/project/volumes/backups/views.py
@@ -45,6 +45,7 @@ class CreateBackupView(forms.ModalFormView):
class BackupDetailView(tabs.TabView):
tab_group_class = backup_tabs.BackupDetailTabs
template_name = 'project/volumes/backups/detail.html'
+ page_title = _("Volume Backup Details: {{ backup.name }}")
def get_context_data(self, **kwargs):
context = super(BackupDetailView, self).get_context_data(**kwargs)
@@ -53,10 +54,6 @@ class BackupDetailView(tabs.TabView):
context["backup"] = backup
context["url"] = self.get_redirect_url()
context["actions"] = table.render_row_actions(backup)
- context["page_title"] = _("Volume Backup Details: "
- "%(backup_name)s") % {'backup_name':
- backup.name}
-
return context
@memoized.memoized_method
diff --git a/openstack_dashboard/dashboards/project/volumes/snapshots/views.py b/openstack_dashboard/dashboards/project/volumes/snapshots/views.py
index 8fa7e18288..db7a5f2d73 100644
--- a/openstack_dashboard/dashboards/project/volumes/snapshots/views.py
+++ b/openstack_dashboard/dashboards/project/volumes/snapshots/views.py
@@ -61,6 +61,7 @@ class UpdateView(forms.ModalFormView):
class DetailView(tabs.TabView):
tab_group_class = vol_snapshot_tabs.SnapshotDetailTabs
template_name = 'project/volumes/snapshots/detail.html'
+ page_title = _("Volume Snapshot Details: {{ snapshot.name }}")
def get_context_data(self, **kwargs):
context = super(DetailView, self).get_context_data(**kwargs)
@@ -69,9 +70,6 @@ class DetailView(tabs.TabView):
context["snapshot"] = snapshot
context["url"] = self.get_redirect_url()
context["actions"] = table.render_row_actions(snapshot)
- context["page_title"] = _("Volume Snapshot Details: "
- "%(snapshot_name)s") % {'snapshot_name':
- snapshot.name}
return context
@memoized.memoized_method
diff --git a/openstack_dashboard/dashboards/project/volumes/templates/volumes/backups/detail.html b/openstack_dashboard/dashboards/project/volumes/templates/volumes/backups/detail.html
index 06dd311c9a..bcef1820e3 100644
--- a/openstack_dashboard/dashboards/project/volumes/templates/volumes/backups/detail.html
+++ b/openstack_dashboard/dashboards/project/volumes/templates/volumes/backups/detail.html
@@ -2,9 +2,6 @@
{% load i18n %}
{% block title %}{% trans "Volume Backup Details" %}{% endblock %}
-{% block page_header %}
- {% include "horizon/common/_page_header.html" with title=page_title %}
-{% endblock page_header %}
{% block main %}
diff --git a/openstack_dashboard/dashboards/project/volumes/templates/volumes/snapshots/detail.html b/openstack_dashboard/dashboards/project/volumes/templates/volumes/snapshots/detail.html
index cdfe652bb8..d3bbe686cc 100644
--- a/openstack_dashboard/dashboards/project/volumes/templates/volumes/snapshots/detail.html
+++ b/openstack_dashboard/dashboards/project/volumes/templates/volumes/snapshots/detail.html
@@ -2,9 +2,6 @@
{% load i18n %}
{% block title %}{% trans "Volume Snapshot Details" %}{% endblock %}
-{% block page_header %}
- {% include "horizon/common/_page_header.html" with title=page_title %}
-{% endblock page_header %}
{% block main %}
diff --git a/openstack_dashboard/dashboards/project/volumes/templates/volumes/volumes/detail.html b/openstack_dashboard/dashboards/project/volumes/templates/volumes/volumes/detail.html
index 6c6687990c..18cf6ccda5 100644
--- a/openstack_dashboard/dashboards/project/volumes/templates/volumes/volumes/detail.html
+++ b/openstack_dashboard/dashboards/project/volumes/templates/volumes/volumes/detail.html
@@ -2,10 +2,6 @@
{% load i18n %}
{% block title %}{% trans "Volume Details" %}{% endblock %}
-{% block page_header %}
- {% include "horizon/common/_page_header.html" with title=page_title %}
-{% endblock page_header %}
-
{% block main %}
diff --git a/openstack_dashboard/dashboards/project/volumes/volumes/views.py b/openstack_dashboard/dashboards/project/volumes/volumes/views.py
index 7ee8647dd5..03d622951e 100644
--- a/openstack_dashboard/dashboards/project/volumes/volumes/views.py
+++ b/openstack_dashboard/dashboards/project/volumes/volumes/views.py
@@ -43,6 +43,7 @@ from openstack_dashboard.dashboards.project.volumes \
class DetailView(tabs.TabView):
tab_group_class = project_tabs.VolumeDetailTabs
template_name = 'project/volumes/volumes/detail.html'
+ page_title = _("Volume Details: {{ volume.name }}")
def get_context_data(self, **kwargs):
context = super(DetailView, self).get_context_data(**kwargs)
@@ -51,10 +52,6 @@ class DetailView(tabs.TabView):
context["volume"] = volume
context["url"] = self.get_redirect_url()
context["actions"] = table.render_row_actions(volume)
- context["page_title"] = _("Volume Details: "
- "%(volume_name)s") % {'volume_name':
- volume.name}
-
return context
@memoized.memoized_method
diff --git a/openstack_dashboard/usage/views.py b/openstack_dashboard/usage/views.py
index 5224b818e0..0afa926de9 100644
--- a/openstack_dashboard/usage/views.py
+++ b/openstack_dashboard/usage/views.py
@@ -22,6 +22,7 @@ class UsageView(tables.DataTableView):
usage_class = None
show_terminated = True
csv_template_name = None
+ page_title = _("Overview")
def __init__(self, *args, **kwargs):
super(UsageView, self).__init__(*args, **kwargs)
@@ -72,6 +73,7 @@ class UsageView(tables.DataTableView):
response_kwargs.setdefault("filename", "usage.csv")
else:
render_class = self.response_class
+ context = self.render_title(context)
resp = render_class(request=self.request,
template=self.get_template_names(),
context=context,