Skip to content
Snippets Groups Projects
Commit 6642de5c authored by Dave St.Germain's avatar Dave St.Germain
Browse files

Prevent 500 error when viewing malformed unit page

PROD-1026
parent 889daa8b
No related merge requests found
......@@ -547,19 +547,21 @@ def get_sibling_urls(subsection):
last_block = block
if not prev_loc:
try:
# section.get_parent SHOULD return the course, but for some reason, it might not
sections = section.get_parent().get_children()
except AttributeError:
log.error(u"Error retrieving URLs in subsection {subsection} included in section {section}".format(
section=section.location,
subsection=subsection.location
))
raise
try:
prev_section = sections[sections.index(section) - 1]
prev_loc = prev_section.get_children()[-1].get_children()[-1].location
except IndexError:
pass
# This should not be a fatal error. The worst case is that the navigation on the unit page
# won't display a link to a previous unit.
else:
try:
prev_section = sections[sections.index(section) - 1]
prev_loc = prev_section.get_children()[-1].get_children()[-1].location
except IndexError:
pass
if not next_loc:
sections = section.get_parent().get_children()
try:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment