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
ce100bad
Commit
ce100bad
authored
Jun 27, 2013
by
cahrens
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add doc strings.
parent
3babf539
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
2 deletions
+16
-2
cms/djangoapps/auth/authz.py
+4
-0
cms/djangoapps/auth/tests/test_authz.py
+12
-2
No files found.
cms/djangoapps/auth/authz.py
View file @
ce100bad
...
...
@@ -208,6 +208,10 @@ def is_user_in_creator_group(user):
def
_grant_instructors_creator_access
(
caller
):
"""
This is to be called only by either a command line code path or through an app which has already
asserted permissions to do this action
"""
for
group
in
Group
.
objects
.
all
():
if
group
.
name
.
startswith
(
INSTRUCTOR_ROLE_NAME
+
"_"
):
for
user
in
group
.
user_set
.
all
():
...
...
cms/djangoapps/auth/tests/test_authz.py
View file @
ce100bad
...
...
@@ -177,8 +177,13 @@ class CourseGroupTest(TestCase):
class
GrantInstructorsCreatorAccessTest
(
TestCase
):
"""
Tests granting existing instructors course creator rights.
"""
def
create_course
(
self
,
index
):
"""
Creates a course with one instructor and one staff member.
"""
creator
=
User
.
objects
.
create_user
(
'testcreator'
+
str
(
index
),
'testcreator+courses@edx.org'
,
'foo'
)
staff
=
User
.
objects
.
create_user
(
'teststaff'
+
str
(
index
),
'teststaff+courses@edx.org'
,
'foo'
)
location
=
'i4x'
,
'mitX'
,
str
(
index
),
'course'
,
'test'
...
...
@@ -187,9 +192,13 @@ class GrantInstructorsCreatorAccessTest(TestCase):
return
[
creator
,
staff
]
def
test_grant_creator_access
(
self
):
"""
Test for _grant_instructors_creator_access.
"""
[
creator1
,
staff1
]
=
self
.
create_course
(
1
)
[
creator2
,
staff2
]
=
self
.
create_course
(
2
)
with
mock
.
patch
.
dict
(
'django.conf.settings.MITX_FEATURES'
,
{
"ENABLE_CREATOR_GROUP"
:
True
}):
# Initially no creators.
self
.
assertFalse
(
is_user_in_creator_group
(
creator1
))
self
.
assertFalse
(
is_user_in_creator_group
(
creator2
))
self
.
assertFalse
(
is_user_in_creator_group
(
staff1
))
...
...
@@ -198,9 +207,10 @@ class GrantInstructorsCreatorAccessTest(TestCase):
admin
=
User
.
objects
.
create_user
(
'populate_creators_command'
,
'grant+creator+access@edx.org'
,
'foo'
)
admin
.
is_staff
=
True
_grant_instructors_creator_access
(
admin
)
_grant_instructors_creator_access
(
admin
)
# Now instructors only are creators.
self
.
assertTrue
(
is_user_in_creator_group
(
creator1
))
self
.
assertTrue
(
is_user_in_creator_group
(
creator2
))
self
.
assertFalse
(
is_user_in_creator_group
(
staff1
))
self
.
assertFalse
(
is_user_in_creator_group
(
staff2
))
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