Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
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
edx
edx-platform
Commits
d56ac9a7
Commit
d56ac9a7
authored
Aug 15, 2012
by
Mike Chen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added comment
parent
158e978a
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
3 deletions
+6
-3
lms/djangoapps/django_comment_client/permissions.py
+6
-3
No files found.
lms/djangoapps/django_comment_client/permissions.py
View file @
d56ac9a7
...
...
@@ -19,13 +19,16 @@ def assign_default_role(sender, instance, **kwargs):
instance
.
user
.
roles
.
add
(
role
)
def
cached_has_permission
(
user
,
permission
,
course_id
=
None
):
# if user.permissions.filter(name=permission).exists():
# return True
"""
Call has_permission if it's not cached. A change in a user's role or
a role's permissions will only become effective after CACHE_LIFESPAN seconds.
"""
CACHE_LIFESPAN
=
60
key
=
"permission_
%
d_
%
s_
%
s"
%
(
user
.
id
,
str
(
course_id
),
permission
)
val
=
cache
.
get
(
key
,
None
)
if
val
not
in
[
True
,
False
]:
val
=
has_permission
(
user
,
permission
,
course_id
=
course_id
)
cache
.
set
(
key
,
val
,
3600
)
cache
.
set
(
key
,
val
,
CACHE_LIFESPAN
)
return
val
def
has_permission
(
user
,
permission
,
course_id
=
None
):
...
...
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