Reduce page title duplication in Identity views

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

Change-Id: I2f240a8b6a0ac76078a930bdf760e1cbab21e0cc
Partial-Bug: 1413749
This commit is contained in:
Sam Betts 2015-02-10 13:33:56 +00:00
parent 8d49a2eeb2
commit 7365c0c88e
18 changed files with 20 additions and 45 deletions

View File

@ -3,7 +3,7 @@
{% block title %}{% trans "Domains" %}{% endblock %}
{% block page_header %}
{% include "horizon/common/_domain_page_header.html" with title=_("Domains") %}
{% include "horizon/common/_domain_page_header.html" with title=page_title %}
{% endblock page_header %}
{% block main %}

View File

@ -33,6 +33,7 @@ from openstack_dashboard.dashboards.identity.domains \
class IndexView(tables.DataTableView):
table_class = project_tables.DomainsTable
template_name = constants.DOMAINS_INDEX_VIEW_TEMPLATE
page_title = _("Domains")
def get_data(self):
domains = []

View File

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

View File

@ -3,7 +3,7 @@
{% block title %}{% trans "Groups" %}{% endblock %}
{% block page_header %}
{% include "horizon/common/_domain_page_header.html" with title=_("Groups") %}
{% include "horizon/common/_domain_page_header.html" with title=page_title %}
{% endblock page_header %}
{% block main %}

View File

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

View File

@ -35,6 +35,7 @@ from openstack_dashboard.dashboards.identity.groups \
class IndexView(tables.DataTableView):
table_class = project_tables.GroupsTable
template_name = constants.GROUPS_INDEX_VIEW_TEMPLATE
page_title = _("Groups")
def get_data(self):
groups = []
@ -61,6 +62,7 @@ class CreateView(forms.ModalFormView):
submit_url = "horizon:identity:groups:create"
submit_label = _("Create Group")
success_url = reverse_lazy(constants.GROUPS_INDEX_URL)
page_title = _("Create Group")
class UpdateView(forms.ModalFormView):
@ -71,6 +73,7 @@ class UpdateView(forms.ModalFormView):
submit_url = "horizon:identity:groups:update"
submit_label = _("Update Group")
success_url = reverse_lazy(constants.GROUPS_INDEX_URL)
page_title = _("Update Group")
@memoized.memoized_method
def get_object(self):

View File

@ -3,7 +3,7 @@
{% block title %}{% trans "Projects" %}{% endblock %}
{% block page_header %}
{% include "horizon/common/_domain_page_header.html" with title=_("Projects") %}
{% include "horizon/common/_domain_page_header.html" with title=page_title %}
{% endblock page_header %}
{% block main %}

View File

@ -3,7 +3,7 @@
{% block title %}{% trans "Project Usage Overview" %}{% endblock %}
{% block page_header %}
{% include "horizon/common/_domain_page_header.html" with title=_("Project Usage") %}
{% include "horizon/common/_domain_page_header.html" with title=page_title %}
{% endblock %}
{% block main %}

View File

@ -68,6 +68,7 @@ class TenantContextMixin(object):
class IndexView(tables.DataTableView):
table_class = project_tables.TenantsTable
template_name = 'identity/projects/index.html'
page_title = _("Projects")
def has_more_data(self, table):
return self._more
@ -116,6 +117,7 @@ class ProjectUsageView(usage.UsageView):
template_name = 'identity/projects/usage.html'
csv_response_class = project_views.ProjectUsageCsvRenderer
csv_template_name = 'project/overview/usage.csv'
page_title = _("Project Usage")
def get_data(self):
super(ProjectUsageView, self).get_data()

View File

