Added 'enabled' option in create user form
In create user form, no way to set the user is disabled. by default it is setting the user as enabled. This patch adding the Boolean field to set enable and disable the user at the time creating. Change-Id: If4bf8ef077326658d4693858144904c7a93f1eb5 Closes-Bug: #1468208
This commit is contained in:
parent
dd694cdef3
commit
3d9372a8c5
@ -106,6 +106,9 @@ class CreateUserForm(PasswordMixin, BaseUserForm):
|
|||||||
add_item_link=ADD_PROJECT_URL)
|
add_item_link=ADD_PROJECT_URL)
|
||||||
role_id = forms.ChoiceField(label=_("Role"),
|
role_id = forms.ChoiceField(label=_("Role"),
|
||||||
required=PROJECT_REQUIRED)
|
required=PROJECT_REQUIRED)
|
||||||
|
enabled = forms.BooleanField(label=_("Enabled"),
|
||||||
|
required=False,
|
||||||
|
initial=True)
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
roles = kwargs.pop('roles')
|
roles = kwargs.pop('roles')
|
||||||
@ -113,7 +116,8 @@ class CreateUserForm(PasswordMixin, BaseUserForm):
|
|||||||
# Reorder form fields from multiple inheritance
|
# Reorder form fields from multiple inheritance
|
||||||
ordering = ["domain_id", "domain_name", "name",
|
ordering = ["domain_id", "domain_name", "name",
|
||||||
"description", "email", "password",
|
"description", "email", "password",
|
||||||
"confirm_password", "project", "role_id"]
|
"confirm_password", "project", "role_id",
|
||||||
|
"enabled"]
|
||||||
# Starting from 1.7 Django uses OrderedDict for fields and keyOrder
|
# Starting from 1.7 Django uses OrderedDict for fields and keyOrder
|
||||||
# no longer works for it
|
# no longer works for it
|
||||||
if django.VERSION >= (1, 7):
|
if django.VERSION >= (1, 7):
|
||||||
@ -149,7 +153,7 @@ class CreateUserForm(PasswordMixin, BaseUserForm):
|
|||||||
description=desc,
|
description=desc,
|
||||||
password=data['password'],
|
password=data['password'],
|
||||||
project=data['project'],
|
project=data['project'],
|
||||||
enabled=True,
|
enabled=data['enabled'],
|
||||||
domain=domain.id)
|
domain=domain.id)
|
||||||
messages.success(request,
|
messages.success(request,
|
||||||
_('User "%s" was successfully created.')
|
_('User "%s" was successfully created.')
|
||||||
|
@ -120,6 +120,7 @@ class UsersViewTests(test.BaseAdminViewTests):
|
|||||||
'password': user.password,
|
'password': user.password,
|
||||||
'project': self.tenant.id,
|
'project': self.tenant.id,
|
||||||
'role_id': self.roles.first().id,
|
'role_id': self.roles.first().id,
|
||||||
|
'enabled': True,
|
||||||
'confirm_password': user.password}
|
'confirm_password': user.password}
|
||||||
res = self.client.post(USER_CREATE_URL, formData)
|
res = self.client.post(USER_CREATE_URL, formData)
|
||||||
|
|
||||||
@ -170,6 +171,7 @@ class UsersViewTests(test.BaseAdminViewTests):
|
|||||||
'name': user.name,
|
'name': user.name,
|
||||||
'description': user.description,
|
'description': user.description,
|
||||||
'email': "",
|
'email': "",
|
||||||
|
'enabled': True,
|
||||||
'password': user.password,
|
'password': user.password,
|
||||||
'project': self.tenant.id,
|
'project': self.tenant.id,
|
||||||
'role_id': self.roles.first().id,
|
'role_id': self.roles.first().id,
|
||||||
|
Loading…
Reference in New Issue
Block a user