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
82af8d4b
Commit
82af8d4b
authored
Sep 25, 2013
by
Don Mitchell
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1124 from edx/dhm/asset_policy
Just write the loc name as the key in the policy file
parents
47621b56
f9328814
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
15 deletions
+44
-15
cms/djangoapps/contentstore/tests/test_contentstore.py
+42
-13
common/lib/xmodule/xmodule/contentstore/mongo.py
+1
-1
common/lib/xmodule/xmodule/modulestore/xml_importer.py
+1
-1
No files found.
cms/djangoapps/contentstore/tests/test_contentstore.py
View file @
82af8d4b
...
@@ -999,13 +999,33 @@ class ContentStoreToyCourseTest(ModuleStoreTestCase):
...
@@ -999,13 +999,33 @@ class ContentStoreToyCourseTest(ModuleStoreTestCase):
# remove old course
# remove old course
delete_course
(
module_store
,
content_store
,
location
,
commit
=
True
)
delete_course
(
module_store
,
content_store
,
location
,
commit
=
True
)
# reimport over old course
stub_location
=
Location
([
'i4x'
,
'edX'
,
'toy'
,
None
,
None
])
course_location
=
course
.
location
self
.
check_import
(
module_store
,
root_dir
,
draft_store
,
content_store
,
stub_location
,
course_location
,
locked_asset
,
locked_asset_attrs
)
# import to different course id
stub_location
=
Location
([
'i4x'
,
'anotherX'
,
'anotherToy'
,
None
,
None
])
course_location
=
stub_location
.
replace
(
category
=
'course'
,
name
=
'Someday'
)
self
.
check_import
(
module_store
,
root_dir
,
draft_store
,
content_store
,
stub_location
,
course_location
,
locked_asset
,
locked_asset_attrs
)
shutil
.
rmtree
(
root_dir
)
def
check_import
(
self
,
module_store
,
root_dir
,
draft_store
,
content_store
,
stub_location
,
course_location
,
locked_asset
,
locked_asset_attrs
):
# reimport
# reimport
import_from_xml
(
import_from_xml
(
module_store
,
root_dir
,
[
'test_export'
],
draft_store
=
draft_store
,
static_content_store
=
content_store
module_store
,
root_dir
,
[
'test_export'
],
draft_store
=
draft_store
,
static_content_store
=
content_store
,
target_location_namespace
=
course_location
)
)
items
=
module_store
.
get_items
(
Location
([
'i4x'
,
'edX'
,
'toy'
,
'vertical'
,
None
]
))
items
=
module_store
.
get_items
(
stub_location
.
replace
(
category
=
'vertical'
,
name
=
None
))
self
.
assertGreater
(
len
(
items
),
0
)
self
.
assertGreater
(
len
(
items
),
0
)
for
descriptor
in
items
:
for
descriptor
in
items
:
# don't try to look at private verticals. Right now we're running
# don't try to look at private verticals. Right now we're running
...
@@ -1016,11 +1036,13 @@ class ContentStoreToyCourseTest(ModuleStoreTestCase):
...
@@ -1016,11 +1036,13 @@ class ContentStoreToyCourseTest(ModuleStoreTestCase):
self
.
assertEqual
(
resp
.
status_code
,
200
)
self
.
assertEqual
(
resp
.
status_code
,
200
)
# verify that we have the content in the draft store as well
# verify that we have the content in the draft store as well
vertical
=
draft_store
.
get_item
(
Location
([
'i4x'
,
'edX'
,
'toy'
,
vertical
=
draft_store
.
get_item
(
'vertical'
,
'vertical_test'
,
None
]),
depth
=
1
)
stub_location
.
replace
(
category
=
'vertical'
,
name
=
'vertical_test'
,
revision
=
None
),
depth
=
1
)
self
.
assertTrue
(
getattr
(
vertical
,
'is_draft'
,
False
))
self
.
assertTrue
(
getattr
(
vertical
,
'is_draft'
,
False
))
self
.
assertNotIn
(
'index_in_children_list'
,
child
.
xml_attributes
)
self
.
assertNotIn
(
'index_in_children_list'
,
vertical
.
xml_attributes
)
self
.
assertNotIn
(
'parent_sequential_url'
,
vertical
.
xml_attributes
)
self
.
assertNotIn
(
'parent_sequential_url'
,
vertical
.
xml_attributes
)
for
child
in
vertical
.
get_children
():
for
child
in
vertical
.
get_children
():
...
@@ -1033,27 +1055,34 @@ class ContentStoreToyCourseTest(ModuleStoreTestCase):
...
@@ -1033,27 +1055,34 @@ class ContentStoreToyCourseTest(ModuleStoreTestCase):
self
.
assertNotIn
(
'parent_sequential_url'
,
child
.
data
)
self
.
assertNotIn
(
'parent_sequential_url'
,
child
.
data
)
# make sure that we don't have a sequential that is in draft mode
# make sure that we don't have a sequential that is in draft mode
sequential
=
draft_store
.
get_item
(
Location
([
'i4x'
,
'edX'
,
'toy'
,
sequential
=
draft_store
.
get_item
(
'sequential'
,
'vertical_sequential'
,
None
]))
stub_location
.
replace
(
category
=
'sequential'
,
name
=
'vertical_sequential'
,
revision
=
None
)
)
self
.
assertFalse
(
getattr
(
sequential
,
'is_draft'
,
False
))
self
.
assertFalse
(
getattr
(
sequential
,
'is_draft'
,
False
))
# verify that we have the private vertical
# verify that we have the private vertical
test_private_vertical
=
draft_store
.
get_item
(
Location
([
'i4x'
,
'edX'
,
'toy'
,
test_private_vertical
=
draft_store
.
get_item
(
'vertical'
,
'a_private_vertical'
,
None
]))
stub_location
.
replace
(
category
=
'vertical'
,
name
=
'a_private_vertical'
,
revision
=
None
)
)
self
.
assertTrue
(
getattr
(
test_private_vertical
,
'is_draft'
,
False
))
self
.
assertTrue
(
getattr
(
test_private_vertical
,
'is_draft'
,
False
))
# make sure the textbook survived the export/import
# make sure the textbook survived the export/import
course
=
module_store
.
get_item
(
Location
([
'i4x'
,
'edX'
,
'toy'
,
'course'
,
'2012_Fall'
,
None
])
)
course
=
module_store
.
get_item
(
course_location
)
self
.
assertGreater
(
len
(
course
.
textbooks
),
0
)
self
.
assertGreater
(
len
(
course
.
textbooks
),
0
)
locked_asset
[
'course'
]
=
stub_location
.
course
locked_asset
[
'org'
]
=
stub_location
.
org
new_attrs
=
content_store
.
get_attrs
(
locked_asset
)
new_attrs
=
content_store
.
get_attrs
(
locked_asset
)
for
key
,
value
in
locked_asset_attrs
.
iteritems
():
for
key
,
value
in
locked_asset_attrs
.
iteritems
():
self
.
assertEqual
(
value
,
new_attrs
[
key
])
if
key
==
'_id'
:
self
.
assertEqual
(
value
[
'name'
],
new_attrs
[
key
][
'name'
])
shutil
.
rmtree
(
root_dir
)
elif
key
==
'filename'
:
pass
else
:
self
.
assertEqual
(
value
,
new_attrs
[
key
])
def
test_export_course_with_metadata_only_video
(
self
):
def
test_export_course_with_metadata_only_video
(
self
):
module_store
=
modulestore
(
'direct'
)
module_store
=
modulestore
(
'direct'
)
...
...
common/lib/xmodule/xmodule/contentstore/mongo.py
View file @
82af8d4b
...
@@ -122,7 +122,7 @@ class MongoContentStore(ContentStore):
...
@@ -122,7 +122,7 @@ class MongoContentStore(ContentStore):
self
.
export
(
asset_location
,
output_directory
)
self
.
export
(
asset_location
,
output_directory
)
for
attr
,
value
in
asset
.
iteritems
():
for
attr
,
value
in
asset
.
iteritems
():
if
attr
not
in
[
'_id'
,
'md5'
,
'uploadDate'
,
'length'
,
'chunkSize'
]:
if
attr
not
in
[
'_id'
,
'md5'
,
'uploadDate'
,
'length'
,
'chunkSize'
]:
policy
.
setdefault
(
asset_location
.
url
()
,
{})[
attr
]
=
value
policy
.
setdefault
(
asset_location
.
name
,
{})[
attr
]
=
value
with
open
(
assets_policy_file
,
'w'
)
as
f
:
with
open
(
assets_policy_file
,
'w'
)
as
f
:
json
.
dump
(
policy
,
f
)
json
.
dump
(
policy
,
f
)
...
...
common/lib/xmodule/xmodule/modulestore/xml_importer.py
View file @
82af8d4b
...
@@ -56,7 +56,7 @@ def import_static_content(modules, course_loc, course_data_path, static_content_
...
@@ -56,7 +56,7 @@ def import_static_content(modules, course_loc, course_data_path, static_content_
content_loc
=
StaticContent
.
compute_location
(
target_location_namespace
.
org
,
target_location_namespace
.
course
,
fullname_with_subpath
)
content_loc
=
StaticContent
.
compute_location
(
target_location_namespace
.
org
,
target_location_namespace
.
course
,
fullname_with_subpath
)
policy_ele
=
policy
.
get
(
content_loc
.
url
()
,
{})
policy_ele
=
policy
.
get
(
content_loc
.
name
,
{})
displayname
=
policy_ele
.
get
(
'displayname'
,
filename
)
displayname
=
policy_ele
.
get
(
'displayname'
,
filename
)
locked
=
policy_ele
.
get
(
'locked'
,
False
)
locked
=
policy_ele
.
get
(
'locked'
,
False
)
mime_type
=
policy_ele
.
get
(
'contentType'
,
mimetypes
.
guess_type
(
filename
)[
0
])
mime_type
=
policy_ele
.
get
(
'contentType'
,
mimetypes
.
guess_type
(
filename
)[
0
])
...
...
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