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
d46ea873
Commit
d46ea873
authored
Mar 03, 2016
by
Awais Jibran
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #11656 from attiyaIshaque/ai/tnl3848-list-index-out-of-range
Fix list index out of range in Textbook's chapters.
parents
a0871900
99e717fb
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
1 deletions
+12
-1
lms/djangoapps/staticbook/tests.py
+11
-0
lms/djangoapps/staticbook/views.py
+1
-1
No files found.
lms/djangoapps/staticbook/tests.py
View file @
d46ea873
...
...
@@ -227,6 +227,17 @@ class StaticPdfBookTest(StaticBookTest):
self
.
assertContains
(
response
,
'file=/static/awesomesauce/{}'
.
format
(
PORTABLE_PDF_BOOK
[
'chapters'
][
0
][
'url'
]
.
replace
(
'/static/'
,
''
)))
def
test_invalid_chapter_id
(
self
):
"""
Test that 1st chapter is displayed to the user when an invalid chapter id is provided
"""
self
.
make_course
(
pdf_textbooks
=
[
PDF_BOOK
])
invalid_chapter
=
len
(
PDF_BOOK
[
'chapters'
])
+
1
url
=
self
.
make_url
(
'pdf_book'
,
book_index
=
0
,
chapter
=
invalid_chapter
)
response
=
self
.
client
.
get
(
url
)
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertContains
(
response
,
"Chapter 1 for PDF"
)
class
StaticHtmlBookTest
(
StaticBookTest
):
"""
...
...
lms/djangoapps/staticbook/views.py
View file @
d46ea873
...
...
@@ -99,7 +99,7 @@ def pdf_index(request, course_id, book_index, chapter=None, page=None):
if
'chapters'
in
textbook
:
for
entry
in
textbook
[
'chapters'
]:
entry
[
'url'
]
=
remap_static_url
(
entry
[
'url'
],
course
)
if
chapter
is
not
None
:
if
chapter
is
not
None
and
int
(
chapter
)
<=
(
len
(
textbook
[
'chapters'
]))
:
current_chapter
=
textbook
[
'chapters'
][
int
(
chapter
)
-
1
]
else
:
current_chapter
=
textbook
[
'chapters'
][
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