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
66a2262e
Commit
66a2262e
authored
Mar 31, 2017
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Fixture] 增加 asset groups assets api
parent
067426d5
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
8 deletions
+21
-8
api.py
apps/perms/api.py
+17
-4
api_urls.py
apps/perms/urls/api_urls.py
+3
-3
first_login_done.html
apps/users/templates/users/first_login_done.html
+1
-1
No files found.
apps/perms/api.py
View file @
66a2262e
...
...
@@ -198,22 +198,35 @@ class MyAssetGroupAssetsApi(ListAPIView):
def
get
(
self
,
request
,
*
args
,
**
kwargs
):
asset_groups
=
{}
# asset_group = {1: {'id': 1, 'name': 'hello', 'assets': set(),
asset_groups
[
0
]
=
{
'id'
:
0
,
'name'
:
'ungrouped'
,
'assets'
:
[]
}
# asset_group = {
# 1: {'id': 1, 'name': 'hello',
# 'assets': [{
# 'id': 'asset_id',
# 'system_users': [{'id': 'system_user_id',...},]
# }],
# 'assets_id': set()}, 2: {}}
user
=
request
.
user
if
user
:
assets
=
get_user_granted_assets
(
user
)
for
asset
in
assets
:
for
asset
,
system_users
in
assets
.
items
():
asset_json
=
asset
.
to_json
()
asset_json
[
'system_users'
]
=
[
su
.
to_json
()
for
su
in
system_users
]
if
not
asset
.
groups
.
all
():
asset_groups
[
0
][
assets
]
.
append
(
asset_json
)
continue
for
asset_group
in
asset
.
groups
.
all
():
if
asset_group
.
id
in
asset_groups
:
asset_groups
[
asset_group
.
id
][
'assets'
]
.
a
dd
(
asset
.
to_json
()
)
asset_groups
[
asset_group
.
id
][
'assets'
]
.
a
ppend
(
asset_json
)
else
:
asset_groups
[
asset_group
.
id
]
=
{
'id'
:
asset_group
.
id
,
'name'
:
asset_group
.
name
,
'comment'
:
asset_group
.
comment
,
'assets'
:
{
asset
.
to_json
()}
,
'assets'
:
[
asset_json
]
,
}
asset_groups_json
=
asset_groups
.
values
()
return
Response
(
asset_groups_json
,
status
=
200
)
...
...
apps/perms/urls/api_urls.py
View file @
66a2262e
...
...
@@ -19,12 +19,12 @@ urlpatterns = [
url
(
r'^v1/user/my/asset-groups/$'
,
api
.
MyGrantedAssetsGroupsApi
.
as_view
(),
name
=
'my-asset-groups'
),
url
(
r'^v1/user/my/asset-groups-assets/$'
,
api
.
MyAssetGroupAssetsApi
.
as_view
(),
name
=
'my-asset-group-assets'
),
url
(
r'^v1/user/my/asset-group/(?P<pk>[0-9]+)/assets/$'
,
api
.
MyAssetGroupOfAssetsApi
.
as_view
(),
name
=
'my-asset-group-of-assets'
),
url
(
r'^v1/user/my/asset-group-assets/$'
,
api
.
MyAssetGroupAssetsApi
.
as_view
(),
name
=
'my-asset-group-assets'
),
# 查询某个用户授权的资产和资产组
url
(
r'^v1/user/(?P<pk>[0-9]+)/assets/$'
,
...
...
apps/users/templates/users/first_login_done.html
View file @
66a2262e
...
...
@@ -28,7 +28,7 @@
<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' %}
<a
href=
"{{ user_guide_url }}"
target=
"_blank"
>
{% trans 'Use guide' %}
</a>
{% trans ' for more information' %}
</div>
</div>
</div>
...
...
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