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
8918217d
Commit
8918217d
authored
Aug 19, 2014
by
Jonathan Piacenti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
path_to_location now returns 404 on orphaned items. Resolves LMS-9661.
parent
14de1a3f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
4 deletions
+17
-4
common/lib/xmodule/xmodule/modulestore/search.py
+3
-3
common/lib/xmodule/xmodule/modulestore/tests/test_mixed_modulestore.py
+14
-1
No files found.
common/lib/xmodule/xmodule/modulestore/search.py
View file @
8918217d
...
@@ -60,14 +60,14 @@ def path_to_location(modulestore, usage_key):
...
@@ -60,14 +60,14 @@ def path_to_location(modulestore, usage_key):
# Found it!
# Found it!
path
=
(
next_usage
,
path
)
path
=
(
next_usage
,
path
)
return
flatten
(
path
)
return
flatten
(
path
)
elif
parent
is
None
:
# Orphaned item.
return
None
# otherwise, add parent locations at the end
# otherwise, add parent locations at the end
newpath
=
(
next_usage
,
path
)
newpath
=
(
next_usage
,
path
)
queue
.
append
((
parent
,
newpath
))
queue
.
append
((
parent
,
newpath
))
# If we're here, there is no path
return
None
if
not
modulestore
.
has_item
(
usage_key
):
if
not
modulestore
.
has_item
(
usage_key
):
raise
ItemNotFoundError
(
usage_key
)
raise
ItemNotFoundError
(
usage_key
)
...
...
common/lib/xmodule/xmodule/modulestore/tests/test_mixed_modulestore.py
View file @
8918217d
...
@@ -22,7 +22,8 @@ from opaque_keys.edx.locator import BlockUsageLocator, CourseLocator
...
@@ -22,7 +22,8 @@ from opaque_keys.edx.locator import BlockUsageLocator, CourseLocator
from
django.conf
import
settings
from
django.conf
import
settings
from
xmodule.modulestore.tests.factories
import
check_mongo_calls
from
xmodule.modulestore.tests.factories
import
check_mongo_calls
from
xmodule.modulestore.search
import
path_to_location
from
xmodule.modulestore.search
import
path_to_location
from
xmodule.modulestore.exceptions
import
DuplicateCourseError
from
xmodule.modulestore.exceptions
import
DuplicateCourseError
,
NoPathToItem
if
not
settings
.
configured
:
if
not
settings
.
configured
:
settings
.
configure
()
settings
.
configure
()
from
xmodule.modulestore.mixed
import
MixedModuleStore
from
xmodule.modulestore.mixed
import
MixedModuleStore
...
@@ -723,6 +724,18 @@ class TestMixedModuleStore(unittest.TestCase):
...
@@ -723,6 +724,18 @@ class TestMixedModuleStore(unittest.TestCase):
with
self
.
assertRaises
(
ItemNotFoundError
):
with
self
.
assertRaises
(
ItemNotFoundError
):
path_to_location
(
self
.
store
,
location
)
path_to_location
(
self
.
store
,
location
)
# Orphaned items should not be found.
orphan
=
course_key
.
make_usage_key
(
'chapter'
,
'OrphanChapter'
)
self
.
store
.
create_item
(
self
.
user_id
,
orphan
.
course_key
,
orphan
.
block_type
,
block_id
=
orphan
.
block_id
)
with
self
.
assertRaises
(
NoPathToItem
):
path_to_location
(
self
.
store
,
orphan
)
def
test_xml_path_to_location
(
self
):
def
test_xml_path_to_location
(
self
):
"""
"""
Make sure that path_to_location works: should be passed a modulestore
Make sure that path_to_location works: should be passed a modulestore
...
...
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