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
32e00212
Commit
32e00212
authored
Jan 21, 2014
by
Don Mitchell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create mapping for previously unmapped locations in order to get
course_id STUD-1212
parent
7bdcc848
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
2 deletions
+41
-2
common/djangoapps/student/roles.py
+1
-1
common/djangoapps/student/tests/test_roles.py
+40
-1
No files found.
common/djangoapps/student/roles.py
View file @
32e00212
...
@@ -168,7 +168,7 @@ class CourseRole(GroupBasedRole):
...
@@ -168,7 +168,7 @@ class CourseRole(GroupBasedRole):
else
:
else
:
groupnames
.
append
(
'{0}_{1}'
.
format
(
role
,
course_context
))
groupnames
.
append
(
'{0}_{1}'
.
format
(
role
,
course_context
))
try
:
try
:
locator
=
loc_mapper
()
.
translate_location
(
course_context
,
self
.
location
,
False
,
Fals
e
)
locator
=
loc_mapper
()
.
translate_location
(
course_context
,
self
.
location
,
True
,
Tru
e
)
groupnames
.
append
(
'{0}_{1}'
.
format
(
role
,
locator
.
package_id
))
groupnames
.
append
(
'{0}_{1}'
.
format
(
role
,
locator
.
package_id
))
except
(
InvalidLocationError
,
ItemNotFoundError
):
except
(
InvalidLocationError
,
ItemNotFoundError
):
# if it's never been mapped, the auth won't be via the Locator syntax
# if it's never been mapped, the auth won't be via the Locator syntax
...
...
common/djangoapps/student/tests/test_roles.py
View file @
32e00212
...
@@ -8,7 +8,9 @@ from xmodule.modulestore import Location
...
@@ -8,7 +8,9 @@ from xmodule.modulestore import Location
from
courseware.tests.factories
import
UserFactory
,
StaffFactory
,
InstructorFactory
from
courseware.tests.factories
import
UserFactory
,
StaffFactory
,
InstructorFactory
from
student.tests.factories
import
AnonymousUserFactory
from
student.tests.factories
import
AnonymousUserFactory
from
student.roles
import
GlobalStaff
,
CourseRole
from
student.roles
import
GlobalStaff
,
CourseRole
,
CourseStaffRole
from
xmodule.modulestore.django
import
loc_mapper
from
xmodule.modulestore.locator
import
BlockUsageLocator
class
RolesTestCase
(
TestCase
):
class
RolesTestCase
(
TestCase
):
...
@@ -45,3 +47,40 @@ class RolesTestCase(TestCase):
...
@@ -45,3 +47,40 @@ class RolesTestCase(TestCase):
self
.
assertTrue
(
CourseRole
(
"role"
,
lowercase_loc
)
.
has_user
(
uppercase_user
))
self
.
assertTrue
(
CourseRole
(
"role"
,
lowercase_loc
)
.
has_user
(
uppercase_user
))
self
.
assertTrue
(
CourseRole
(
"role"
,
uppercase_loc
)
.
has_user
(
uppercase_user
))
self
.
assertTrue
(
CourseRole
(
"role"
,
uppercase_loc
)
.
has_user
(
uppercase_user
))
def
test_course_role
(
self
):
"""
Test that giving a user a course role enables access appropriately
"""
course_locator
=
loc_mapper
()
.
translate_location
(
self
.
course
.
course_id
,
self
.
course
,
add_entry_if_missing
=
True
)
self
.
assertFalse
(
CourseStaffRole
(
course_locator
)
.
has_user
(
self
.
student
),
"Student has premature access to {}"
.
format
(
unicode
(
course_locator
))
)
self
.
assertFalse
(
CourseStaffRole
(
self
.
course
)
.
has_user
(
self
.
student
),
"Student has premature access to {}"
.
format
(
self
.
course
.
url
())
)
CourseStaffRole
(
course_locator
)
.
add_users
(
self
.
student
)
self
.
assertTrue
(
CourseStaffRole
(
course_locator
)
.
has_user
(
self
.
student
),
"Student doesn't have access to {}"
.
format
(
unicode
(
course_locator
))
)
self
.
assertTrue
(
CourseStaffRole
(
self
.
course
)
.
has_user
(
self
.
student
),
"Student doesn't have access to {}"
.
format
(
unicode
(
self
.
course
.
url
()))
)
# now try accessing something internal to the course
vertical_locator
=
BlockUsageLocator
(
package_id
=
course_locator
.
package_id
,
branch
=
'published'
,
block_id
=
'madeup'
)
vertical_location
=
self
.
course
.
replace
(
category
=
'vertical'
,
name
=
'madeuptoo'
)
self
.
assertTrue
(
CourseStaffRole
(
vertical_locator
)
.
has_user
(
self
.
student
),
"Student doesn't have access to {}"
.
format
(
unicode
(
vertical_locator
))
)
self
.
assertTrue
(
CourseStaffRole
(
vertical_location
,
course_context
=
self
.
course
.
course_id
)
.
has_user
(
self
.
student
),
"Student doesn't have access to {}"
.
format
(
unicode
(
vertical_location
.
url
()))
)
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