From 94e24c16260b85b672cebf9bdfa14b7e86d3bf7c Mon Sep 17 00:00:00 2001 From: Victor Shnayder Date: Fri, 3 Aug 2012 14:45:43 -0400 Subject: [PATCH] Leftover name->url_name fixes --- .../lib/xmodule/xmodule/modulestore/search.py | 5 +++-- lms/djangoapps/courseware/grades.py | 10 +++++----- lms/djangoapps/courseware/module_render.py | 18 +++++++++--------- 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/common/lib/xmodule/xmodule/modulestore/search.py b/common/lib/xmodule/xmodule/modulestore/search.py index b3eae64fcc..baf3d46b57 100644 --- a/common/lib/xmodule/xmodule/modulestore/search.py +++ b/common/lib/xmodule/xmodule/modulestore/search.py @@ -87,8 +87,9 @@ def path_to_location(modulestore, location, course_name=None): n = len(path) course_id = CourseDescriptor.location_to_id(path[0]) - chapter = path[1].url_name if n > 1 else None - section = path[2].url_name if n > 2 else None + # pull out the location names + chapter = path[1].name if n > 1 else None + section = path[2].name if n > 2 else None # TODO (vshnayder): not handling position at all yet... position = None diff --git a/lms/djangoapps/courseware/grades.py b/lms/djangoapps/courseware/grades.py index 717cbde140..6e7a0ce102 100644 --- a/lms/djangoapps/courseware/grades.py +++ b/lms/djangoapps/courseware/grades.py @@ -74,8 +74,8 @@ def grade_sheet(student, course, grader, student_module_cache): totaled_scores[format] = format_scores sections.append({ - 'display_name': s.metadata.get('display_name'), - 'url_name': s.metadata.get('url_name'), + 'display_name': s.display_name, + 'url_name': s.url_name, 'scores': scores, 'section_total': section_total, 'format': format, @@ -83,9 +83,9 @@ def grade_sheet(student, course, grader, student_module_cache): 'graded': graded, }) - chapters.append({'course': course.metadata.get('display_name'), - 'display_name': c.metadata.get('display_name'), - 'url_name': c.metadata.get('url_name'), + chapters.append({'course': course.display_name, + 'display_name': c.display_name, + 'url_name': c.url_name, 'sections': sections}) grade_summary = grader.grade(totaled_scores) diff --git a/lms/djangoapps/courseware/module_render.py b/lms/djangoapps/courseware/module_render.py index 4699ed50a4..9260e15c61 100644 --- a/lms/djangoapps/courseware/module_render.py +++ b/lms/djangoapps/courseware/module_render.py @@ -56,21 +56,21 @@ def toc_for_course(user, request, course, active_chapter, active_section): sections = list() for section in chapter.get_display_items(): - active = (chapter.metadata.get('display_name') == active_chapter and - section.metadata.get('display_name') == active_section) + active = (chapter.display_name == active_chapter and + section.display_name == active_section) hide_from_toc = section.metadata.get('hide_from_toc', 'false').lower() == 'true' if not hide_from_toc: - sections.append({'display_name': section.metadata.get('display_name'), - 'url_name': section.metadata.get('url_name'), + sections.append({'display_name': section.display_name, + 'url_name': section.url_name, 'format': section.metadata.get('format', ''), 'due': section.metadata.get('due', ''), 'active': active}) - chapters.append({'display_name': chapter.metadata.get('display_name'), - 'url_name': chapter.metadata.get('url_name'), + chapters.append({'display_name': chapter.display_name, + 'url_name': chapter.url_name, 'sections': sections, - 'active': chapter.metadata.get('display_name') == active_chapter}) + 'active': chapter.display_name == active_chapter}) return chapters @@ -89,7 +89,7 @@ def get_section(course_module, chapter, section): chapter_module = None for _chapter in course_module.get_children(): - if _chapter.metadata.get('url_name') == chapter: + if _chapter.url_name == chapter: chapter_module = _chapter break @@ -98,7 +98,7 @@ def get_section(course_module, chapter, section): section_module = None for _section in chapter_module.get_children(): - if _section.metadata.get('url_name') == section: + if _section.url_name == section: section_module = _section break