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
1f774c99
Commit
1f774c99
authored
Dec 01, 2014
by
John Eskew
Committed by
Zia Fazal
Apr 07, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
When fill_in_run() fails, handle failure instead of exception.
parent
135a1bc5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
7 deletions
+19
-7
common/lib/xmodule/xmodule/modulestore/mongo/base.py
+11
-6
common/lib/xmodule/xmodule/modulestore/tests/test_mongo.py
+8
-1
No files found.
common/lib/xmodule/xmodule/modulestore/mongo/base.py
View file @
1f774c99
...
@@ -1495,9 +1495,16 @@ class MongoModuleStore(ModuleStoreDraftAndPublished, ModuleStoreWriteBase, Mongo
...
@@ -1495,9 +1495,16 @@ class MongoModuleStore(ModuleStoreDraftAndPublished, ModuleStoreWriteBase, Mongo
# Using the course_key, find or insert the course asset metadata document.
# Using the course_key, find or insert the course asset metadata document.
# A single document exists per course to store the course asset metadata.
# A single document exists per course to store the course asset metadata.
course_key
=
self
.
fill_in_run
(
course_key
)
course_key
=
self
.
fill_in_run
(
course_key
)
course_assets
=
self
.
asset_collection
.
find_one
(
if
course_key
.
run
is
None
:
{
'course_id'
:
unicode
(
course_key
)},
log
.
warning
(
u'No run found for combo org "{}" course "{}" on asset request.'
.
format
(
)
course_key
.
org
,
course_key
.
course
))
course_assets
=
None
else
:
# Complete course key, so query for asset metadata.
course_assets
=
self
.
asset_collection
.
find_one
(
{
'course_id'
:
unicode
(
course_key
)},
)
doc_id
=
None
if
course_assets
is
None
else
course_assets
[
'_id'
]
doc_id
=
None
if
course_assets
is
None
else
course_assets
[
'_id'
]
if
course_assets
is
None
:
if
course_assets
is
None
:
...
@@ -1616,9 +1623,7 @@ class MongoModuleStore(ModuleStoreDraftAndPublished, ModuleStoreWriteBase, Mongo
...
@@ -1616,9 +1623,7 @@ class MongoModuleStore(ModuleStoreDraftAndPublished, ModuleStoreWriteBase, Mongo
dest_course_key (CourseKey): identifier of course to copy to
dest_course_key (CourseKey): identifier of course to copy to
"""
"""
source_assets
=
self
.
_find_course_assets
(
source_course_key
)
source_assets
=
self
.
_find_course_assets
(
source_course_key
)
dest_assets
=
{
'assets'
:
source_assets
.
asset_md
.
copy
()}
dest_assets
=
{
'assets'
:
source_assets
.
asset_md
.
copy
(),
'course_id'
:
unicode
(
dest_course_key
)}
dest_assets
[
'course_id'
]
=
unicode
(
dest_course_key
)
self
.
asset_collection
.
remove
({
'course_id'
:
unicode
(
dest_course_key
)})
self
.
asset_collection
.
remove
({
'course_id'
:
unicode
(
dest_course_key
)})
# Update the document.
# Update the document.
self
.
asset_collection
.
insert
(
dest_assets
)
self
.
asset_collection
.
insert
(
dest_assets
)
...
...
common/lib/xmodule/xmodule/modulestore/tests/test_mongo.py
View file @
1f774c99
...
@@ -29,7 +29,7 @@ from xmodule.modulestore import ModuleStoreEnum
...
@@ -29,7 +29,7 @@ from xmodule.modulestore import ModuleStoreEnum
from
xmodule.modulestore.mongo
import
MongoKeyValueStore
from
xmodule.modulestore.mongo
import
MongoKeyValueStore
from
xmodule.modulestore.draft
import
DraftModuleStore
from
xmodule.modulestore.draft
import
DraftModuleStore
from
opaque_keys.edx.locations
import
SlashSeparatedCourseKey
,
AssetLocation
from
opaque_keys.edx.locations
import
SlashSeparatedCourseKey
,
AssetLocation
from
opaque_keys.edx.locator
import
LibraryLocator
from
opaque_keys.edx.locator
import
LibraryLocator
,
CourseLocator
from
opaque_keys.edx.keys
import
UsageKey
from
opaque_keys.edx.keys
import
UsageKey
from
xmodule.modulestore.xml_exporter
import
export_to_xml
from
xmodule.modulestore.xml_exporter
import
export_to_xml
from
xmodule.modulestore.xml_importer
import
import_from_xml
,
perform_xlint
from
xmodule.modulestore.xml_importer
import
import_from_xml
,
perform_xlint
...
@@ -42,6 +42,8 @@ from xmodule.x_module import XModuleMixin
...
@@ -42,6 +42,8 @@ from xmodule.x_module import XModuleMixin
from
xmodule.modulestore.mongo.base
import
as_draft
from
xmodule.modulestore.mongo.base
import
as_draft
from
xmodule.modulestore.tests.mongo_connection
import
MONGO_PORT_NUM
,
MONGO_HOST
from
xmodule.modulestore.tests.mongo_connection
import
MONGO_PORT_NUM
,
MONGO_HOST
from
xmodule.modulestore.edit_info
import
EditInfoMixin
from
xmodule.modulestore.edit_info
import
EditInfoMixin
from
xmodule.modulestore.exceptions
import
ItemNotFoundError
log
=
logging
.
getLogger
(
__name__
)
log
=
logging
.
getLogger
(
__name__
)
...
@@ -701,6 +703,11 @@ class TestMongoModuleStoreWithNoAssetCollection(TestMongoModuleStore):
...
@@ -701,6 +703,11 @@ class TestMongoModuleStoreWithNoAssetCollection(TestMongoModuleStore):
# Confirm that no specified asset collection name means empty asset metadata.
# Confirm that no specified asset collection name means empty asset metadata.
self
.
assertEquals
(
self
.
draft_store
.
get_all_asset_metadata
(
course
.
id
,
'asset'
),
[])
self
.
assertEquals
(
self
.
draft_store
.
get_all_asset_metadata
(
course
.
id
,
'asset'
),
[])
def
test_no_asset_invalid_key
(
self
):
course_key
=
CourseLocator
(
org
=
"edx3"
,
course
=
"test_course"
,
run
=
None
,
deprecated
=
True
)
# Confirm that invalid course key raises ItemNotFoundError
self
.
assertRaises
(
ItemNotFoundError
,
lambda
:
self
.
draft_store
.
get_all_asset_metadata
(
course_key
,
'asset'
)[:
1
])
class
TestMongoKeyValueStore
(
object
):
class
TestMongoKeyValueStore
(
object
):
"""
"""
...
...
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