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
6 years ago
by
BaiJiangJie
Committed by
老广
6 years ago
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Bufix] 修复用户更新时password_strategy字段不能为空的bug (#2741)
parent
aa25b774
master
auditor_jym
audits
dev
dev_beta
dev_beta_db
gengmei
node_service
v52
wph
1.5.2
1.5.1
1.5.0
No related merge requests found
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):
...
@@ -21,13 +21,7 @@ class UserCheckOtpCodeForm(forms.Form):
otp_code
=
forms
.
CharField
(
label
=
_
(
'MFA code'
),
max_length
=
6
)
otp_code
=
forms
.
CharField
(
label
=
_
(
'MFA code'
),
max_length
=
6
)
class
UserCreateUpdateForm
(
OrgModelForm
):
class
UserCreateUpdateFormMixin
(
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
)
)
role_choices
=
((
i
,
n
)
for
i
,
n
in
User
.
ROLE_CHOICES
if
i
!=
User
.
ROLE_APP
)
role_choices
=
((
i
,
n
)
for
i
,
n
in
User
.
ROLE_CHOICES
if
i
!=
User
.
ROLE_APP
)
password
=
forms
.
CharField
(
password
=
forms
.
CharField
(
label
=
_
(
'Password'
),
widget
=
forms
.
PasswordInput
,
label
=
_
(
'Password'
),
widget
=
forms
.
PasswordInput
,
...
@@ -42,10 +36,6 @@ class UserCreateUpdateForm(OrgModelForm):
...
@@ -42,10 +36,6 @@ class UserCreateUpdateForm(OrgModelForm):
widget
=
forms
.
Textarea
(
attrs
=
{
'placeholder'
:
_
(
'ssh-rsa AAAA...'
)}),
widget
=
forms
.
Textarea
(
attrs
=
{
'placeholder'
:
_
(
'ssh-rsa AAAA...'
)}),
help_text
=
_
(
'Paste user id_rsa.pub here.'
)
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
:
class
Meta
:
model
=
User
model
=
User
...
@@ -65,7 +55,7 @@ class UserCreateUpdateForm(OrgModelForm):
...
@@ -65,7 +55,7 @@ class UserCreateUpdateForm(OrgModelForm):
def
__init__
(
self
,
*
args
,
**
kwargs
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
self
.
request
=
kwargs
.
pop
(
"request"
,
None
)
self
.
request
=
kwargs
.
pop
(
"request"
,
None
)
super
(
UserCreateUpdateForm
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
super
(
UserCreateUpdateForm
Mixin
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
roles
=
[]
roles
=
[]
# Super admin user
# Super admin user
...
@@ -115,6 +105,23 @@ class UserCreateUpdateForm(OrgModelForm):
...
@@ -115,6 +105,23 @@ class UserCreateUpdateForm(OrgModelForm):
return
user
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
):
class
UserProfileForm
(
forms
.
ModelForm
):
username
=
forms
.
CharField
(
disabled
=
True
)
username
=
forms
.
CharField
(
disabled
=
True
)
name
=
forms
.
CharField
(
disabled
=
True
)
name
=
forms
.
CharField
(
disabled
=
True
)
...
...
This diff is collapsed.
Click to expand it.
apps/users/views/user.py
View file @
059a8de4
...
@@ -75,7 +75,7 @@ class UserListView(AdminUserRequiredMixin, TemplateView):
...
@@ -75,7 +75,7 @@ class UserListView(AdminUserRequiredMixin, TemplateView):
class
UserCreateView
(
AdminUserRequiredMixin
,
SuccessMessageMixin
,
CreateView
):
class
UserCreateView
(
AdminUserRequiredMixin
,
SuccessMessageMixin
,
CreateView
):
model
=
User
model
=
User
form_class
=
forms
.
UserCreate
Update
Form
form_class
=
forms
.
UserCreateForm
template_name
=
'users/user_create.html'
template_name
=
'users/user_create.html'
success_url
=
reverse_lazy
(
'users:user-list'
)
success_url
=
reverse_lazy
(
'users:user-list'
)
success_message
=
create_success_msg
success_message
=
create_success_msg
...
@@ -108,7 +108,7 @@ class UserCreateView(AdminUserRequiredMixin, SuccessMessageMixin, CreateView):
...
@@ -108,7 +108,7 @@ class UserCreateView(AdminUserRequiredMixin, SuccessMessageMixin, CreateView):
class
UserUpdateView
(
AdminUserRequiredMixin
,
SuccessMessageMixin
,
UpdateView
):
class
UserUpdateView
(
AdminUserRequiredMixin
,
SuccessMessageMixin
,
UpdateView
):
model
=
User
model
=
User
form_class
=
forms
.
User
Create
UpdateForm
form_class
=
forms
.
UserUpdateForm
template_name
=
'users/user_update.html'
template_name
=
'users/user_update.html'
context_object_name
=
'user_object'
context_object_name
=
'user_object'
success_url
=
reverse_lazy
(
'users:user-list'
)
success_url
=
reverse_lazy
(
'users:user-list'
)
...
...
This diff is collapsed.
Click to expand it.
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