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
8a86f401
Commit
8a86f401
authored
Jul 31, 2012
by
Victor Shnayder
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make courseware index view more bulletproof
parent
9c67005e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
26 deletions
+46
-26
lms/djangoapps/courseware/views.py
+46
-26
No files found.
lms/djangoapps/courseware/views.py
View file @
8a86f401
...
...
@@ -184,34 +184,54 @@ def index(request, course_id, chapter=None, section=None,
chapter
=
clean
(
chapter
)
section
=
clean
(
section
)
context
=
{
'csrf'
:
csrf
(
request
)[
'csrf_token'
],
'accordion'
:
render_accordion
(
request
,
course
,
chapter
,
section
),
'COURSE_TITLE'
:
course
.
title
,
'course'
:
course
,
'init'
:
''
,
'content'
:
''
}
look_for_module
=
chapter
is
not
None
and
section
is
not
None
if
look_for_module
:
# TODO (cpennington): Pass the right course in here
section_descriptor
=
get_section
(
course
,
chapter
,
section
)
if
section_descriptor
is
not
None
:
student_module_cache
=
StudentModuleCache
(
request
.
user
,
section_descriptor
)
module
,
_
,
_
,
_
=
get_module
(
request
.
user
,
request
,
section_descriptor
.
location
,
student_module_cache
)
context
[
'content'
]
=
module
.
get_html
()
try
:
context
=
{
'csrf'
:
csrf
(
request
)[
'csrf_token'
],
'accordion'
:
render_accordion
(
request
,
course
,
chapter
,
section
),
'COURSE_TITLE'
:
course
.
title
,
'course'
:
course
,
'init'
:
''
,
'content'
:
''
}
look_for_module
=
chapter
is
not
None
and
section
is
not
None
if
look_for_module
:
# TODO (cpennington): Pass the right course in here
section_descriptor
=
get_section
(
course
,
chapter
,
section
)
if
section_descriptor
is
not
None
:
student_module_cache
=
StudentModuleCache
(
request
.
user
,
section_descriptor
)
module
,
_
,
_
,
_
=
get_module
(
request
.
user
,
request
,
section_descriptor
.
location
,
student_module_cache
)
context
[
'content'
]
=
module
.
get_html
()
else
:
log
.
warning
(
"Couldn't find a section descriptor for course_id '{0}',"
"chapter '{1}', section '{2}'"
.
format
(
course_id
,
chapter
,
section
))
result
=
render_to_response
(
'courseware.html'
,
context
)
except
:
# In production, don't want to let a 500 out for any reason
if
settings
.
DEBUG
:
raise
else
:
log
.
warning
(
"Couldn't find a section descriptor for course_id '{0}',"
"chapter '{1}', section '{2}'"
.
format
(
course_id
,
chapter
,
section
))
log
.
exception
(
"Error in index view: user={user}, course={course},"
" chapter={chapter} section={section}"
"position={position}"
.
format
(
user
=
request
.
user
,
course
=
course
,
chapter
=
chapter
,
section
=
section
,
position
=
position
))
try
:
result
=
render_to_response
(
'courseware-error.html'
,
{})
except
:
result
=
HttpResponse
(
"There was an unrecoverable error"
)
result
=
render_to_response
(
'courseware.html'
,
context
)
return
result
@ensure_csrf_cookie
...
...
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