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
68c182c0
Commit
68c182c0
authored
Nov 01, 2013
by
Calen Pennington
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Optimize and cache the query to find the list of groups a user is in
parent
e370fb95
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
4 deletions
+10
-4
lms/djangoapps/courseware/access.py
+10
-4
No files found.
lms/djangoapps/courseware/access.py
View file @
68c182c0
...
...
@@ -503,6 +503,14 @@ def _has_global_staff_access(user):
return
False
def
group_names
(
user
):
"""Return the list of names of the groups that a user is in"""
if
not
hasattr
(
user
,
'_groups'
):
user
.
_groups
=
user
.
groups
.
values_list
(
'name'
,
flat
=
True
)
return
user
.
_groups
def
_adjust_start_date_for_beta_testers
(
user
,
descriptor
):
"""
If user is in a beta test group, adjust the start date by the appropriate number of
...
...
@@ -530,10 +538,8 @@ def _adjust_start_date_for_beta_testers(user, descriptor):
# bail early if no beta testing is set up
return
descriptor
.
start
user_groups
=
[
g
.
name
for
g
in
user
.
groups
.
all
()]
beta_group
=
course_beta_test_group_name
(
descriptor
.
location
)
if
beta_group
in
user_groups
:
if
beta_group
in
group_names
(
user
)
:
debug
(
"Adjust start time: user in group
%
s"
,
beta_group
)
delta
=
timedelta
(
descriptor
.
days_early_for_beta
)
effective
=
descriptor
.
start
-
delta
...
...
@@ -577,7 +583,7 @@ def _has_access_to_location(user, location, access_level, course_context):
return
True
# If not global staff, is the user in the Auth group for this class?
user_groups
=
[
g
.
name
for
g
in
user
.
groups
.
all
()]
user_groups
=
group_names
(
user
)
if
access_level
==
'staff'
:
staff_groups
=
group_names_for_staff
(
location
,
course_context
)
+
\
...
...
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