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
b064be3e
Commit
b064be3e
authored
Jul 01, 2019
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Bugfix] 修复用户页面不走cache的bug
parent
c3308442
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
7 additions
and
8 deletions
+7
-8
user_asset_list.html
apps/assets/templates/assets/user_asset_list.html
+1
-1
user_permission.py
apps/perms/api/user_permission.py
+5
-6
user_granted_asset.html
apps/users/templates/users/user_granted_asset.html
+1
-1
No files found.
apps/assets/templates/assets/user_asset_list.html
View file @
b064be3e
...
@@ -151,7 +151,7 @@ function initTree() {
...
@@ -151,7 +151,7 @@ function initTree() {
}
}
$
(
document
).
ready
(
function
()
{
$
(
document
).
ready
(
function
()
{
{
#
initTree
();
#
}
initTree
();
initTable
();
initTable
();
}).
on
(
'click'
,
'.labels li'
,
function
()
{
}).
on
(
'click'
,
'.labels li'
,
function
()
{
var
val
=
$
(
this
).
text
();
var
val
=
$
(
this
).
text
();
...
...
apps/perms/api/user_permission.py
View file @
b064be3e
...
@@ -58,7 +58,11 @@ class UserPermissionCacheMixin:
...
@@ -58,7 +58,11 @@ class UserPermissionCacheMixin:
return
None
return
None
def
get_request_md5
(
self
):
def
get_request_md5
(
self
):
full_path
=
self
.
request
.
get_full_path
()
path
=
self
.
request
.
path
query
=
{
k
:
v
for
k
,
v
in
self
.
request
.
GET
.
items
()}
query
.
pop
(
"_"
,
None
)
query
=
"&"
.
join
([
"{}={}"
.
format
(
k
,
v
)
for
k
,
v
in
query
.
items
()])
full_path
=
"{}?{}"
.
format
(
path
,
query
)
return
md5
(
full_path
.
encode
())
.
hexdigest
()
return
md5
(
full_path
.
encode
())
.
hexdigest
()
def
get_meta_cache_id
(
self
):
def
get_meta_cache_id
(
self
):
...
@@ -83,9 +87,7 @@ class UserPermissionCacheMixin:
...
@@ -83,9 +87,7 @@ class UserPermissionCacheMixin:
return
None
return
None
# 从响应缓冲里获取响应
# 从响应缓冲里获取响应
key
=
self
.
get_response_key
()
key
=
self
.
get_response_key
()
print
(
"response key: {}"
.
format
(
key
))
data
=
cache
.
get
(
key
)
data
=
cache
.
get
(
key
)
print
(
data
)
if
not
data
:
if
not
data
:
logger
.
debug
(
"Not get response from cache: {}"
.
format
(
key
))
logger
.
debug
(
"Not get response from cache: {}"
.
format
(
key
))
return
None
return
None
...
@@ -94,7 +96,6 @@ class UserPermissionCacheMixin:
...
@@ -94,7 +96,6 @@ class UserPermissionCacheMixin:
return
response
return
response
def
expire_response_cache
(
self
):
def
expire_response_cache
(
self
):
print
(
"Expire cache"
)
obj_id
=
self
.
get_object_id
()
obj_id
=
self
.
get_object_id
()
expire_cache_id
=
'{}_{}'
.
format
(
obj_id
,
'*'
)
expire_cache_id
=
'{}_{}'
.
format
(
obj_id
,
'*'
)
key
=
self
.
RESP_CACHE_KEY
.
format
(
expire_cache_id
)
key
=
self
.
RESP_CACHE_KEY
.
format
(
expire_cache_id
)
...
@@ -109,7 +110,6 @@ class UserPermissionCacheMixin:
...
@@ -109,7 +110,6 @@ class UserPermissionCacheMixin:
key
=
self
.
get_response_key
()
key
=
self
.
get_response_key
()
cache
.
set
(
key
,
response
.
data
,
self
.
CACHE_TIME
)
cache
.
set
(
key
,
response
.
data
,
self
.
CACHE_TIME
)
logger
.
debug
(
"Set response to cache: {}"
.
format
(
key
))
logger
.
debug
(
"Set response to cache: {}"
.
format
(
key
))
print
(
self
.
CACHE_TIME
)
def
get
(
self
,
request
,
*
args
,
**
kwargs
):
def
get
(
self
,
request
,
*
args
,
**
kwargs
):
self
.
cache_policy
=
request
.
GET
.
get
(
'cache_policy'
,
'0'
)
self
.
cache_policy
=
request
.
GET
.
get
(
'cache_policy'
,
'0'
)
...
@@ -256,7 +256,6 @@ class UserGrantedNodesWithAssetsAsTreeApi(UserPermissionCacheMixin, ListAPIView)
...
@@ -256,7 +256,6 @@ class UserGrantedNodesWithAssetsAsTreeApi(UserPermissionCacheMixin, ListAPIView)
return
user
return
user
def
get_queryset
(
self
):
def
get_queryset
(
self
):
print
(
"Call get queryset"
)
queryset
=
[]
queryset
=
[]
self
.
show_assets
=
self
.
request
.
query_params
.
get
(
'show_assets'
,
'1'
)
==
'1'
self
.
show_assets
=
self
.
request
.
query_params
.
get
(
'show_assets'
,
'1'
)
==
'1'
self
.
system_user_id
=
self
.
request
.
query_params
.
get
(
'system_user'
)
self
.
system_user_id
=
self
.
request
.
query_params
.
get
(
'system_user'
)
...
...
apps/users/templates/users/user_granted_asset.html
View file @
b064be3e
...
@@ -145,7 +145,7 @@ function initTree() {
...
@@ -145,7 +145,7 @@ function initTree() {
$
(
document
).
ready
(
function
()
{
$
(
document
).
ready
(
function
()
{
initTree
();
initTree
();
{
#
initTable
();
#
}
initTable
();
});
});
</script>
</script>
{% endblock %}
{% 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