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
b56d73ba
Unverified
Commit
b56d73ba
authored
Dec 17, 2018
by
老广
Committed by
GitHub
Dec 17, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Node asset amount (#2192)
* [Bugfix] 修复错误 * [Update] 优化用户api
parent
517a27ea
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
84 additions
and
75 deletions
+84
-75
_asset_list_modal.html
apps/assets/templates/assets/_asset_list_modal.html
+9
-21
django.mo
apps/locale/zh/LC_MESSAGES/django.mo
+0
-0
django.po
apps/locale/zh/LC_MESSAGES/django.po
+36
-24
group.py
apps/users/api/group.py
+2
-2
user.py
apps/users/models/user.py
+12
-0
v1.py
apps/users/serializers/v1.py
+8
-21
user_list.html
apps/users/templates/users/user_list.html
+17
-7
No files found.
apps/assets/templates/assets/_asset_list_modal.html
View file @
b56d73ba
...
...
@@ -71,14 +71,14 @@ function initTable2() {
function
onSelected2
(
event
,
treeNode
)
{
var
url
=
asset_table2
.
ajax
.
url
();
url
=
setUrlParam
(
url
,
"node_id"
,
treeNode
.
node_id
);
setCookie
(
'node_selected'
,
treeNode
.
id
);
url
=
setUrlParam
(
url
,
"node_id"
,
treeNode
.
meta
.
node
.
id
);
asset_table2
.
ajax
.
url
(
url
);
asset_table2
.
ajax
.
reload
();
}
function
initTree2
()
{
var
url
=
'{% url '
api
-
assets
:
node
-
children
-
tree
' %}?assets=0'
;
var
setting
=
{
view
:
{
dblClickExpand
:
false
,
...
...
@@ -89,29 +89,17 @@ function initTree2() {
enable
:
true
}
},
async
:
{
enable
:
true
,
url
:
url
,
autoParam
:
[
"id=key"
,
"name=n"
,
"level=lv"
],
type
:
'get'
},
callback
:
{
onSelected
:
onSelected2
}
};
var
zNodes
=
[];
$
.
get
(
"{% url 'api-assets:node-list' %}"
,
function
(
data
,
status
){
$
.
each
(
data
,
function
(
index
,
value
)
{
value
[
"node_id"
]
=
value
[
"id"
];
value
[
"id"
]
=
value
[
"tree_id"
];
value
[
"pId"
]
=
value
[
"tree_parent"
];
{
#
value
[
"open"
]
=
true
;
#
}
if
(
value
[
"key"
]
===
"0"
)
{
value
[
"open"
]
=
true
;
}
value
[
"name"
]
=
value
[
"value"
]
+
' ('
+
value
[
'assets_amount'
]
+
')'
;
});
zNodes
=
data
;
$
.
fn
.
zTree
.
init
(
$
(
"#assetTree2"
),
setting
,
zNodes
);
zTree2
=
$
.
fn
.
zTree
.
getZTreeObj
(
"assetTree2"
);
var
root
=
zTree2
.
getNodes
()[
0
];
zTree2
.
expandNode
(
root
);
});
zTree2
=
$
.
fn
.
zTree
.
init
(
$
(
"#assetTree2"
),
setting
);
}
...
...
apps/locale/zh/LC_MESSAGES/django.mo
View file @
b56d73ba
No preview for this file type
apps/locale/zh/LC_MESSAGES/django.po
View file @
b56d73ba
...
...
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Jumpserver 0.3.3\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-12-17
17:51
+0800\n"
"POT-Creation-Date: 2018-12-17
20:06
+0800\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: ibuler <ibuler@qq.com>\n"
"Language-Team: Jumpserver team<ibuler@qq.com>\n"
...
...
@@ -480,7 +480,7 @@ msgid "Default"
msgstr "默认"
#: assets/models/cluster.py:36 assets/models/label.py:14
#: users/models/user.py:4
20
#: users/models/user.py:4
32
msgid "System"
msgstr "系统"
...
...
@@ -617,7 +617,7 @@ msgstr "默认资产组"
#: terminal/templates/terminal/command_list.html:72
#: terminal/templates/terminal/session_list.html:33
#: terminal/templates/terminal/session_list.html:71 users/forms.py:314
#: users/models/user.py:33 users/models/user.py:4
08
#: users/models/user.py:33 users/models/user.py:4
20
#: users/templates/users/user_group_detail.html:78
#: users/templates/users/user_group_list.html:13 users/views/user.py:386
#: xpack/plugins/orgs/forms.py:26
...
...
@@ -1021,7 +1021,7 @@ msgstr "测试"
#: users/templates/users/user_detail.html:25
#: users/templates/users/user_group_detail.html:28
#: users/templates/users/user_group_list.html:43
#: users/templates/users/user_list.html:
77
#: users/templates/users/user_list.html:
80
#: users/templates/users/user_profile.html:155
#: users/templates/users/user_profile.html:185
#: users/templates/users/user_profile.html:194
...
...
@@ -1055,8 +1055,8 @@ msgstr "更新"
#: users/templates/users/user_detail.html:30
#: users/templates/users/user_group_detail.html:32
#: users/templates/users/user_group_list.html:45
#: users/templates/users/user_list.html:8
1
#: users/templates/users/user_list.html:8
5
#: users/templates/users/user_list.html:8
4
#: users/templates/users/user_list.html:8
8
#: xpack/plugins/cloud/templates/cloud/account_detail.html:29
#: xpack/plugins/cloud/templates/cloud/account_list.html:40
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_detail.html:32
...
...
@@ -1090,7 +1090,7 @@ msgstr "选择节点"
#: users/templates/users/user_detail.html:480
#: users/templates/users/user_group_create_update.html:32
#: users/templates/users/user_group_list.html:88
#: users/templates/users/user_list.html:20
5
#: users/templates/users/user_list.html:20
8
#: users/templates/users/user_profile.html:236
#: xpack/plugins/cloud/templates/cloud/account_create_update.html:34
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_create.html:36
...
...
@@ -1175,7 +1175,6 @@ msgstr "快速修改"
#: users/templates/users/user_detail.html:144
#: users/templates/users/user_granted_asset.html:46
#: users/templates/users/user_group_granted_asset.html:46
#: users/templates/users/user_list.html:28
#: users/templates/users/user_profile.html:63
msgid "Active"
msgstr "激活中"
...
...
@@ -1308,7 +1307,7 @@ msgstr "重命名失败,不能更改root节点的名称"
#: users/templates/users/user_detail.html:406
#: users/templates/users/user_detail.html:474
#: users/templates/users/user_group_list.html:82
#: users/templates/users/user_list.html:
199
#: users/templates/users/user_list.html:
202
msgid "Are you sure?"
msgstr "你确认吗?"
...
...
@@ -1324,7 +1323,7 @@ msgstr "删除选择资产"
#: users/templates/users/user_detail.html:478
#: users/templates/users/user_group_create_update.html:31
#: users/templates/users/user_group_list.html:86
#: users/templates/users/user_list.html:20
3
#: users/templates/users/user_list.html:20
6
#: xpack/plugins/orgs/templates/orgs/org_create_update.html:32
msgid "Cancel"
msgstr "取消"
...
...
@@ -3330,7 +3329,7 @@ msgstr "添加到用户组"
msgid "Public key should not be the same as your old one."
msgstr "不能和原来的密钥相同"
#: users/forms.py:114 users/forms.py:249 users/serializers/v1.py:
51
#: users/forms.py:114 users/forms.py:249 users/serializers/v1.py:
38
msgid "Not a valid ssh public key"
msgstr "ssh密钥不合法"
...
...
@@ -3457,7 +3456,7 @@ msgstr "Agent"
msgid "Date login"
msgstr "登录日期"
#: users/models/user.py:32 users/models/user.py:4
16
#: users/models/user.py:32 users/models/user.py:4
28
msgid "Administrator"
msgstr "管理员"
...
...
@@ -3503,7 +3502,7 @@ msgstr "用户来源"
msgid "Date password last updated"
msgstr "最后更新密码日期"
#: users/models/user.py:4
19
#: users/models/user.py:4
31
msgid "Administrator is the super user of system"
msgstr "Administrator是初始的超级管理员"
...
...
@@ -3924,23 +3923,37 @@ msgstr "用户组删除"
msgid "UserGroup Deleting failed."
msgstr "用户组删除失败"
#: users/templates/users/user_list.html:200
#: users/templates/users/user_list.html:28 xpack/plugins/cloud/models.py:52
#: xpack/plugins/cloud/templates/cloud/account_detail.html:60
#: xpack/plugins/cloud/templates/cloud/account_list.html:14
msgid "Validity"
msgstr "账户状态"
#: users/templates/users/user_list.html:203
msgid "This will delete the selected users !!!"
msgstr "删除选中用户 !!!"
#: users/templates/users/user_list.html:2
09
#: users/templates/users/user_list.html:2
12
msgid "User Deleted."
msgstr "已被删除"
#: users/templates/users/user_list.html:21
0
#: users/templates/users/user_list.html:21
5
#: users/templates/users/user_list.html:21
3
#: users/templates/users/user_list.html:21
8
msgid "User Delete"
msgstr "删除"
#: users/templates/users/user_list.html:21
4
#: users/templates/users/user_list.html:21
7
msgid "User Deleting failed."
msgstr "用户删除失败"
#: users/templates/users/user_list.html:253
msgid "User is expired"
msgstr "用户已失效"
#: users/templates/users/user_list.html:256
msgid "User is inactive"
msgstr "用户已禁用"
#: users/templates/users/user_otp_authentication.html:6
#: users/templates/users/user_password_authentication.html:6
msgid "Authenticate"
...
...
@@ -4407,12 +4420,6 @@ msgstr ""
msgid "Access key secret"
msgstr ""
#: xpack/plugins/cloud/models.py:52
#: xpack/plugins/cloud/templates/cloud/account_detail.html:60
#: xpack/plugins/cloud/templates/cloud/account_list.html:14
msgid "Validity"
msgstr "账户状态"
#: xpack/plugins/cloud/models.py:120
msgid "Regions"
msgstr "地域"
...
...
@@ -4606,6 +4613,11 @@ msgstr "创建组织"
msgid "Update org"
msgstr "更新组织"
#, fuzzy
#~| msgid "Validity"
#~ msgid "Valid"
#~ msgstr "账户状态"
#~ msgid "You can't update the root node name"
#~ msgstr "不能修改根节点名称"
...
...
apps/users/api/group.py
View file @
b56d73ba
...
...
@@ -6,7 +6,7 @@ from rest_framework_bulk import BulkModelViewSet
from
rest_framework.pagination
import
LimitOffsetPagination
from
..serializers
import
UserGroupSerializer
,
\
UserGroupUpdateMem
e
berSerializer
UserGroupUpdateMemberSerializer
from
..models
import
UserGroup
from
common.permissions
import
IsOrgAdmin
from
common.mixins
import
IDInFilterMixin
...
...
@@ -26,5 +26,5 @@ class UserGroupViewSet(IDInFilterMixin, BulkModelViewSet):
class
UserGroupUpdateUserApi
(
generics
.
RetrieveUpdateAPIView
):
queryset
=
UserGroup
.
objects
.
all
()
serializer_class
=
UserGroupUpdateMem
e
berSerializer
serializer_class
=
UserGroupUpdateMemberSerializer
permission_classes
=
(
IsOrgAdmin
,)
apps/users/models/user.py
View file @
b56d73ba
...
...
@@ -142,6 +142,18 @@ class User(AbstractUser):
return
True
return
False
@property
def
groups_display
(
self
):
return
' '
.
join
(
self
.
groups
.
all
()
.
values_list
(
'name'
,
flat
=
True
))
@property
def
role_display
(
self
):
return
self
.
get_role_display
()
@property
def
source_display
(
self
):
return
self
.
get_source_display
()
@property
def
is_expired
(
self
):
if
self
.
date_expired
and
self
.
date_expired
<
timezone
.
now
():
...
...
apps/users/serializers/v1.py
View file @
b56d73ba
...
...
@@ -13,31 +13,18 @@ signer = get_signer()
class
UserSerializer
(
BulkSerializerMixin
,
serializers
.
ModelSerializer
):
groups_display
=
serializers
.
SerializerMethodField
()
groups
=
serializers
.
PrimaryKeyRelatedField
(
many
=
True
,
queryset
=
UserGroup
.
objects
.
all
(),
required
=
False
)
class
Meta
:
model
=
User
list_serializer_class
=
BulkListSerializer
exclude
=
[
'first_name'
,
'last_name'
,
'password'
,
'_private_key'
,
'_public_key'
,
'_otp_secret_key'
,
'user_permissions'
fields
=
[
'id'
,
'name'
,
'username'
,
'email'
,
'groups'
,
'groups_display'
,
'role'
,
'role_display'
,
'avatar_url'
,
'wechat'
,
'phone'
,
'otp_level'
,
'comment'
,
'source'
,
'source_display'
,
'is_valid'
,
'is_expired'
,
'is_active'
,
'created_by'
,
'is_first_login'
,
'date_password_last_updated'
,
'date_expired'
,
]
# validators = []
def
get_field_names
(
self
,
declared_fields
,
info
):
fields
=
super
(
UserSerializer
,
self
)
.
get_field_names
(
declared_fields
,
info
)
fields
.
extend
([
'groups_display'
,
'get_role_display'
,
'get_source_display'
,
'is_valid'
])
return
fields
@staticmethod
def
get_groups_display
(
obj
):
return
" "
.
join
([
group
.
name
for
group
in
obj
.
groups
.
all
()])
class
UserPKUpdateSerializer
(
serializers
.
ModelSerializer
):
...
...
@@ -74,7 +61,7 @@ class UserGroupSerializer(BulkSerializerMixin, serializers.ModelSerializer):
return
[
user
.
name
for
user
in
obj
.
users
.
all
()]
class
UserGroupUpdateMem
e
berSerializer
(
serializers
.
ModelSerializer
):
class
UserGroupUpdateMemberSerializer
(
serializers
.
ModelSerializer
):
users
=
serializers
.
PrimaryKeyRelatedField
(
many
=
True
,
queryset
=
User
.
objects
.
all
())
class
Meta
:
...
...
apps/users/templates/users/user_list.html
View file @
b56d73ba
...
...
@@ -25,7 +25,7 @@
<th
class=
"text-center"
>
{% trans 'Role' %}
</th>
<th
class=
"text-center"
>
{% trans 'User group' %}
</th>
<th
class=
"text-center"
>
{% trans 'Source' %}
</th>
<th
class=
"text-center"
>
{% trans '
Active
' %}
</th>
<th
class=
"text-center"
>
{% trans '
Validity
' %}
</th>
<th
class=
"text-center"
>
{% trans 'Action' %}
</th>
</tr>
</thead>
...
...
@@ -66,11 +66,14 @@ function initTable() {
var
innerHtml
=
cellData
.
length
>
20
?
cellData
.
substring
(
0
,
20
)
+
'...'
:
cellData
;
$
(
td
).
html
(
'<span href="javascript:void(0);" data-toggle="tooltip" title="'
+
cellData
+
'">'
+
innerHtml
+
'</span>'
);
}},
{
targets
:
6
,
createdCell
:
function
(
td
,
cellData
)
{
if
(
!
cellData
)
{
$
(
td
).
html
(
'<i class="fa fa-times text-danger"></i>'
)
}
else
{
{
targets
:
6
,
createdCell
:
function
(
td
,
cellData
,
rowData
)
{
if
(
cellData
)
{
$
(
td
).
html
(
'<i class="fa fa-check text-navy"></i>'
)
}
else
if
(
!
rowData
.
is_active
)
{
$
(
td
).
html
(
'<i class="fa fa-times text-danger inactive"></i>'
)
}
else
if
(
rowData
.
is_expired
)
{
$
(
td
).
html
(
'<i class="fa fa-times text-danger expired"></i>'
)
}
}},
{
targets
:
7
,
createdCell
:
function
(
td
,
cellData
,
rowData
)
{
...
...
@@ -91,9 +94,9 @@ function initTable() {
ajax_url
:
'{% url "api-users:user-list" %}'
,
columns
:
[
{
data
:
"id"
},
{
data
:
"name"
},
{
data
:
"username"
},
{
data
:
"
get_
role_display"
,
orderable
:
false
},
{
data
:
"role_display"
,
orderable
:
false
},
{
data
:
"groups_display"
,
orderable
:
false
},
{
data
:
"
get_
source_display"
,
orderable
:
false
},
{
data
:
"source_display"
,
orderable
:
false
},
{
data
:
"is_valid"
,
orderable
:
false
},
{
data
:
"id"
,
orderable
:
false
}
],
...
...
@@ -246,6 +249,13 @@ $(document).ready(function(){
var
uid
=
$this
.
data
(
'uid'
);
var
the_url
=
'{% url "api-users:user-detail" pk=DEFAULT_PK %}'
.
replace
(
"{{ DEFAULT_PK }}"
,
uid
);
objectDelete
(
$this
,
name
,
the_url
);
}).
on
(
'click'
,
'.expired'
,
function
()
{
var
msg
=
'{% trans "User is expired" %}'
;
toastr
.
error
(
msg
)
}).
on
(
'click'
,
'.inactive'
,
function
()
{
var
msg
=
'{% trans '
User
is
inactive
' %}'
;
toastr
.
error
(
msg
)
})
</script>
{% endblock %}
...
...
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