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
99f146df
Commit
99f146df
authored
Jul 13, 2015
by
Akiva Leffert
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #8883 from edx/aleffert/xblock-access-result
Make render_xblock return a 404 if access check fails
parents
e9eefb8b
6084f4df
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
4 deletions
+7
-4
lms/djangoapps/courseware/testutils.py
+2
-2
lms/djangoapps/courseware/views.py
+5
-2
No files found.
lms/djangoapps/courseware/testutils.py
View file @
99f146df
...
...
@@ -154,12 +154,12 @@ class RenderXBlockTestMixin(object):
def
test_unauthenticated
(
self
):
self
.
setup_course
()
self
.
setup_user
(
admin
=
False
,
enroll
=
True
,
login
=
False
)
self
.
verify_response
(
expected_response_code
=
302
)
self
.
verify_response
(
expected_response_code
=
404
)
def
test_unenrolled_student
(
self
):
self
.
setup_course
()
self
.
setup_user
(
admin
=
False
,
enroll
=
False
,
login
=
True
)
self
.
verify_response
(
expected_response_code
=
302
)
self
.
verify_response
(
expected_response_code
=
404
)
@patch.dict
(
'django.conf.settings.FEATURES'
,
{
'DISABLE_START_DATES'
:
False
})
def
test_fail_block_unreleased
(
self
):
...
...
lms/djangoapps/courseware/views.py
View file @
99f146df
...
...
@@ -37,7 +37,7 @@ from courseware.courses import (
get_studio_url
,
get_course_with_access
,
sort_by_announcement
,
sort_by_start_date
,
)
UserNotEnrolled
)
from
courseware.masquerade
import
setup_masquerade
from
openedx.core.djangoapps.credit.api
import
(
get_credit_requirement_status
,
...
...
@@ -1465,7 +1465,10 @@ def render_xblock(request, usage_key_string, check_if_enrolled=True):
with
modulestore
()
.
bulk_operations
(
course_key
):
# verify the user has access to the course, including enrollment check
course
=
get_course_with_access
(
request
.
user
,
'load'
,
course_key
,
check_if_enrolled
=
check_if_enrolled
)
try
:
course
=
get_course_with_access
(
request
.
user
,
'load'
,
course_key
,
check_if_enrolled
=
check_if_enrolled
)
except
UserNotEnrolled
:
raise
Http404
(
"Course not found."
)
# get the block, which verifies whether the user has access to the block.
block
,
_
=
get_module_by_usage_id
(
...
...
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