render content and log the error when getting sibling urls

This commit is contained in:
DawoudSheraz
2019-11-25 14:55:45 +05:00
parent 6d2ed9d876
commit 40611acf87

View File

@@ -550,7 +550,7 @@ def get_sibling_urls(subsection):
# 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(
log.error(u"URL Retrieval Error # 1: subsection {subsection} included in section {section}".format(
section=section.location,
subsection=subsection.location
))
@@ -563,12 +563,19 @@ def get_sibling_urls(subsection):
except IndexError:
pass
if not next_loc:
sections = section.get_parent().get_children()
try:
next_section = sections[sections.index(section) + 1]
next_loc = next_section.get_children()[0].get_children()[0].location
except IndexError:
pass
sections = section.get_parent().get_children()
except AttributeError:
log.error(u"URL Retrieval Error # 2: subsection {subsection} included in section {section}".format(
section=section.location,
subsection=subsection.location
))
else:
try:
next_section = sections[sections.index(section) + 1]
next_loc = next_section.get_children()[0].get_children()[0].location
except IndexError:
pass
if prev_loc:
prev_url = reverse_usage_url('container_handler', prev_loc)
if next_loc: