Merge "Prevent user from disabling her current project"
This commit is contained in:
commit
b4735c6ce6
|
@ -189,9 +189,12 @@ class UpdateRow(tables.Row):
|
|||
|
||||
class UpdateCell(tables.UpdateAction):
|
||||
def allowed(self, request, project, cell):
|
||||
return api.keystone.keystone_can_edit_project() and \
|
||||
policy.check((("identity", "identity:update_project"),),
|
||||
request)
|
||||
policy_rule = (("identity", "identity:update_project"),)
|
||||
return (
|
||||
(cell.column.name != 'enabled' or
|
||||
request.user.token.project['id'] != cell.datum.id) and
|
||||
api.keystone.keystone_can_edit_project() and
|
||||
policy.check(policy_rule, request))
|
||||
|
||||
def update_cell(self, request, datum, project_id,
|
||||
cell_name, new_cell_value):
|
||||
|
|
|
@ -521,6 +521,14 @@ class CreateProject(workflows.Workflow):
|
|||
class UpdateProjectInfoAction(CreateProjectInfoAction):
|
||||
enabled = forms.BooleanField(required=False, label=_("Enabled"))
|
||||
|
||||
def __init__(self, request, initial, *args, **kwargs):
|
||||
super(UpdateProjectInfoAction, self).__init__(
|
||||
request, initial, *args, **kwargs)
|
||||
if initial['project_id'] == request.user.token.project['id']:
|
||||
self.fields['enabled'].widget.attrs['disabled'] = True
|
||||
self.fields['enabled'].help_text = _(
|
||||
'You cannot disable your current project')
|
||||
|
||||
class Meta:
|
||||
name = _("Project Information")
|
||||
slug = 'update_info'
|
||||
|
|
Loading…
Reference in New Issue