Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
J
jumpserver
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ops
jumpserver
Commits
059a8de4
Commit
059a8de4
authored
May 28, 2019
by
BaiJiangJie
Committed by
老广
May 28, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Bufix] 修复用户更新时password_strategy字段不能为空的bug (#2741)
parent
aa25b774
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
14 deletions
+21
-14
forms.py
apps/users/forms.py
+19
-12
user.py
apps/users/views/user.py
+2
-2
No files found.
apps/users/forms.py
View file @
059a8de4
...
...
@@ -21,13 +21,7 @@ class UserCheckOtpCodeForm(forms.Form):
otp_code
=
forms
.
CharField
(
label
=
_
(
'MFA code'
),
max_length
=
6
)
class
UserCreateUpdateForm
(
OrgModelForm
):
EMAIL_SET_PASSWORD
=
_
(
'Reset link will be generated and sent to the user'
)
CUSTOM_PASSWORD
=
_
(
'Set password'
)
PASSWORD_STRATEGY_CHOICES
=
(
(
0
,
EMAIL_SET_PASSWORD
),
(
1
,
CUSTOM_PASSWORD
)
)
class
UserCreateUpdateFormMixin
(
OrgModelForm
):
role_choices
=
((
i
,
n
)
for
i
,
n
in
User
.
ROLE_CHOICES
if
i
!=
User
.
ROLE_APP
)
password
=
forms
.
CharField
(
label
=
_
(
'Password'
),
widget
=
forms
.
PasswordInput
,
...
...
@@ -42,10 +36,6 @@ class UserCreateUpdateForm(OrgModelForm):
widget
=
forms
.
Textarea
(
attrs
=
{
'placeholder'
:
_
(
'ssh-rsa AAAA...'
)}),
help_text
=
_
(
'Paste user id_rsa.pub here.'
)
)
password_strategy
=
forms
.
ChoiceField
(
choices
=
PASSWORD_STRATEGY_CHOICES
,
required
=
True
,
initial
=
0
,
widget
=
forms
.
RadioSelect
(),
label
=
_
(
'Password strategy'
)
)
class
Meta
:
model
=
User
...
...
@@ -65,7 +55,7 @@ class UserCreateUpdateForm(OrgModelForm):
def
__init__
(
self
,
*
args
,
**
kwargs
):
self
.
request
=
kwargs
.
pop
(
"request"
,
None
)
super
(
UserCreateUpdateForm
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
super
(
UserCreateUpdateForm
Mixin
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
roles
=
[]
# Super admin user
...
...
@@ -115,6 +105,23 @@ class UserCreateUpdateForm(OrgModelForm):
return
user
class
UserCreateForm
(
UserCreateUpdateFormMixin
):
EMAIL_SET_PASSWORD
=
_
(
'Reset link will be generated and sent to the user'
)
CUSTOM_PASSWORD
=
_
(
'Set password'
)
PASSWORD_STRATEGY_CHOICES
=
(
(
0
,
EMAIL_SET_PASSWORD
),
(
1
,
CUSTOM_PASSWORD
)
)
password_strategy
=
forms
.
ChoiceField
(
choices
=
PASSWORD_STRATEGY_CHOICES
,
required
=
True
,
initial
=
0
,
widget
=
forms
.
RadioSelect
(),
label
=
_
(
'Password strategy'
)
)
class
UserUpdateForm
(
UserCreateUpdateFormMixin
):
pass
class
UserProfileForm
(
forms
.
ModelForm
):
username
=
forms
.
CharField
(
disabled
=
True
)
name
=
forms
.
CharField
(
disabled
=
True
)
...
...
apps/users/views/user.py
View file @
059a8de4
...
...
@@ -75,7 +75,7 @@ class UserListView(AdminUserRequiredMixin, TemplateView):
class
UserCreateView
(
AdminUserRequiredMixin
,
SuccessMessageMixin
,
CreateView
):
model
=
User
form_class
=
forms
.
UserCreate
Update
Form
form_class
=
forms
.
UserCreateForm
template_name
=
'users/user_create.html'
success_url
=
reverse_lazy
(
'users:user-list'
)
success_message
=
create_success_msg
...
...
@@ -108,7 +108,7 @@ class UserCreateView(AdminUserRequiredMixin, SuccessMessageMixin, CreateView):
class
UserUpdateView
(
AdminUserRequiredMixin
,
SuccessMessageMixin
,
UpdateView
):
model
=
User
form_class
=
forms
.
User
Create
UpdateForm
form_class
=
forms
.
UserUpdateForm
template_name
=
'users/user_update.html'
context_object_name
=
'user_object'
success_url
=
reverse_lazy
(
'users:user-list'
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment