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
0a022e13
Commit
0a022e13
authored
Apr 25, 2014
by
David Baumgold
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3371 from carsongee/cg/pdf_textbook_urls
Switch PDF Textbooks to use portable URLs
parents
a4f4d7ba
6136ed2e
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
52 additions
and
14 deletions
+52
-14
cms/djangoapps/contentstore/features/textbooks.feature
+2
-2
cms/djangoapps/contentstore/tests/test_contentstore.py
+4
-4
cms/static/js/views/edit_chapter.js
+1
-1
common/lib/xmodule/xmodule/modulestore/xml_importer.py
+4
-3
lms/djangoapps/staticbook/tests.py
+40
-4
lms/djangoapps/staticbook/views.py
+1
-0
No files found.
cms/djangoapps/contentstore/features/textbooks.feature
View file @
0a022e13
...
...
@@ -19,9 +19,9 @@ Feature: CMS.Textbooks
And
I upload the textbook
"textbook.pdf"
And
I wait for
"2"
seconds
And
I save the textbook
Then
I should see a textbook named
"Economics"
with a chapter path containing
"/
c4x/MITx/999/asset
/textbook.pdf"
Then
I should see a textbook named
"Economics"
with a chapter path containing
"/
static
/textbook.pdf"
And
I reload the page
Then
I should see a textbook named
"Economics"
with a chapter path containing
"/
c4x/MITx/999/asset
/textbook.pdf"
Then
I should see a textbook named
"Economics"
with a chapter path containing
"/
static
/textbook.pdf"
Scenario
:
Create a textbook with multiple chapters
Given
I have opened a new course in Studio
...
...
cms/djangoapps/contentstore/tests/test_contentstore.py
View file @
0a022e13
...
...
@@ -1809,10 +1809,10 @@ class ContentStoreTest(ModuleStoreTestCase):
# first check PDF textbooks, to make sure the url paths got updated
course_module
=
module_store
.
get_instance
(
target_course_id
,
target_location
)
self
.
assertEqual
s
(
len
(
course_module
.
pdf_textbooks
),
1
)
self
.
assertEqual
s
(
len
(
course_module
.
pdf_textbooks
[
0
][
"chapters"
]),
2
)
self
.
assertEqual
s
(
course_module
.
pdf_textbooks
[
0
][
"chapters"
][
0
][
"url"
],
'/c4x/MITx/999/asset
/Chapter1.pdf'
)
self
.
assertEqual
s
(
course_module
.
pdf_textbooks
[
0
][
"chapters"
][
1
][
"url"
],
'/c4x/MITx/999/asset
/Chapter2.pdf'
)
self
.
assertEqual
(
len
(
course_module
.
pdf_textbooks
),
1
)
self
.
assertEqual
(
len
(
course_module
.
pdf_textbooks
[
0
][
"chapters"
]),
2
)
self
.
assertEqual
(
course_module
.
pdf_textbooks
[
0
][
"chapters"
][
0
][
"url"
],
'/static
/Chapter1.pdf'
)
self
.
assertEqual
(
course_module
.
pdf_textbooks
[
0
][
"chapters"
][
1
][
"url"
],
'/static
/Chapter2.pdf'
)
def
test_import_into_new_course_id_wiki_slug_renamespacing
(
self
):
module_store
=
modulestore
(
'direct'
)
...
...
cms/static/js/views/edit_chapter.js
View file @
0a022e13
...
...
@@ -65,7 +65,7 @@ define(["js/views/baseview", "underscore", "underscore.string", "jquery", "gette
if
(
!
that
.
model
.
get
(
'name'
))
{
options
.
name
=
response
.
asset
.
displayname
;
}
options
.
asset_path
=
response
.
asset
.
url
;
options
.
asset_path
=
response
.
asset
.
portable_
url
;
that
.
model
.
set
(
options
);
}
});
...
...
common/lib/xmodule/xmodule/modulestore/xml_importer.py
View file @
0a022e13
...
...
@@ -517,12 +517,13 @@ def remap_namespace(module, target_location_namespace):
# There is more re-namespacing work we have to do when
# importing course modules
# remap pdf_textbook urls
# remap pdf_textbook urls
to portable static URLs
for
entry
in
module
.
pdf_textbooks
:
for
chapter
in
entry
.
get
(
'chapters'
,
[]):
if
StaticContent
.
is_c4x_path
(
chapter
.
get
(
'url'
,
''
)):
chapter
[
'url'
]
=
StaticContent
.
renamespace_c4x_path
(
chapter
[
'url'
],
target_location_namespace
chapter_loc
=
StaticContent
.
get_location_from_path
(
chapter
[
'url'
])
chapter
[
'url'
]
=
StaticContent
.
get_static_path_from_location
(
chapter_loc
)
# Original wiki_slugs had value location.course. To make them unique this was changed to 'org.course.name'.
...
...
lms/djangoapps/staticbook/tests.py
View file @
0a022e13
...
...
@@ -22,8 +22,17 @@ PDF_BOOK = {
"tab_title"
:
"Textbook"
,
"title"
:
"A PDF Textbook"
,
"chapters"
:
[
{
"title"
:
"Chapter 1 for PDF"
,
"url"
:
"https://somehost.com/the_book/chap1.pdf"
},
{
"title"
:
"Chapter 2 for PDF"
,
"url"
:
"https://somehost.com/the_book/chap2.pdf"
},
{
"title"
:
"Chapter 1 for PDF"
,
"url"
:
"https://somehost.com/the_book/chap1.pdf"
},
{
"title"
:
"Chapter 2 for PDF"
,
"url"
:
"https://somehost.com/the_book/chap2.pdf"
},
],
}
PORTABLE_PDF_BOOK
=
{
"tab_title"
:
"Textbook"
,
"title"
:
"A PDF Textbook"
,
"chapters"
:
[
{
"title"
:
"Chapter 1 for PDF"
,
"url"
:
"/static/chap1.pdf"
},
{
"title"
:
"Chapter 2 for PDF"
,
"url"
:
"/static/chap2.pdf"
},
],
}
...
...
@@ -31,8 +40,8 @@ HTML_BOOK = {
"tab_title"
:
"Textbook"
,
"title"
:
"An HTML Textbook"
,
"chapters"
:
[
{
"title"
:
"Chapter 1 for HTML"
,
"url"
:
"https://somehost.com/the_book/chap1.html"
},
{
"title"
:
"Chapter 2 for HTML"
,
"url"
:
"https://somehost.com/the_book/chap2.html"
},
{
"title"
:
"Chapter 1 for HTML"
,
"url"
:
"https://somehost.com/the_book/chap1.html"
},
{
"title"
:
"Chapter 2 for HTML"
,
"url"
:
"https://somehost.com/the_book/chap2.html"
},
],
}
...
...
@@ -194,6 +203,33 @@ class StaticPdfBookTest(StaticBookTest):
with
self
.
assertRaises
(
NoReverseMatch
):
self
.
make_url
(
'pdf_book'
,
book_index
=
0
,
chapter
=
'fooey'
,
page
=
'xyzzy'
)
def
test_static_url_map_contentstore
(
self
):
"""
This ensure static URL mapping is happening properly for
a course that uses the contentstore
"""
self
.
make_course
(
pdf_textbooks
=
[
PORTABLE_PDF_BOOK
])
url
=
self
.
make_url
(
'pdf_book'
,
book_index
=
0
,
chapter
=
1
)
response
=
self
.
client
.
get
(
url
)
self
.
assertNotContains
(
response
,
'file={}'
.
format
(
PORTABLE_PDF_BOOK
[
'chapters'
][
0
][
'url'
]))
self
.
assertContains
(
response
,
'file=/c4x/{0.org}/{0.course}/asset/{1}'
.
format
(
self
.
course
.
location
,
PORTABLE_PDF_BOOK
[
'chapters'
][
0
][
'url'
]
.
replace
(
'/static/'
,
''
)))
def
test_static_url_map_static_asset_path
(
self
):
"""
Like above, but used when the course has set a static_asset_path
"""
self
.
make_course
(
pdf_textbooks
=
[
PORTABLE_PDF_BOOK
],
static_asset_path
=
'awesomesauce'
)
url
=
self
.
make_url
(
'pdf_book'
,
book_index
=
0
,
chapter
=
1
)
response
=
self
.
client
.
get
(
url
)
self
.
assertNotContains
(
response
,
'file={}'
.
format
(
PORTABLE_PDF_BOOK
[
'chapters'
][
0
][
'url'
]))
self
.
assertNotContains
(
response
,
'file=/c4x/{0.org}/{0.course}/asset/{1}'
.
format
(
self
.
course
.
location
,
PORTABLE_PDF_BOOK
[
'chapters'
][
0
][
'url'
]
.
replace
(
'/static/'
,
''
)))
self
.
assertContains
(
response
,
'file=/static/awesomesauce/{}'
.
format
(
PORTABLE_PDF_BOOK
[
'chapters'
][
0
][
'url'
]
.
replace
(
'/static/'
,
''
)))
class
StaticHtmlBookTest
(
StaticBookTest
):
"""
...
...
lms/djangoapps/staticbook/views.py
View file @
0a022e13
...
...
@@ -51,6 +51,7 @@ def remap_static_url(original_url, course):
input_url
,
getattr
(
course
,
'data_dir'
,
None
),
course_id
=
course
.
location
.
course_id
,
static_asset_path
=
course
.
static_asset_path
)
# strip off the quotes again...
return
output_url
[
1
:
-
1
]
...
...
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