Disallow editing roles not associated with a plan

Change-Id: I4fb6b2476e9aef163cc3f21e6387d47259336d25
Closes-bug: #1373837
This commit is contained in:
Ana Krivokapic 2014-09-29 17:04:07 +02:00
parent 427262ed68
commit 0cae0d1bae
2 changed files with 12 additions and 9 deletions

View File

@ -16,6 +16,7 @@ from django.utils.translation import ugettext_lazy as _
from horizon import tables
from tuskar_ui import api
from tuskar_ui.infrastructure.nodes import tables as nodes_tables
@ -26,6 +27,13 @@ class UpdateRole(tables.LinkAction):
classes = ("ajax-modal",)
icon = "pencil"
def allowed(self, request, datum):
plan = api.tuskar.Plan.get_the_plan(request)
if datum.id in [role.id for role in plan.role_list]:
return True
return False
class RolesTable(tables.DataTable):

View File

@ -165,15 +165,10 @@ class UpdateView(workflows.WorkflowView):
redirect=reverse_lazy(INDEX_URL))
role_flavor = role.flavor(plan)
if role_flavor is None:
role_flavor = ''
else:
role_flavor = role_flavor.name
try:
role_image = role.image(plan).id
except glance_exc.HTTPNotFound:
# Glance returns a 404 if the image doesn't exist
role_image = ''
role_flavor = '' if role_flavor is None else role_flavor.name
role_image = role.image(plan)
role_image = '' if role_image is None else role_image.id
return {'role_id': role.id,
'name': role.name,