Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
edx-platform-release
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hsin-Yu Chien
edx-platform-release
Commits
02a24716
Commit
02a24716
authored
11 years ago
by
Sarina Canelake
Browse files
Options
Downloads
Plain Diff
Merge pull request #278 from edx/sarina/fix-modulestore-500s
Catch InvalidLocationError
parents
2b6d338d
f7d6d149
Loading
Loading
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lms/djangoapps/courseware/courses.py
+3
-3
3 additions, 3 deletions
lms/djangoapps/courseware/courses.py
lms/djangoapps/courseware/tests/test_courses.py
+16
-0
16 additions, 0 deletions
lms/djangoapps/courseware/tests/test_courses.py
with
19 additions
and
3 deletions
lms/djangoapps/courseware/courses.py
+
3
−
3
View file @
02a24716
...
...
@@ -12,12 +12,11 @@ from xmodule.modulestore import Location
from
xmodule.modulestore.django
import
modulestore
from
xmodule.contentstore.content
import
StaticContent
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
static_replace
import
replace_static_urls
from
courseware.access
import
has_access
import
branding
from
xmodule.modulestore.exceptions
import
ItemNotFoundError
log
=
logging
.
getLogger
(
__name__
)
...
...
@@ -49,7 +48,8 @@ def get_course_by_id(course_id, depth=0):
return
modulestore
().
get_instance
(
course_id
,
course_loc
,
depth
=
depth
)
except
(
KeyError
,
ItemNotFoundError
):
raise
Http404
(
"
Course not found.
"
)
except
InvalidLocationError
:
raise
Http404
(
"
Invalid location
"
)
def
get_course_with_access
(
user
,
course_id
,
action
,
depth
=
0
):
"""
...
...
This diff is collapsed.
Click to expand it.
lms/djangoapps/courseware/tests/test_courses.py
0 → 100644
+
16
−
0
View file @
02a24716
# -*- 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íáßç
'
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment