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
6c3563cc
Commit
6c3563cc
authored
Jun 28, 2013
by
Ned Batchelder
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simple refactoring and reformatting of the view code.
parent
b5aebf0e
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
29 deletions
+34
-29
lms/djangoapps/staticbook/views.py
+34
-29
No files found.
lms/djangoapps/staticbook/views.py
View file @
6c3563cc
...
@@ -22,20 +22,37 @@ def index(request, course_id, book_index, page=None):
...
@@ -22,20 +22,37 @@ def index(request, course_id, book_index, page=None):
if
page
is
None
:
if
page
is
None
:
page
=
textbook
.
start_page
page
=
textbook
.
start_page
return
render_to_response
(
'staticbook.html'
,
return
render_to_response
(
{
'book_index'
:
book_index
,
'page'
:
int
(
page
),
'staticbook.html'
,
{
'book_index'
:
book_index
,
'page'
:
int
(
page
),
'course'
:
course
,
'course'
:
course
,
'book_url'
:
textbook
.
book_url
,
'book_url'
:
textbook
.
book_url
,
'table_of_contents'
:
table_of_contents
,
'table_of_contents'
:
table_of_contents
,
'start_page'
:
textbook
.
start_page
,
'start_page'
:
textbook
.
start_page
,
'end_page'
:
textbook
.
end_page
,
'end_page'
:
textbook
.
end_page
,
'staff_access'
:
staff_access
})
'staff_access'
:
staff_access
,
},
)
def
index_shifted
(
request
,
course_id
,
page
):
def
index_shifted
(
request
,
course_id
,
page
):
return
index
(
request
,
course_id
=
course_id
,
page
=
int
(
page
)
+
24
)
return
index
(
request
,
course_id
=
course_id
,
page
=
int
(
page
)
+
24
)
def
remap_static_url
(
original_url
,
course
):
"""Remap a URL in the ways the course requires."""
# Ick: this should be possible without having to quote and unquote the URL...
input_url
=
"'"
+
original_url
+
"'"
output_url
=
replace_static_urls
(
input_url
,
getattr
(
course
,
'data_dir'
,
None
),
course_namespace
=
course
.
location
,
)
# strip off the quotes again...
return
output_url
[
1
:
-
1
]
@login_required
@login_required
def
pdf_index
(
request
,
course_id
,
book_index
,
chapter
=
None
,
page
=
None
):
def
pdf_index
(
request
,
course_id
,
book_index
,
chapter
=
None
,
page
=
None
):
"""
"""
...
@@ -60,16 +77,6 @@ def pdf_index(request, course_id, book_index, chapter=None, page=None):
...
@@ -60,16 +77,6 @@ def pdf_index(request, course_id, book_index, chapter=None, page=None):
raise
Http404
(
"Invalid book index value: {0}"
.
format
(
book_index
))
raise
Http404
(
"Invalid book index value: {0}"
.
format
(
book_index
))
textbook
=
course
.
pdf_textbooks
[
book_index
]
textbook
=
course
.
pdf_textbooks
[
book_index
]
def
remap_static_url
(
original_url
,
course
):
input_url
=
"'"
+
original_url
+
"'"
output_url
=
replace_static_urls
(
input_url
,
getattr
(
course
,
'data_dir'
,
None
),
course_namespace
=
course
.
location
)
# strip off the quotes again...
return
output_url
[
1
:
-
1
]
if
'url'
in
textbook
:
if
'url'
in
textbook
:
textbook
[
'url'
]
=
remap_static_url
(
textbook
[
'url'
],
course
)
textbook
[
'url'
]
=
remap_static_url
(
textbook
[
'url'
],
course
)
# then remap all the chapter URLs as well, if they are provided.
# then remap all the chapter URLs as well, if they are provided.
...
@@ -77,13 +84,17 @@ def pdf_index(request, course_id, book_index, chapter=None, page=None):
...
@@ -77,13 +84,17 @@ def pdf_index(request, course_id, book_index, chapter=None, page=None):
for
entry
in
textbook
[
'chapters'
]:
for
entry
in
textbook
[
'chapters'
]:
entry
[
'url'
]
=
remap_static_url
(
entry
[
'url'
],
course
)
entry
[
'url'
]
=
remap_static_url
(
entry
[
'url'
],
course
)
return
render_to_response
(
'static_pdfbook.html'
,
return
render_to_response
(
{
'book_index'
:
book_index
,
'static_pdfbook.html'
,
{
'book_index'
:
book_index
,
'course'
:
course
,
'course'
:
course
,
'textbook'
:
textbook
,
'textbook'
:
textbook
,
'chapter'
:
chapter
,
'chapter'
:
chapter
,
'page'
:
page
,
'page'
:
page
,
'staff_access'
:
staff_access
})
'staff_access'
:
staff_access
,
},
)
@login_required
@login_required
...
@@ -109,16 +120,6 @@ def html_index(request, course_id, book_index, chapter=None):
...
@@ -109,16 +120,6 @@ def html_index(request, course_id, book_index, chapter=None):
raise
Http404
(
"Invalid book index value: {0}"
.
format
(
book_index
))
raise
Http404
(
"Invalid book index value: {0}"
.
format
(
book_index
))
textbook
=
course
.
html_textbooks
[
book_index
]
textbook
=
course
.
html_textbooks
[
book_index
]
def
remap_static_url
(
original_url
,
course
):
input_url
=
"'"
+
original_url
+
"'"
output_url
=
replace_static_urls
(
input_url
,
getattr
(
course
,
'data_dir'
,
None
),
course_namespace
=
course
.
location
)
# strip off the quotes again...
return
output_url
[
1
:
-
1
]
if
'url'
in
textbook
:
if
'url'
in
textbook
:
textbook
[
'url'
]
=
remap_static_url
(
textbook
[
'url'
],
course
)
textbook
[
'url'
]
=
remap_static_url
(
textbook
[
'url'
],
course
)
# then remap all the chapter URLs as well, if they are provided.
# then remap all the chapter URLs as well, if they are provided.
...
@@ -126,10 +127,14 @@ def html_index(request, course_id, book_index, chapter=None):
...
@@ -126,10 +127,14 @@ def html_index(request, course_id, book_index, chapter=None):
for
entry
in
textbook
[
'chapters'
]:
for
entry
in
textbook
[
'chapters'
]:
entry
[
'url'
]
=
remap_static_url
(
entry
[
'url'
],
course
)
entry
[
'url'
]
=
remap_static_url
(
entry
[
'url'
],
course
)
return
render_to_response
(
'static_htmlbook.html'
,
return
render_to_response
(
{
'book_index'
:
book_index
,
'static_htmlbook.html'
,
{
'book_index'
:
book_index
,
'course'
:
course
,
'course'
:
course
,
'textbook'
:
textbook
,
'textbook'
:
textbook
,
'chapter'
:
chapter
,
'chapter'
:
chapter
,
'staff_access'
:
staff_access
,
'staff_access'
:
staff_access
,
'notes_enabled'
:
notes_enabled
})
'notes_enabled'
:
notes_enabled
,
},
)
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