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
692c4236
Commit
692c4236
authored
Mar 05, 2013
by
chrisndodge
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1600 from MITx/bug/christina/misc
Don't collapse multiple underscores for asset names.
parents
5b315844
cc234d45
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
4 deletions
+21
-4
common/lib/xmodule/xmodule/contentstore/content.py
+2
-1
common/lib/xmodule/xmodule/modulestore/__init__.py
+11
-0
common/lib/xmodule/xmodule/tests/test_content.py
+8
-3
No files found.
common/lib/xmodule/xmodule/contentstore/content.py
View file @
692c4236
...
@@ -35,7 +35,8 @@ class StaticContent(object):
...
@@ -35,7 +35,8 @@ class StaticContent(object):
@staticmethod
@staticmethod
def
compute_location
(
org
,
course
,
name
,
revision
=
None
,
is_thumbnail
=
False
):
def
compute_location
(
org
,
course
,
name
,
revision
=
None
,
is_thumbnail
=
False
):
name
=
name
.
replace
(
'/'
,
'_'
)
name
=
name
.
replace
(
'/'
,
'_'
)
return
Location
([
XASSET_LOCATION_TAG
,
org
,
course
,
'asset'
if
not
is_thumbnail
else
'thumbnail'
,
Location
.
clean
(
name
),
revision
])
return
Location
([
XASSET_LOCATION_TAG
,
org
,
course
,
'asset'
if
not
is_thumbnail
else
'thumbnail'
,
Location
.
clean_keeping_underscores
(
name
),
revision
])
def
get_id
(
self
):
def
get_id
(
self
):
return
StaticContent
.
get_id_from_location
(
self
.
location
)
return
StaticContent
.
get_id_from_location
(
self
.
location
)
...
...
common/lib/xmodule/xmodule/modulestore/__init__.py
View file @
692c4236
...
@@ -71,6 +71,17 @@ class Location(_LocationBase):
...
@@ -71,6 +71,17 @@ class Location(_LocationBase):
"""
"""
return
Location
.
_clean
(
value
,
INVALID_CHARS
)
return
Location
.
_clean
(
value
,
INVALID_CHARS
)
@staticmethod
def
clean_keeping_underscores
(
value
):
"""
Return value, replacing INVALID_CHARS, but not collapsing multiple '_' chars.
This for cleaning asset names, as the YouTube ID's may have underscores in them, and we need the
transcript asset name to match. In the future we may want to change the behavior of _clean.
"""
return
INVALID_CHARS
.
sub
(
'_'
,
value
)
@staticmethod
@staticmethod
def
clean_for_url_name
(
value
):
def
clean_for_url_name
(
value
):
"""
"""
...
...
common/lib/xmodule/xmodule/tests/test_content.py
View file @
692c4236
...
@@ -19,9 +19,14 @@ class ContentTest(unittest.TestCase):
...
@@ -19,9 +19,14 @@ class ContentTest(unittest.TestCase):
content
=
StaticContent
(
'loc'
,
'name'
,
'content_type'
,
'data'
)
content
=
StaticContent
(
'loc'
,
'name'
,
'content_type'
,
'data'
)
self
.
assertIsNone
(
content
.
thumbnail_location
)
self
.
assertIsNone
(
content
.
thumbnail_location
)
def
test_generate_thumbnail_
non
image
(
self
):
def
test_generate_thumbnail_image
(
self
):
contentStore
=
ContentStore
()
contentStore
=
ContentStore
()
content
=
Content
(
Location
(
u'c4x'
,
u'mitX'
,
u'800'
,
u'asset'
,
u'monsters.jpg'
),
None
)
content
=
Content
(
Location
(
u'c4x'
,
u'mitX'
,
u'800'
,
u'asset'
,
u'monsters
__
.jpg'
),
None
)
(
thumbnail_content
,
thumbnail_file_location
)
=
contentStore
.
generate_thumbnail
(
content
)
(
thumbnail_content
,
thumbnail_file_location
)
=
contentStore
.
generate_thumbnail
(
content
)
self
.
assertIsNone
(
thumbnail_content
)
self
.
assertIsNone
(
thumbnail_content
)
self
.
assertEqual
(
Location
(
u'c4x'
,
u'mitX'
,
u'800'
,
u'thumbnail'
,
u'monsters.jpg'
),
thumbnail_file_location
)
self
.
assertEqual
(
Location
(
u'c4x'
,
u'mitX'
,
u'800'
,
u'thumbnail'
,
u'monsters__.jpg'
),
thumbnail_file_location
)
def
test_compute_location
(
self
):
# We had a bug that __ got converted into a single _. Make sure that substitution of INVALID_CHARS (like space)
# still happen.
asset_location
=
StaticContent
.
compute_location
(
'mitX'
,
'400'
,
'subs__1eo_jXvZnE .srt.sjson'
)
self
.
assertEqual
(
Location
(
u'c4x'
,
u'mitX'
,
u'400'
,
u'asset'
,
u'subs__1eo_jXvZnE_.srt.sjson'
,
None
),
asset_location
)
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