@ -2,11 +2,6 @@
{% load i18n %}
{% block title %}{% trans "Create Role" %}{% endblock %}
{% block page_header %}
{# to make searchable false, just remove it from the include statement #}
{% include "horizon/common/_page_header.html" with title=_("Create Role") %}
{% endblock page_header %}
{% block main %}
{% include 'identity/roles/_create.html' %}
{% endblock %}

View File

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

View File

@ -2,11 +2,6 @@
{% load i18n %}
{% block title %}{% trans "Update Role" %}{% endblock %}
{% block page_header %}
{# to make searchable false, just remove it from the include statement #}
{% include "horizon/common/_page_header.html" with title=_("Update Role") %}
{% endblock page_header %}
{% block main %}
{% include 'identity/roles/_update.html' %}
{% endblock %}

View File

@ -34,6 +34,7 @@ from openstack_dashboard.dashboards.identity.roles \
class IndexView(tables.DataTableView):
table_class = project_tables.RolesTable
template_name = 'identity/roles/index.html'
page_title = _("Roles")
def get_data(self):
roles = []
@ -58,6 +59,7 @@ class UpdateView(forms.ModalFormView):
submit_label = _("Update Role")
submit_url = "horizon:identity:roles:update"
success_url = reverse_lazy('horizon:identity:roles:index')
page_title = _("Update Role")
@memoized.memoized_method
def get_object(self):
@ -89,3 +91,4 @@ class CreateView(forms.ModalFormView):
submit_label = _("Create Role")
submit_url = reverse_lazy("horizon:identity:roles:create")
success_url = reverse_lazy('horizon:identity:roles:index')
page_title = _("Create Role")

View File

@ -2,11 +2,6 @@
{% load i18n %}
{% block title %}{% trans "Create User" %}{% endblock %}
{% block page_header %}
{# to make searchable false, just remove it from the include statement #}
{% include "horizon/common/_page_header.html" with title=_("Create User") %}
{% endblock page_header %}
{% block main %}
{% include 'identity/users/_create.html' %}
{% endblock %}

View File

@ -2,10 +2,6 @@
{% load i18n %}
{% block title %}{% trans "User Details" %}{% endblock %}
{% block page_header %}
{% include "horizon/common/_page_header.html" with title=page_title %}
{% endblock page_header %}
{% block main %}
<div class="row">
<div class="col-sm-12">
@ -13,4 +9,3 @@
</div>
</div>
{% endblock %}

View File

@ -3,7 +3,7 @@
{% block title %}{% trans "Users" %}{% endblock %}
{% block page_header %}
{% include "horizon/common/_domain_page_header.html" with title=_("Users") %}
{% include "horizon/common/_domain_page_header.html" with title=page_title %}
{% endblock page_header %}
{% block main %}

View File

@ -2,11 +2,6 @@
{% load i18n %}
{% block title %}{% trans "Update User" %}{% endblock %}
{% block page_header %}
{# to make searchable false, just remove it from the include statement #}
{% include "horizon/common/_page_header.html" with title=_("Update User") %}
{% endblock page_header %}
{% block main %}
{% include 'identity/users/_update.html' %}
{% endblock %}

View File

@ -23,13 +23,13 @@ from django.core.urlresolvers import reverse_lazy
from django.utils.decorators import method_decorator # noqa
from django.utils.translation import ugettext_lazy as _
from django.views.decorators.debug import sensitive_post_parameters # noqa
from django.views import generic
from horizon import exceptions
from horizon import forms
from horizon import messages
from horizon import tables
from horizon.utils import memoized
from horizon import views
from openstack_dashboard import api
from openstack_dashboard import policy
@ -43,6 +43,7 @@ from openstack_dashboard.dashboards.identity.users \
class IndexView(tables.DataTableView):
table_class = project_tables.UsersTable
template_name = 'identity/users/index.html'
page_title = _("Users")
def get_data(self):
users = []
@ -78,6 +79,7 @@ class UpdateView(forms.ModalFormView):
submit_label = _("Update User")
submit_url = "horizon:identity:users:update"
success_url = reverse_lazy('horizon:identity:users:index')
page_title = _("Update User")
@method_decorator(sensitive_post_parameters('password',
'confirm_password'))
@ -131,6 +133,7 @@ class CreateView(forms.ModalFormView):
submit_label = _("Create User")
submit_url = reverse_lazy("horizon:identity:users:create")
success_url = reverse_lazy('horizon:identity:users:index')
page_title = _("Create User")
@method_decorator(sensitive_post_parameters('password',
'confirm_password'))
@ -159,8 +162,9 @@ class CreateView(forms.ModalFormView):
'role_id': getattr(default_role, "id", None)}
class DetailView(generic.TemplateView):
class DetailView(views.HorizonTemplateView):
template_name = 'identity/users/detail.html'
page_title = _("User Details: {{ user.name }}")
def get_context_data(self, **kwargs):
context = super(DetailView, self).get_context_data(**kwargs)
@ -179,7 +183,6 @@ class DetailView(generic.TemplateView):
context["user"] = user
context["domain_id"] = domain_id
context["domain_name"] = domain_name
context["page_title"] = _("User Details: %s") % user.name
context["url"] = self.get_redirect_url()
context["actions"] = table.render_row_actions(user)
return context