Removed "Disable user" from dropdown menu for self
Previously the "Disable user" option was disabled for the logged in user, it was displayed but not clickable. This has been changed to no longer display at all. Change-Id: I3114e1191915717638ec57ccf444872fb2a39dd2 Closes-Bug: 1567393
This commit is contained in:
parent
fbfc638de6
commit
e390773260
@ -108,7 +108,8 @@ class ToggleEnabled(policy.PolicyTargetMixin, tables.BatchAction):
|
||||
("target.user.domain_id", "domain_id"))
|
||||
|
||||
def allowed(self, request, user=None):
|
||||
if not api.keystone.keystone_can_edit_user():
|
||||
if (not api.keystone.keystone_can_edit_user() or
|
||||
user.id == request.user.id):
|
||||
return False
|
||||
|
||||
self.enabled = True
|
||||
@ -121,16 +122,7 @@ class ToggleEnabled(policy.PolicyTargetMixin, tables.BatchAction):
|
||||
self.current_present_action = ENABLE
|
||||
return True
|
||||
|
||||
def update(self, request, user=None):
|
||||
super(ToggleEnabled, self).update(request, user)
|
||||
if user and user.id == request.user.id:
|
||||
self.attrs["disabled"] = "disabled"
|
||||
|
||||
def action(self, request, obj_id):
|
||||
if obj_id == request.user.id:
|
||||
messages.info(request, _('You cannot disable the user you are '
|
||||
'currently logged in as.'))
|
||||
return
|
||||
if self.enabled:
|
||||
api.keystone.user_update_enabled(request, obj_id, False)
|
||||
self.current_past_action = DISABLE
|
||||
|
@ -727,8 +727,8 @@ class UsersViewTests(test.BaseAdminViewTests):
|
||||
res = self.client.post(USERS_INDEX_URL, formData, follow=True)
|
||||
|
||||
self.assertEqual(list(res.context['messages'])[0].message,
|
||||
u'You cannot disable the user you are currently '
|
||||
u'logged in as.')
|
||||
u'You are not allowed to disable user: '
|
||||
u'test_user')
|
||||
|
||||
@test.create_stubs({api.keystone: ('user_list', 'domain_lookup')})
|
||||
def test_disabling_current_user_domain_name(self):
|
||||
@ -752,8 +752,8 @@ class UsersViewTests(test.BaseAdminViewTests):
|
||||
res = self.client.post(USERS_INDEX_URL, formData, follow=True)
|
||||
|
||||
self.assertEqual(list(res.context['messages'])[0].message,
|
||||
u'You cannot disable the user you are currently '
|
||||
u'logged in as.')
|
||||
u'You are not allowed to disable user: '
|
||||
u'test_user')
|
||||
|
||||
@test.create_stubs({api.keystone: ('user_list', 'domain_lookup')})
|
||||
def test_delete_user_with_improper_permissions(self):
|
||||
|
Loading…
Reference in New Issue
Block a user