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
4e9ce2bd
Commit
4e9ce2bd
authored
Aug 27, 2012
by
David Ormsbee
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #565 from MITx/feature/victor/fix-queue-access-control
Fix latent bug in access checks in get_module
parents
db028328
1e72e1c9
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
8 deletions
+19
-8
lms/djangoapps/courseware/module_render.py
+4
-6
lms/djangoapps/courseware/tests/tests.py
+11
-2
lms/djangoapps/courseware/views.py
+4
-0
No files found.
lms/djangoapps/courseware/module_render.py
View file @
4e9ce2bd
...
...
@@ -144,8 +144,8 @@ def get_module(user, request, location, student_module_cache, course_id, positio
Arguments:
- user : User for whom we're getting the module
- request : current django HTTPrequest
-- used in particular for
auth
(This is important e.g. for prof impersonation of students in progress view)
- request : current django HTTPrequest
. Note: request.user isn't used for anything--all
auth
and such works based on user.
- location : A Location-like object identifying the module to load
- student_module_cache : a StudentModuleCache
- course_id : the course_id in the context of which to load module
...
...
@@ -171,12 +171,10 @@ def _get_module(user, request, location, student_module_cache, course_id, positi
descriptor
=
modulestore
()
.
get_instance
(
course_id
,
location
)
# Short circuit--if the user shouldn't have access, bail without doing any work
# NOTE: Do access check on request.user -- that's who actually needs access (e.g. could be prof
# impersonating a user)
if
not
has_access
(
request
.
user
,
descriptor
,
'load'
):
if
not
has_access
(
user
,
descriptor
,
'load'
):
return
None
#
TODO
Only check the cache if this module can possibly have state
# Only check the cache if this module can possibly have state
instance_module
=
None
shared_module
=
None
if
user
.
is_authenticated
():
...
...
lms/djangoapps/courseware/tests/tests.py
View file @
4e9ce2bd
...
...
@@ -411,8 +411,6 @@ class TestViewAuth(PageLoader):
"""list of urls that only instructors/staff should be able to see"""
urls
=
reverse_urls
([
'instructor_dashboard'
,
'gradebook'
,
'grade_summary'
],
course
)
urls
.
append
(
reverse
(
'student_progress'
,
kwargs
=
{
'course_id'
:
course
.
id
,
'student_id'
:
user
(
self
.
student
)
.
id
}))
return
urls
def
check_non_staff
(
course
):
...
...
@@ -435,6 +433,17 @@ class TestViewAuth(PageLoader):
print
'checking for 200 on {0}'
.
format
(
url
)
self
.
check_for_get_code
(
200
,
url
)
# The student progress tab is not accessible to a student
# before launch, so the instructor view-as-student feature should return a 404 as well.
# TODO (vshnayder): If this is not the behavior we want, will need
# to make access checking smarter and understand both the effective
# user (the student), and the requesting user (the prof)
url
=
reverse
(
'student_progress'
,
kwargs
=
{
'course_id'
:
course
.
id
,
'student_id'
:
user
(
self
.
student
)
.
id
})
print
'checking for 404 on view-as-student: {0}'
.
format
(
url
)
self
.
check_for_get_code
(
404
,
url
)
# First, try with an enrolled student
print
'=== Testing student access....'
self
.
login
(
self
.
student
,
self
.
password
)
...
...
lms/djangoapps/courseware/views.py
View file @
4e9ce2bd
...
...
@@ -333,6 +333,10 @@ def progress(request, course_id, student_id=None):
course_module
=
get_module
(
student
,
request
,
course
.
location
,
student_module_cache
,
course_id
)
# The course_module should be accessible, but check anyway just in case something went wrong:
if
course_module
is
None
:
raise
Http404
(
"Course does not exist"
)
courseware_summary
=
grades
.
progress_summary
(
student
,
course_module
,
course
.
grader
,
student_module_cache
)
grade_summary
=
grades
.
grade
(
student
,
request
,
course
,
student_module_cache
)
...
...
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