Create a "Identity Projects details" page
This patch add the detail page for the "Projects" (Identity -> Projects) table/resource. So when user clicks on the project name, it will show the drill down details to the end user. Change-Id: I00589f139570758f5645e7862de36487ca844b34 Closes-bug: #1380600
This commit is contained in:
parent
58362e2297
commit
104f652f34
@ -223,6 +223,7 @@ class UpdateCell(tables.UpdateAction):
|
||||
|
||||
class TenantsTable(tables.DataTable):
|
||||
name = tables.Column('name', verbose_name=_('Name'),
|
||||
link=("horizon:identity:projects:detail"),
|
||||
form_field=forms.CharField(max_length=64),
|
||||
update_action=UpdateCell)
|
||||
description = tables.Column(lambda obj: getattr(obj, 'description', None),
|
||||
|
@ -0,0 +1,19 @@
|
||||
{% load i18n %}
|
||||
|
||||
<h3>{% trans "Project Overview" %}</h3>
|
||||
|
||||
<div class="info detail">
|
||||
<h4>{% trans "Information" %}</h4>
|
||||
<hr class="header_rule">
|
||||
<dl class="dl-horizontal">
|
||||
<dt>{% trans "Project Name" %}</dt>
|
||||
<dd>{{ project.name }}</dd>
|
||||
<dt>{% trans "Project ID" %}</dt>
|
||||
<dd>{{ project.id }}</dd>
|
||||
<dt>{% trans "Enabled" %}</dt>
|
||||
<dd>{{ project.enabled }}</dd>
|
||||
<dt>{% trans "Description" %}</dt>
|
||||
<dd>{{ project.description|default:_("None") }}</dd>
|
||||
</dl>
|
||||
</div>
|
||||
|
@ -0,0 +1,16 @@
|
||||
{% extends 'base.html' %}
|
||||
{% load i18n %}
|
||||
{% block title %}{% trans "Project 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">
|
||||
{% include "identity/projects/_detail_overview.html" %}
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
@ -46,6 +46,7 @@ from socket import timeout as socket_timeout # noqa
|
||||
INDEX_URL = reverse('horizon:identity:projects:index')
|
||||
USER_ROLE_PREFIX = workflows.PROJECT_GROUP_MEMBER_SLUG + "_role_"
|
||||
GROUP_ROLE_PREFIX = workflows.PROJECT_USER_MEMBER_SLUG + "_role_"
|
||||
PROJECT_DETAIL_URL = reverse('horizon:identity:projects:detail', args=[1])
|
||||
|
||||
|
||||
class TenantsViewTests(test.BaseAdminViewTests):
|
||||
@ -1639,6 +1640,36 @@ class UsageViewTests(test.BaseAdminViewTests):
|
||||
self.assertContains(res, '%s\r\n' % hdr)
|
||||
|
||||
|
||||
class DetailProjectViewTests(test.BaseAdminViewTests):
|
||||
@test.create_stubs({api.keystone: ('tenant_get',)})
|
||||
def test_detail_view(self):
|
||||
project = self.tenants.first()
|
||||
|
||||
api.keystone.tenant_get(IsA(http.HttpRequest), self.tenant.id) \
|
||||
.AndReturn(project)
|
||||
self.mox.ReplayAll()
|
||||
|
||||
res = self.client.get(PROJECT_DETAIL_URL, args=[project.id])
|
||||
|
||||
self.assertTemplateUsed(res, 'identity/projects/detail.html')
|
||||
self.assertEqual(res.context['project'].name, project.name)
|
||||
self.assertEqual(res.context['project'].id, project.id)
|
||||
self.assertContains(res, "Project Details: %s" % project.name,
|
||||
1, 200)
|
||||
|
||||
@test.create_stubs({api.keystone: ('tenant_get',)})
|
||||
def test_detail_view_with_exception(self):
|
||||
project = self.tenants.first()
|
||||
|
||||
api.keystone.tenant_get(IsA(http.HttpRequest), self.tenant.id) \
|
||||
.AndRaise(self.exceptions.keystone)
|
||||
self.mox.ReplayAll()
|
||||
|
||||
res = self.client.get(PROJECT_DETAIL_URL, args=[project.id])
|
||||
|
||||
self.assertRedirectsNoFollow(res, INDEX_URL)
|
||||
|
||||
|
||||
@unittest.skipUnless(os.environ.get('WITH_SELENIUM', False),
|
||||
"The WITH_SELENIUM env variable is not set.")
|
||||
class SeleniumTests(test.SeleniumAdminTestCase):
|
||||
|
@ -30,4 +30,6 @@ urlpatterns = patterns(
|
||||
views.UpdateProjectView.as_view(), name='update'),
|
||||
url(r'^(?P<project_id>[^/]+)/usage/$',
|
||||
views.ProjectUsageView.as_view(), name='usage'),
|
||||
url(r'^(?P<project_id>[^/]+)/detail/$',
|
||||
views.DetailProjectView.as_view(), name='detail'),
|
||||
)
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.views import generic
|
||||
|
||||
from horizon import exceptions
|
||||
from horizon import messages
|
||||
@ -203,3 +204,28 @@ class UpdateProjectView(workflows.WorkflowView):
|
||||
_('Unable to retrieve project details.'),
|
||||
redirect=reverse(INDEX_URL))
|
||||
return initial
|
||||
|
||||
|
||||
class DetailProjectView(generic.TemplateView):
|
||||
template_name = 'identity/projects/detail.html'
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(DetailProjectView, self).get_context_data(**kwargs)
|
||||
project = self.get_data()
|
||||
table = project_tables.TenantsTable(self.request)
|
||||
context["project"] = project
|
||||
context["page_title"] = _("Project Details: %s") % project.name
|
||||
context["url"] = reverse(INDEX_URL)
|
||||
context["actions"] = table.render_row_actions(project)
|
||||
return context
|
||||
|
||||
@memoized.memoized_method
|
||||
def get_data(self):
|
||||
try:
|
||||
project_id = self.kwargs['project_id']
|
||||
project = api.keystone.tenant_get(self.request, project_id)
|
||||
except Exception:
|
||||
exceptions.handle(self.request,
|
||||
_('Unable to retrieve project details.'),
|
||||
redirect=reverse(INDEX_URL))
|
||||
return project
|
||||
|
Loading…
Reference in New Issue
Block a user