Merge "Add policy check for project detail link"

This commit is contained in:
Jenkins 2015-11-18 21:33:36 +00:00 committed by Gerrit Code Review
commit be260e88c0

View File

@ -241,6 +241,23 @@ class TenantsTable(tables.DataTable):
required=False), required=False),
update_action=UpdateCell) update_action=UpdateCell)
def get_project_detail_link(self, project):
# this method is an ugly monkey patch, needed because
# the column link method does not provide access to the request
if policy.check((("identity", "identity:get_project"),),
self.request, target={"project": project}):
return reverse("horizon:identity:projects:detail",
args=(project.id,))
return None
def __init__(self, request, data=None, needs_form_wrapper=None, **kwargs):
super(TenantsTable,
self).__init__(request, data=data,
needs_form_wrapper=needs_form_wrapper,
**kwargs)
# see the comment above about ugly monkey patches
self.columns['name'].get_link_url = self.get_project_detail_link
class Meta(object): class Meta(object):
name = "tenants" name = "tenants"
verbose_name = _("Projects") verbose_name = _("Projects")