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
067426d5
Commit
067426d5
authored
Mar 31, 2017
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Fixture] 完成用户向导页
parent
87eb1914
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
84 additions
and
22 deletions
+84
-22
views.py
apps/applications/views.py
+1
-0
utils.py
apps/common/utils.py
+1
-1
forms.py
apps/users/forms.py
+10
-10
first_login.html
apps/users/templates/users/first_login.html
+4
-4
first_login_done.html
apps/users/templates/users/first_login_done.html
+51
-0
login.py
apps/users/views/login.py
+14
-7
config_example.py
config_example.py
+3
-0
No files found.
apps/applications/views.py
View file @
067426d5
...
...
@@ -108,6 +108,7 @@ class TerminalConnectView(LoginRequiredMixin, DetailView):
'messages'
:
_
(
'You should use your ssh client tools '
'connect terminal: {} <br /> <br />'
'{}'
.
format
(
self
.
object
.
name
,
self
.
object
.
url
)),
'redirect_url'
:
reverse
(
'applications:terminal-list'
)
}
kwargs
.
update
(
context
)
...
...
apps/common/utils.py
View file @
067426d5
...
...
@@ -252,7 +252,7 @@ def validate_ssh_public_key(text):
ssh
=
sshpubkeys
.
SSHKey
(
text
)
try
:
ssh
.
parse
()
except
sshpubkeys
.
InvalidKeyException
:
except
(
sshpubkeys
.
InvalidKeyException
,
UnicodeDecodeError
)
:
return
False
except
NotImplementedError
as
e
:
return
False
...
...
apps/users/forms.py
View file @
067426d5
...
...
@@ -91,7 +91,10 @@ class UserPublicKeyForm(forms.Form):
help_text
=
_
(
'Paste your id_rsa.pub here.'
))
def
__init__
(
self
,
*
args
,
**
kwargs
):
self
.
instance
=
kwargs
.
pop
(
'instance'
)
if
'instance'
in
kwargs
:
self
.
instance
=
kwargs
.
pop
(
'instance'
)
else
:
self
.
instance
=
None
super
(
UserPublicKeyForm
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
def
clean_public_key
(
self
):
...
...
@@ -128,15 +131,12 @@ class UserGroupForm(forms.ModelForm):
}
class
UserInfoForm
(
forms
.
Form
):
name
=
forms
.
CharField
(
max_length
=
20
,
label
=
_
(
'name'
))
avatar
=
forms
.
ImageField
(
label
=
_
(
'avatar'
),
required
=
False
)
wechat
=
forms
.
CharField
(
max_length
=
30
,
label
=
_
(
'wechat'
),
required
=
False
)
phone
=
forms
.
CharField
(
max_length
=
20
,
label
=
_
(
'phone'
),
required
=
False
)
enable_otp
=
forms
.
BooleanField
(
required
=
False
,
label
=
_
(
'enable otp'
))
# class UserInfoForm(forms.Form):
# name = forms.CharField(max_length=20, label=_('name'))
# avatar = forms.ImageField(label=_('avatar'), required=False)
# wechat = forms.CharField(max_length=30, label=_('wechat'), required=False)
# phone = forms.CharField(max_length=20, label=_('phone'), required=False)
# enable_otp = forms.BooleanField(required=False, label=_('enable otp'))
class
UserPrivateAssetPermissionForm
(
forms
.
ModelForm
):
...
...
apps/users/templates/users/first_login.html
View file @
067426d5
...
...
@@ -34,7 +34,7 @@
aria-disabled=
"false"
aria-selected=
"true"
>
<a
href=
"javascript:void(0)"
><span
class=
"number"
>
{% trans 'Step' %} {{ step }}
</span></a>
</li>
{% endfor %}
{% endfor
>
%}
</ul>
</div>
<div
class=
"content clearfix"
>
...
...
@@ -54,10 +54,10 @@
<div
class=
"actions clearfix"
>
<ul>
{% if wizard.steps.prev %}
<li><a
class=
"fl_goto"
data-goto=
"{{ wizard.steps.first }}"
>
{% trans "
f
irst step" %}
</a></li>
<li><a
class=
"fl_goto"
name=
"wizard_goto_step"
data-goto=
"{{ wizard.steps.prev }}"
>
{% trans "
p
rev step" %}
</a></li>
<li><a
class=
"fl_goto"
data-goto=
"{{ wizard.steps.first }}"
>
{% trans "
F
irst step" %}
</a></li>
<li><a
class=
"fl_goto"
name=
"wizard_goto_step"
data-goto=
"{{ wizard.steps.prev }}"
>
{% trans "
P
rev step" %}
</a></li>
{% endif %}
<li><a
id=
"fl_submit"
>
{% trans "
s
ubmit" %}
</a></li>
<li><a
id=
"fl_submit"
>
{% trans "
S
ubmit" %}
</a></li>
</ul>
</div>
</div>
...
...
apps/users/templates/users/first_login_done.html
0 → 100644
View file @
067426d5
{% extends 'base.html' %}
{% load static %}
{% load i18n %}
{% load bootstrap %}
{% block custom_head_css_js %}
{{ wizard.form.media }}
<link
href=
"{% static 'css/plugins/steps/jquery.steps.css' %}"
rel=
"stylesheet"
>
{% endblock %}
{% block first_login_message %}{% endblock %}
{% block content %}
<div
class=
"wrapper wrapper-content animated fadeInRight"
>
<div
class=
"row"
>
<div
class=
"col-lg-12"
>
<div
class=
"ibox"
>
<div
class=
"ibox-title"
>
<h5>
{% trans 'First Login' %}
</h5>
<div
class=
"ibox-tools"
>
<a
class=
"collapse-link"
>
<i
class=
"fa fa-chevron-up"
></i>
</a>
<a
class=
"dropdown-toggle"
data-toggle=
"dropdown"
href=
"#"
>
<i
class=
"fa fa-wrench"
></i>
</a>
</div>
</div>
<div
class=
"ibox-content"
>
<div
class=
"alert alert-success"
id=
"messages"
>
{% trans 'Welcome to use jumpserver, visit ' %}
<a
href=
"{{ user_guide_url }}"
>
{% trans 'Use guide' %}
</a>
{% trans ' for more information' %}
</div>
</div>
</div>
</div>
</div>
</div>
{% endblock %}
{% block custom_foot_js %}
<script>
$
(
document
).
on
(
'click'
,
".fl_goto"
,
function
(){
var
$form
=
$
(
'#fl_form'
);
$
(
'<input />'
,
{
'name'
:
'wizard_goto_step'
,
'value'
:
$
(
this
).
data
(
'goto'
),
'type'
:
'hidden'
}).
appendTo
(
$form
);
$form
.
submit
();
return
false
;
}).
on
(
'click'
,
'#fl_submit'
,
function
(){
$
(
'#fl_form'
).
submit
();
return
false
;
})
</script>
{% endblock %}
apps/users/views/login.py
View file @
067426d5
...
...
@@ -2,6 +2,7 @@
from
__future__
import
unicode_literals
from
django
import
forms
from
django.shortcuts
import
render
from
django.contrib.auth
import
login
as
auth_login
,
logout
as
auth_logout
from
django.contrib.auth.mixins
import
LoginRequiredMixin
from
django.core.files.storage
import
default_storage
...
...
@@ -15,6 +16,7 @@ from django.views.decorators.debug import sensitive_post_parameters
from
django.views.generic.base
import
TemplateView
from
django.views.generic.edit
import
FormView
from
formtools.wizard.views
import
SessionWizardView
from
django.conf
import
settings
from
common.utils
import
get_object_or_none
from
..models
import
User
...
...
@@ -154,7 +156,7 @@ class UserResetPasswordView(TemplateView):
class
UserFirstLoginView
(
LoginRequiredMixin
,
SessionWizardView
):
template_name
=
'users/first_login.html'
form_list
=
[
forms
.
User
Info
Form
,
forms
.
UserPublicKeyForm
]
form_list
=
[
forms
.
User
Profile
Form
,
forms
.
UserPublicKeyForm
]
file_storage
=
default_storage
def
dispatch
(
self
,
request
,
*
args
,
**
kwargs
):
...
...
@@ -162,7 +164,7 @@ class UserFirstLoginView(LoginRequiredMixin, SessionWizardView):
return
redirect
(
reverse
(
'index'
))
return
super
(
UserFirstLoginView
,
self
)
.
dispatch
(
request
,
*
args
,
**
kwargs
)
def
done
(
self
,
form_list
,
form_dict
,
**
kwargs
):
def
done
(
self
,
form_list
,
**
kwargs
):
user
=
self
.
request
.
user
for
form
in
form_list
:
for
field
in
form
:
...
...
@@ -173,19 +175,23 @@ class UserFirstLoginView(LoginRequiredMixin, SessionWizardView):
user
.
is_first_login
=
False
user
.
is_public_key_valid
=
True
user
.
save
()
return
redirect
(
reverse
(
'index'
))
context
=
{
'user_guide_url'
:
settings
.
CONFIG
.
USER_GUIDE_URL
}
return
render
(
self
.
request
,
'users/first_login_done.html'
,
context
)
def
get_context_data
(
self
,
**
kwargs
):
context
=
super
(
UserFirstLoginView
,
self
)
.
get_context_data
(
**
kwargs
)
context
.
update
({
'app'
:
_
(
'Users'
),
'action'
:
_
(
'First
L
ogin'
)})
context
.
update
({
'app'
:
_
(
'Users'
),
'action'
:
_
(
'First
l
ogin'
)})
return
context
def
get_form_initial
(
self
,
step
):
user
=
self
.
request
.
user
if
step
==
'0'
:
return
{
'username'
:
user
.
username
or
''
,
'name'
:
user
.
name
or
user
.
username
,
'e
nable_otp'
:
user
.
enable_otp
or
True
,
'e
mail'
:
user
.
email
or
''
,
'wechat'
:
user
.
wechat
or
''
,
'phone'
:
user
.
phone
or
''
}
...
...
@@ -194,9 +200,10 @@ class UserFirstLoginView(LoginRequiredMixin, SessionWizardView):
def
get_form
(
self
,
step
=
None
,
data
=
None
,
files
=
None
):
form
=
super
(
UserFirstLoginView
,
self
)
.
get_form
(
step
,
data
,
files
)
form
.
instance
=
self
.
request
.
user
if
step
is
None
:
step
=
self
.
steps
.
current
if
step
==
'1'
:
form
.
user
=
self
.
request
.
user
#
if step == '1':
# form.instance
= self.request.user
return
form
config_example.py
View file @
067426d5
...
...
@@ -83,6 +83,9 @@ class Config:
CAPTCHA_TEST_MODE
=
False
# You can set jumpserver usage url here, that when user submit wizard redirect to
USER_GUIDE_URL
=
''
def
__init__
(
self
):
pass
...
...
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