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
0f9ae9ef
Commit
0f9ae9ef
authored
Sep 25, 2017
by
ibuler
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev' of github.com:jumpserver/jumpserver into dev
parents
4aef5b82
43a0c4fe
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
26 additions
and
9 deletions
+26
-9
asset.py
apps/assets/views/asset.py
+17
-5
user.py
apps/users/models/user.py
+1
-1
user_profile.html
apps/users/templates/users/user_profile.html
+1
-1
install.md
docs/install.md
+4
-0
requirements.txt
requirements/requirements.txt
+3
-2
No files found.
apps/assets/views/asset.py
View file @
0f9ae9ef
...
...
@@ -5,6 +5,7 @@ import csv
import
json
import
uuid
import
codecs
import
chardet
from
io
import
StringIO
from
collections
import
defaultdict
...
...
@@ -243,10 +244,11 @@ class BulkImportAssetView(AdminUserRequiredMixin, JSONResponseMixin, FormView):
form_class
=
forms
.
FileForm
def
form_valid
(
self
,
form
):
file
=
form
.
cleaned_data
[
'file'
]
data
=
file
.
read
()
.
decode
(
'utf-8'
)
.
strip
(
codecs
.
BOM_UTF8
.
decode
(
'utf-8'
))
csv_file
=
StringIO
(
data
)
f
=
form
.
cleaned_data
[
'file'
]
det_result
=
chardet
.
detect
(
f
.
read
())
f
.
seek
(
0
)
# reset file seek index
file_data
=
f
.
read
()
.
decode
(
det_result
[
'encoding'
])
.
strip
(
codecs
.
BOM_UTF8
.
decode
())
csv_file
=
StringIO
(
file_data
)
reader
=
csv
.
reader
(
csv_file
)
csv_data
=
[
row
for
row
in
reader
]
fields
=
[
...
...
@@ -270,8 +272,15 @@ class BulkImportAssetView(AdminUserRequiredMixin, JSONResponseMixin, FormView):
for
row
in
csv_data
[
1
:]:
if
set
(
row
)
==
{
''
}:
continue
asset_dict
=
dict
(
zip
(
attr
,
row
))
id_
=
asset_dict
.
pop
(
'id'
,
0
)
try
:
id_
=
int
(
id_
)
except
ValueError
:
id_
=
0
asset
=
get_object_or_none
(
Asset
,
id
=
id_
)
for
k
,
v
in
asset_dict
.
items
():
if
k
==
'idc'
:
...
...
@@ -295,11 +304,13 @@ class BulkImportAssetView(AdminUserRequiredMixin, JSONResponseMixin, FormView):
if
not
asset
:
try
:
groups
=
asset_dict
.
pop
(
'groups'
)
if
len
(
Asset
.
objects
.
filter
(
hostname
=
asset_dict
.
get
(
'hostname'
))):
raise
Exception
(
_
(
'already exists'
))
asset
=
Asset
.
objects
.
create
(
**
asset_dict
)
asset
.
groups
.
set
(
groups
)
created
.
append
(
asset_dict
[
'hostname'
])
assets
.
append
(
asset
)
except
IndexError
as
e
:
except
Exception
as
e
:
failed
.
append
(
'
%
s:
%
s'
%
(
asset_dict
[
'hostname'
],
str
(
e
)))
else
:
for
k
,
v
in
asset_dict
.
items
():
...
...
@@ -317,6 +328,7 @@ class BulkImportAssetView(AdminUserRequiredMixin, JSONResponseMixin, FormView):
if
assets
:
update_assets_hardware_info
.
delay
([
asset
.
_to_secret_json
()
for
asset
in
assets
])
data
=
{
'created'
:
created
,
'created_info'
:
'Created {}'
.
format
(
len
(
created
)),
...
...
apps/users/models/user.py
View file @
0f9ae9ef
...
...
@@ -204,7 +204,7 @@ class User(AbstractUser):
'wechat'
:
self
.
wechat
,
'phone'
:
self
.
phone
,
'comment'
:
self
.
comment
,
'date_expired'
:
self
.
date_expired
.
strftime
(
'
%
Y-
%
m-
%
d
%
H:
%
M:
%
S'
)
'date_expired'
:
self
.
date_expired
.
strftime
(
'
%
Y-
%
m-
%
d
%
H:
%
M:
%
S'
)
if
self
.
date_expired
is
not
None
else
None
})
@classmethod
...
...
apps/users/templates/users/user_profile.html
View file @
0f9ae9ef
...
...
@@ -22,7 +22,7 @@
</ul>
</div>
<div
class=
"tab-content"
>
<div
class=
"col-sm-7"
>
<div
class=
"col-sm-7"
style=
"padding-left: 0;"
>
<div
class=
"ibox float-e-margins"
>
<div
class=
"ibox-title"
>
<span
class=
"label label-primary"
><b>
{{ user.name }}
</b></span>
...
...
docs/install.md
View file @
0f9ae9ef
...
...
@@ -36,6 +36,10 @@
$ sudo yum -y install `cat rpm_requirements.txt`
$ pip install -r requirements.txt -i https://pypi.doubanio.com/simple
// 解决Mac安装ldap提示 Modules/LDAPObject.c:18:10: fatal error: 'sasl.h' file not found
pip install python-ldap \
--global-option=build_ext \
--global-option="-I$(xcrun --show-sdk-path)/usr/include/sasl"
##### 2.3 准备配置文件
...
...
requirements/requirements.txt
View file @
0f9ae9ef
...
...
@@ -5,8 +5,8 @@ djangorestframework>=3.6.2
ForgeryPy
#openpyxl>=2.4.0
celery>=4.0.2
paramiko
>
=2.1.2
ansible
>
=2.2.2.0
paramiko
=
=2.1.2
ansible
=
=2.2.2.0
django-simple-captcha>=0.5.5
django-formtools>=2.0
sshpubkeys>=2.2.0
...
...
@@ -21,3 +21,4 @@ gssapi
django-rest-swagger
django-auth-ldap
ldap3
chardet>=3.0.4
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