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
54e1faea
Commit
54e1faea
authored
May 28, 2014
by
David Adams
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3394 from edx/dcadams/parse_query_params
Parse urls with query params for ^/static
parents
ac26130e
384bac2f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
5 deletions
+22
-5
common/djangoapps/static_replace/test/test_static_replace.py
+5
-3
common/lib/xmodule/xmodule/contentstore/content.py
+17
-2
No files found.
common/djangoapps/static_replace/test/test_static_replace.py
View file @
54e1faea
...
...
@@ -95,13 +95,15 @@ def test_raw_static_check():
@patch
(
'static_replace.modulestore'
)
def
test_static_url_with_query
(
mock_modulestore
,
mock_storage
):
"""
Make sure urls with query have the parameter section unaltered
Make sure that for urls with query params:
query params that contain "^/static/" are converted to full location urls
query params that do not contain "^/static/" are left unchanged
"""
mock_storage
.
exists
.
return_value
=
False
mock_modulestore
.
return_value
=
Mock
(
MongoModuleStore
)
pre_text
=
'EMBED src ="/static/LAlec04_controller.swf?csConfigFile=/
c4x/org/course/asset/LAlec04_config.xml
"'
post_text
=
'EMBED src ="/c4x/org/course/asset/LAlec04_controller.swf?csConfigFile=
/c4x/org/course/asset/LAlec04_config.xml
"'
pre_text
=
'EMBED src ="/static/LAlec04_controller.swf?csConfigFile=/
static/LAlec04_config.xml&name1=value1&name2=value2
"'
post_text
=
'EMBED src ="/c4x/org/course/asset/LAlec04_controller.swf?csConfigFile=
%2
Fc4x
%2
Forg
%2
Fcourse
%2
Fasset
%2
FLAlec04_config.xml&name1=value1&name2=value2
"'
assert_equals
(
post_text
,
replace_static_urls
(
pre_text
,
DATA_DIRECTORY
,
COURSE_KEY
))
...
...
common/lib/xmodule/xmodule/contentstore/content.py
View file @
54e1faea
...
...
@@ -7,7 +7,8 @@ XASSET_THUMBNAIL_TAIL_NAME = '.jpg'
import
os
import
logging
import
StringIO
from
urlparse
import
urlparse
,
urlunparse
from
urlparse
import
urlparse
,
urlunparse
,
parse_qsl
from
urllib
import
urlencode
from
xmodule.modulestore.locations
import
AssetLocation
,
SlashSeparatedCourseKey
from
.django
import
contentstore
...
...
@@ -123,8 +124,22 @@ class StaticContent(object):
loc
=
StaticContent
.
compute_location
(
course_id
,
orig_path
)
loc_url
=
loc
.
to_deprecated_string
()
# parse the query params for "^/static/" and replace with the location url
orig_query
=
parse_qsl
(
query
)
new_query_list
=
[]
for
query_name
,
query_value
in
orig_query
:
if
query_value
.
startswith
(
"/static/"
):
new_query
=
StaticContent
.
compute_location
(
course_id
,
query_value
[
len
(
'/static/'
):],
)
new_query_url
=
new_query
.
to_deprecated_string
()
new_query_list
.
append
((
query_name
,
new_query_url
))
else
:
new_query_list
.
append
((
query_name
,
query_value
))
# Reconstruct with new path
return
urlunparse
((
scheme
,
netloc
,
loc_url
,
params
,
query
,
fragment
))
return
urlunparse
((
scheme
,
netloc
,
loc_url
,
params
,
urlencode
(
new_query_list
)
,
fragment
))
def
stream_data
(
self
):
yield
self
.
_data
...
...
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