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
fd5f562c
Commit
fd5f562c
authored
Jul 18, 2018
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Update] stash it
parent
790652ff
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
2 deletions
+18
-2
mixins.py
apps/orgs/mixins.py
+0
-1
forms.py
apps/perms/forms.py
+12
-1
forms.py
apps/users/forms.py
+6
-0
No files found.
apps/orgs/mixins.py
View file @
fd5f562c
...
...
@@ -79,7 +79,6 @@ class OrgModelForm(ModelForm):
for
name
,
field
in
self
.
fields
.
items
():
if
not
hasattr
(
field
,
'queryset'
):
continue
print
(
field
)
model
=
field
.
queryset
.
model
field
.
queryset
=
model
.
objects
.
all
()
apps/perms/forms.py
View file @
fd5f562c
...
...
@@ -4,11 +4,13 @@ from __future__ import absolute_import, unicode_literals
from
django
import
forms
from
django.utils.translation
import
ugettext_lazy
as
_
from
orgs.mixins
import
OrgModelForm
from
orgs.utils
import
get_current_org
from
.hands
import
User
from
.models
import
AssetPermission
class
AssetPermissionForm
(
forms
.
ModelForm
):
class
AssetPermissionForm
(
Org
ModelForm
):
users
=
forms
.
ModelMultipleChoiceField
(
queryset
=
User
.
objects
.
exclude
(
role
=
User
.
ROLE_APP
),
label
=
_
(
"User"
),
...
...
@@ -21,6 +23,15 @@ class AssetPermissionForm(forms.ModelForm):
required
=
False
,
)
def
__init__
(
self
,
*
args
,
**
kwargs
):
super
()
.
__init__
(
*
args
,
**
kwargs
)
if
'initial'
not
in
kwargs
:
return
users_field
=
self
.
fields
.
get
(
'users'
)
if
hasattr
(
users_field
,
'queryset'
):
current_org
=
get_current_org
()
users_field
.
queryset
=
User
.
objects
.
filter
(
orgs
=
current_org
)
class
Meta
:
model
=
AssetPermission
exclude
=
(
...
...
apps/users/forms.py
View file @
fd5f562c
...
...
@@ -306,6 +306,12 @@ class UserGroupForm(forms.ModelForm):
})
kwargs
[
'initial'
]
=
initial
super
()
.
__init__
(
**
kwargs
)
if
'initial'
not
in
kwargs
:
return
users_field
=
self
.
fields
.
get
(
'users'
)
if
hasattr
(
users_field
,
'queryset'
):
current_org
=
get_current_org
()
users_field
.
queryset
=
User
.
objects
.
filter
(
orgs
=
current_org
)
def
save
(
self
,
commit
=
True
):
group
=
super
()
.
save
(
commit
=
commit
)
...
...
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