Reduce page title duplication in A and S 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 project access and security views.

Change-Id: I58f22a522bcd88b6905a5886427cc3fd7b1915f9
Partial-Bug: 1413749
This commit is contained in:
Sam Betts 2015-02-10 13:35:27 +00:00
parent 1934a7eaa8
commit b57a5db146
13 changed files with 18 additions and 43 deletions

View File

@ -21,11 +21,11 @@ from django import http
from django import shortcuts
from django.template.loader import render_to_string
from django.utils.translation import ugettext_lazy as _
from django.views import generic
from horizon import exceptions
from horizon import forms
from horizon import messages
from horizon import views
from openstack_dashboard import api
@ -133,8 +133,9 @@ def download_rc_file(request):
return shortcuts.redirect(request.build_absolute_uri())
class CredentialsView(forms.ModalFormMixin, generic.TemplateView):
class CredentialsView(forms.ModalFormMixin, views.HorizonTemplateView):
template_name = 'project/access_and_security/api_access/credentials.html'
page_title = _("User Credentials Details")
def get_context_data(self, **kwargs):
context = super(CredentialsView, self).get_context_data(**kwargs)

View File

@ -24,12 +24,12 @@ from django.core.urlresolvers import reverse_lazy
from django import http
from django.template.defaultfilters import slugify # noqa
from django.utils.translation import ugettext_lazy as _
from django.views.generic import TemplateView # noqa
from django.views.generic import View # noqa
from horizon import exceptions
from horizon import forms
from horizon.utils import memoized
from horizon import views
from openstack_dashboard import api
@ -41,6 +41,7 @@ class CreateView(forms.ModalFormView):
form_class = project_forms.CreateKeypair
template_name = 'project/access_and_security/keypairs/create.html'
success_url = 'horizon:project:access_and_security:keypairs:download'
page_title = _("Create Key Pair")
def get_success_url(self):
return reverse(self.success_url,
@ -51,13 +52,15 @@ class ImportView(forms.ModalFormView):
form_class = project_forms.ImportKeypair
template_name = 'project/access_and_security/keypairs/import.html'
success_url = reverse_lazy('horizon:project:access_and_security:index')
page_title = _("Import Key Pair")
def get_object_id(self, keypair):
return keypair.name
class DetailView(TemplateView):
class DetailView(views.HorizonTemplateView):
template_name = 'project/access_and_security/keypairs/detail.html'
page_title = _("Key Pair Details")
@memoized.memoized_method
def _get_data(self):
@ -75,15 +78,16 @@ class DetailView(TemplateView):
def get_context_data(self, **kwargs):
"""Gets the context data for keypair."""
context = super(DetailView, self).get_context_data(**kwargs)
context['page_title'] = _("Key Pair Details")
context['keypair'] = self._get_data()
return context
class DownloadView(TemplateView):
class DownloadView(views.HorizonTemplateView):
template_name = 'project/access_and_security/keypairs/download.html'
page_title = _("Download Key Pair")
def get_context_data(self, keypair_name=None):
return {'keypair_name': keypair_name}
template_name = 'project/access_and_security/keypairs/download.html'
class GenerateView(View):

View File

@ -71,6 +71,7 @@ class UpdateView(forms.ModalFormView):
form_class = project_forms.UpdateGroup
template_name = 'project/access_and_security/security_groups/update.html'
success_url = reverse_lazy('horizon:project:access_and_security:index')
page_title = _("Edit Security Group")
@memoized.memoized_method
def get_object(self):
@ -97,6 +98,7 @@ class UpdateView(forms.ModalFormView):
class AddRuleView(forms.ModalFormView):
form_class = project_forms.AddRule
template_name = 'project/access_and_security/security_groups/add_rule.html'
page_title = _("Add Rule")
def get_success_url(self):
sg_id = self.kwargs['security_group_id']
@ -137,3 +139,4 @@ class CreateView(forms.ModalFormView):
form_class = project_forms.CreateGroup
template_name = 'project/access_and_security/security_groups/create.html'
success_url = reverse_lazy('horizon:project:access_and_security:index')
page_title = _("Create Security Group")

View File

@ -2,10 +2,6 @@
{% load i18n %}
{% block title %}{% trans "User Credentials" %}{% endblock %}
{% block page_header %}
{% include "horizon/common/_page_header.html" with title=_("User Credentials Details") %}
{% endblock page_header %}
{% block main %}
{% include 'project/access_and_security/api_access/_credentials.html' %}
{% endblock %}

View File

@ -2,10 +2,6 @@
{% load i18n %}
{% block title %}{% trans "Access & Security" %}{% endblock %}
{% block page_header %}
{% include "horizon/common/_page_header.html" with title=_("Access & Security") %}
{% endblock page_header %}
{% block main %}
<div class="row">
<div class="col-sm-12">

View File

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

View File

@ -2,9 +2,6 @@
{% load i18n sizeformat %}
{% block title %}{% trans "Key Pair Details" %}{% endblock %}
{% block page_header %}
{% include "horizon/common/_page_header.html" with title=page_title %}
{% endblock page_header %}
{% block main %}
<div class="row-fluid">

View File

@ -3,10 +3,6 @@
{% load url from future %}
{% block title %}{% blocktrans %}Download Key Pair{% endblocktrans %}{% endblock %}
{% block page_header %}
{% include "horizon/common/_page_header.html" with title=_("Download Key Pair") %}
{% endblock page_header %}
{% block main %}
<div class="modal-header">
<h3>{% blocktrans %}The key pair &quot;{{ keypair_name }}&quot; should download automatically. If not use the link below.{% endblocktrans %}</h3>

View File

@ -2,11 +2,6 @@
{% load i18n %}
{% block title %}{% trans "Import Key Pair" %}{% endblock %}
{% block page_header %}
{% include "horizon/common/_page_header.html" with title=_("Import Key Pair") %}
{% endblock page_header %}
{% block main %}
{% include 'project/access_and_security/keypairs/_import.html' %}
{% endblock %}

View File

@ -2,10 +2,6 @@
{% load i18n %}
{% block title %}{% trans "Add Rule" %}{% endblock %}
{% block page_header %}
{% include "horizon/common/_page_header.html" with title=_("Add Rule") %}
{% endblock page_header %}
{% block main %}
{% include 'project/access_and_security/security_groups/_add_rule.html' %}
{% endblock %}

View File

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

View File

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

View File

@ -21,6 +21,8 @@
Views for Instances and Volumes.
"""
from django.utils.translation import ugettext_lazy as _
from horizon import tabs
from openstack_dashboard.dashboards.project.access_and_security \
@ -30,3 +32,4 @@ from openstack_dashboard.dashboards.project.access_and_security \
class IndexView(tabs.TabbedTableView):
tab_group_class = project_tabs.AccessAndSecurityTabs
template_name = 'project/access_and_security/index.html'
page_title = _("Access & Security")