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
f7d6d149
Commit
f7d6d149
authored
Jun 25, 2013
by
Sarina Canelake
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Catch InvalidLocationError
parent
2cd18dfa
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
3 deletions
+19
-3
lms/djangoapps/courseware/courses.py
+3
-3
lms/djangoapps/courseware/tests/test_courses.py
+16
-0
No files found.
lms/djangoapps/courseware/courses.py
View file @
f7d6d149
...
@@ -12,12 +12,11 @@ from xmodule.modulestore import Location
...
@@ -12,12 +12,11 @@ from xmodule.modulestore import Location
from
xmodule.modulestore.django
import
modulestore
from
xmodule.modulestore.django
import
modulestore
from
xmodule.contentstore.content
import
StaticContent
from
xmodule.contentstore.content
import
StaticContent
from
xmodule.modulestore.xml
import
XMLModuleStore
from
xmodule.modulestore.xml
import
XMLModuleStore
from
xmodule.modulestore.exceptions
import
ItemNotFoundError
from
xmodule.modulestore.exceptions
import
ItemNotFoundError
,
InvalidLocationError
from
courseware.model_data
import
ModelDataCache
from
courseware.model_data
import
ModelDataCache
from
static_replace
import
replace_static_urls
from
static_replace
import
replace_static_urls
from
courseware.access
import
has_access
from
courseware.access
import
has_access
import
branding
import
branding
from
xmodule.modulestore.exceptions
import
ItemNotFoundError
log
=
logging
.
getLogger
(
__name__
)
log
=
logging
.
getLogger
(
__name__
)
...
@@ -49,7 +48,8 @@ def get_course_by_id(course_id, depth=0):
...
@@ -49,7 +48,8 @@ def get_course_by_id(course_id, depth=0):
return
modulestore
()
.
get_instance
(
course_id
,
course_loc
,
depth
=
depth
)
return
modulestore
()
.
get_instance
(
course_id
,
course_loc
,
depth
=
depth
)
except
(
KeyError
,
ItemNotFoundError
):
except
(
KeyError
,
ItemNotFoundError
):
raise
Http404
(
"Course not found."
)
raise
Http404
(
"Course not found."
)
except
InvalidLocationError
:
raise
Http404
(
"Invalid location"
)
def
get_course_with_access
(
user
,
course_id
,
action
,
depth
=
0
):
def
get_course_with_access
(
user
,
course_id
,
action
,
depth
=
0
):
"""
"""
...
...
lms/djangoapps/courseware/tests/test_courses.py
0 → 100644
View file @
f7d6d149
# -*- coding: utf-8 -*-
from
django.test
import
TestCase
from
django.http
import
Http404
from
courseware.courses
import
get_course_by_id
class
CoursesTest
(
TestCase
):
def
test_get_course_by_id_invalid_chars
(
self
):
"""
Test that `get_course_by_id` throws a 404, rather than
an exception, when faced with unexpected characters
(such as unicode characters, and symbols such as = and ' ')
"""
with
self
.
assertRaises
(
Http404
):
get_course_by_id
(
'MITx/foobar/statistics=introduction'
)
get_course_by_id
(
'MITx/foobar/business and management'
)
get_course_by_id
(
'MITx/foobar/NiñøJoséMaríáßç'
)
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