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
7e4820af
Commit
7e4820af
authored
Dec 09, 2013
by
Don Mitchell
Committed by
Adam Palay
Dec 10, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reduce sql queries for groupname tests. (STUD-1039)
Conflicts: cms/djangoapps/auth/authz.py
parent
ddc45ea5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
10 deletions
+6
-10
cms/djangoapps/auth/authz.py
+6
-9
lms/djangoapps/courseware/roles.py
+0
-1
No files found.
cms/djangoapps/auth/authz.py
View file @
7e4820af
...
...
@@ -63,7 +63,7 @@ def get_all_course_role_groupnames(location, role, use_filter=True):
# filter to the ones which exist
default
=
groupnames
[
0
]
if
use_filter
:
groupnames
=
[
group
for
group
in
groupnames
if
Group
.
objects
.
filter
(
name
=
group
)
.
exists
(
)]
groupnames
=
[
group
.
name
for
group
in
Group
.
objects
.
filter
(
name__in
=
groupnames
)]
return
groupnames
,
default
...
...
@@ -203,12 +203,9 @@ def remove_user_from_course_group(caller, user, location, role):
# see if the user is actually in that role, if not then we don't have to do anything
groupnames
,
_
=
get_all_course_role_groupnames
(
location
,
role
)
for
groupname
in
groupnames
:
groups
=
user
.
groups
.
filter
(
name
=
groupname
)
if
groups
:
# will only be one with that name
user
.
groups
.
remove
(
groups
[
0
])
user
.
save
()
for
group
in
user
.
groups
.
filter
(
name__in
=
groupnames
):
user
.
groups
.
remove
(
group
)
user
.
save
()
def
remove_user_from_creator_group
(
caller
,
user
):
...
...
@@ -243,7 +240,7 @@ def is_user_in_course_group_role(user, location, role, check_staff=True):
if
check_staff
and
user
.
is_staff
:
return
True
groupnames
,
_
=
get_all_course_role_groupnames
(
location
,
role
)
return
any
(
user
.
groups
.
filter
(
name
=
groupname
)
.
exists
()
for
groupname
in
groupnames
)
return
user
.
groups
.
filter
(
name__in
=
groupnames
)
.
exists
(
)
return
False
...
...
@@ -266,7 +263,7 @@ def is_user_in_creator_group(user):
# Feature flag for using the creator group setting. Will be removed once the feature is complete.
if
settings
.
MITX_FEATURES
.
get
(
'ENABLE_CREATOR_GROUP'
,
False
):
return
user
.
groups
.
filter
(
name
=
COURSE_CREATOR_GROUP_NAME
)
.
count
()
>
0
return
user
.
groups
.
filter
(
name
=
COURSE_CREATOR_GROUP_NAME
)
.
exists
()
return
True
...
...
lms/djangoapps/courseware/roles.py
View file @
7e4820af
...
...
@@ -4,7 +4,6 @@ adding users, removing users, and listing members
"""
from
abc
import
ABCMeta
,
abstractmethod
from
functools
import
partial
from
django.contrib.auth.models
import
User
,
Group
...
...
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