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
bbe40800
Commit
bbe40800
authored
Jul 20, 2018
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Update] 删掉Premiddleware
parent
b6523da6
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
18 additions
and
27 deletions
+18
-27
settings.py
apps/jumpserver/settings.py
+4
-5
middleware.py
apps/orgs/middleware.py
+0
-11
mixins.py
apps/orgs/mixins.py
+10
-9
utils.py
apps/orgs/utils.py
+2
-1
api.py
apps/users/api.py
+2
-1
No files found.
apps/jumpserver/settings.py
View file @
bbe40800
...
...
@@ -78,7 +78,6 @@ INSTALLED_APPS = [
]
MIDDLEWARE
=
[
'orgs.middleware.OrgPreMiddleware'
,
'django.middleware.security.SecurityMiddleware'
,
'django.contrib.sessions.middleware.SessionMiddleware'
,
'django.middleware.locale.LocaleMiddleware'
,
...
...
@@ -234,10 +233,10 @@ LOGGING = {
'handlers'
:
[
'console'
,
'ansible_logs'
],
'level'
:
"INFO"
,
},
'django.db'
:
{
'handlers'
:
[
'console'
,
'file'
],
'level'
:
'DEBUG'
}
#
'django.db': {
#
'handlers': ['console', 'file'],
#
'level': 'DEBUG'
#
}
}
}
...
...
apps/orgs/middleware.py
View file @
bbe40800
...
...
@@ -2,17 +2,6 @@
#
from
.utils
import
get_org_from_request
,
set_current_org
from
.models
import
Organization
class
OrgPreMiddleware
:
def
__init__
(
self
,
get_response
):
self
.
get_response
=
get_response
def
__call__
(
self
,
request
):
set_current_org
(
Organization
.
root
())
response
=
self
.
get_response
(
request
)
return
response
class
OrgMiddleware
:
...
...
apps/orgs/mixins.py
View file @
bbe40800
...
...
@@ -23,7 +23,8 @@ class OrgManager(models.Manager):
current_org
=
get_current_org
()
kwargs
=
{}
print
(
">>>>>>>>>> Get query set"
)
# print(">>>>>>>>>> Get query set")
# print(current_org)
if
not
current_org
:
kwargs
[
'id'
]
=
None
elif
current_org
.
is_real
():
...
...
@@ -36,14 +37,14 @@ class OrgManager(models.Manager):
# print(queryset.query)
return
queryset
#
def all(self):
#
current_org = get_current_org()
#
if not current_org:
#
msg = 'You can `objects.set_current_org(org).all()` then run it'
#
warnings.warn(msg)
#
return self
#
else:
#
return super(OrgManager, self).all()
def
all
(
self
):
current_org
=
get_current_org
()
if
not
current_org
:
msg
=
'You can `objects.set_current_org(org).all()` then run it'
warnings
.
warn
(
msg
)
return
self
else
:
return
super
(
OrgManager
,
self
)
.
all
()
def
set_current_org
(
self
,
org
):
if
isinstance
(
org
,
str
):
...
...
apps/orgs/utils.py
View file @
bbe40800
...
...
@@ -24,7 +24,8 @@ def get_current_request():
def
get_current_org
():
return
getattr
(
_thread_locals
,
'current_org'
,
None
)
org
=
getattr
(
_thread_locals
,
'current_org'
,
None
)
return
org
def
get_current_user
():
...
...
apps/users/api.py
View file @
bbe40800
...
...
@@ -106,12 +106,13 @@ class UserUpdatePKApi(generics.UpdateAPIView):
user
.
save
()
class
UserGroupViewSet
(
IDInFilterMixin
,
OrgViewGenericMixin
,
BulkModelViewSet
):
class
UserGroupViewSet
(
BulkModelViewSet
):
queryset
=
UserGroup
.
objects
.
all
()
serializer_class
=
UserGroupSerializer
permission_classes
=
(
IsSuperUser
,)
class
UserGroupUpdateUserApi
(
generics
.
RetrieveUpdateAPIView
):
queryset
=
UserGroup
.
objects
.
all
()
serializer_class
=
UserGroupUpdateMemeberSerializer
...
...
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