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
c1d27402
Unverified
Commit
c1d27402
authored
Sep 11, 2019
by
老广
Committed by
GitHub
Sep 11, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Update] 添加 asset permission默认排序,去掉node permission model (#3214)
parent
041bab88
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
20 deletions
+34
-20
0008_auto_20190911_1907.py
apps/perms/migrations/0008_auto_20190911_1907.py
+32
-0
asset_permission.py
apps/perms/models/asset_permission.py
+2
-20
No files found.
apps/perms/migrations/0008_auto_20190911_1907.py
0 → 100644
View file @
c1d27402
# Generated by Django 2.1.7 on 2019-09-11 11:07
from
django.db
import
migrations
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'perms'
,
'0007_remove_assetpermission_actions'
),
]
operations
=
[
migrations
.
RemoveField
(
model_name
=
'nodepermission'
,
name
=
'node'
,
),
migrations
.
RemoveField
(
model_name
=
'nodepermission'
,
name
=
'system_user'
,
),
migrations
.
RemoveField
(
model_name
=
'nodepermission'
,
name
=
'user_group'
,
),
migrations
.
AlterModelOptions
(
name
=
'assetpermission'
,
options
=
{
'ordering'
:
(
'name'
,),
'verbose_name'
:
'Asset permission'
},
),
migrations
.
DeleteModel
(
name
=
'NodePermission'
,
),
]
apps/perms/models/asset_permission.py
View file @
c1d27402
...
@@ -13,7 +13,7 @@ from .base import BasePermission
...
@@ -13,7 +13,7 @@ from .base import BasePermission
__all__
=
[
__all__
=
[
'AssetPermission'
,
'
NodePermission'
,
'
Action'
,
'AssetPermission'
,
'Action'
,
]
]
...
@@ -78,12 +78,12 @@ class AssetPermission(BasePermission):
...
@@ -78,12 +78,12 @@ class AssetPermission(BasePermission):
assets
=
models
.
ManyToManyField
(
'assets.Asset'
,
related_name
=
'granted_by_permissions'
,
blank
=
True
,
verbose_name
=
_
(
"Asset"
))
assets
=
models
.
ManyToManyField
(
'assets.Asset'
,
related_name
=
'granted_by_permissions'
,
blank
=
True
,
verbose_name
=
_
(
"Asset"
))
nodes
=
models
.
ManyToManyField
(
'assets.Node'
,
related_name
=
'granted_by_permissions'
,
blank
=
True
,
verbose_name
=
_
(
"Nodes"
))
nodes
=
models
.
ManyToManyField
(
'assets.Node'
,
related_name
=
'granted_by_permissions'
,
blank
=
True
,
verbose_name
=
_
(
"Nodes"
))
system_users
=
models
.
ManyToManyField
(
'assets.SystemUser'
,
related_name
=
'granted_by_permissions'
,
verbose_name
=
_
(
"System user"
))
system_users
=
models
.
ManyToManyField
(
'assets.SystemUser'
,
related_name
=
'granted_by_permissions'
,
verbose_name
=
_
(
"System user"
))
# actions = models.ManyToManyField(Action, related_name='permissions', blank=True, verbose_name=_('Action'))
actions
=
models
.
IntegerField
(
choices
=
Action
.
DB_CHOICES
,
default
=
Action
.
ALL
,
verbose_name
=
_
(
"Actions"
))
actions
=
models
.
IntegerField
(
choices
=
Action
.
DB_CHOICES
,
default
=
Action
.
ALL
,
verbose_name
=
_
(
"Actions"
))
class
Meta
:
class
Meta
:
unique_together
=
[(
'org_id'
,
'name'
)]
unique_together
=
[(
'org_id'
,
'name'
)]
verbose_name
=
_
(
"Asset permission"
)
verbose_name
=
_
(
"Asset permission"
)
ordering
=
(
'name'
,)
@classmethod
@classmethod
def
get_queryset_with_prefetch
(
cls
):
def
get_queryset_with_prefetch
(
cls
):
...
@@ -106,21 +106,3 @@ class AssetPermission(BasePermission):
...
@@ -106,21 +106,3 @@ class AssetPermission(BasePermission):
args
=
reduce
(
lambda
x
,
y
:
x
|
y
,
args
)
args
=
reduce
(
lambda
x
,
y
:
x
|
y
,
args
)
assets
=
Asset
.
objects
.
filter
(
args
)
.
distinct
()
assets
=
Asset
.
objects
.
filter
(
args
)
.
distinct
()
return
assets
return
assets
class
NodePermission
(
OrgModelMixin
):
id
=
models
.
UUIDField
(
default
=
uuid
.
uuid4
,
primary_key
=
True
)
node
=
models
.
ForeignKey
(
'assets.Node'
,
on_delete
=
models
.
CASCADE
,
verbose_name
=
_
(
"Node"
))
user_group
=
models
.
ForeignKey
(
'users.UserGroup'
,
on_delete
=
models
.
CASCADE
,
verbose_name
=
_
(
"User group"
))
system_user
=
models
.
ForeignKey
(
'assets.SystemUser'
,
on_delete
=
models
.
CASCADE
,
verbose_name
=
_
(
"System user"
))
is_active
=
models
.
BooleanField
(
default
=
True
,
verbose_name
=
_
(
'Active'
))
date_expired
=
models
.
DateTimeField
(
default
=
date_expired_default
,
verbose_name
=
_
(
'Date expired'
))
created_by
=
models
.
CharField
(
max_length
=
128
,
blank
=
True
,
verbose_name
=
_
(
'Created by'
))
date_created
=
models
.
DateTimeField
(
auto_now_add
=
True
,
verbose_name
=
_
(
'Date created'
))
comment
=
models
.
TextField
(
verbose_name
=
_
(
'Comment'
),
blank
=
True
)
def
__str__
(
self
):
return
"{}:{}:{}"
.
format
(
self
.
node
.
value
,
self
.
user_group
.
name
,
self
.
system_user
.
name
)
class
Meta
:
verbose_name
=
_
(
"Asset permission"
)
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