def _build_element_common(self, element, displayability, link, parent_element=None): if not displayability.is_name_visible: raise ValueError('Should not add non-displayble elements') ret = OutlineElement() ret.course_element = element ret.is_available_to_students = displayability.is_available_to_students ret.is_available_to_visitors = displayability.is_available_to_visitors if hasattr(element, 'lesson_id'): ret.id = element.lesson_id ret.title = resources_display.display_lesson_title( parent_element, element, self._app_context) else: ret.id = element.unit_id if element.is_unit(): ret.title = resources_display.display_unit_title( element, self._app_context) else: ret.title = element.title if parent_element: ret.parent_id = parent_element.unit_id if displayability.is_content_available: ret.link = link if (self._student_preferences and self._student_preferences.last_location and link and self._student_preferences.last_location.endswith(link)): ret.link_is_last_page_visited = True if hasattr(element, 'description'): ret.description = element.description return ret
def _build_element_common(self, element, displayability, link, parent_element=None): if not displayability.is_displayed: raise ValueError('Should not add non-displayble elements') ret = OutlineElement() ret.course_element = element ret.is_available_to_students = displayability.is_available_to_students ret.is_available_to_visitors = displayability.is_available_to_visitors if hasattr(element, 'lesson_id'): ret.id = element.lesson_id ret.title = resources_display.display_lesson_title( parent_element, element, self._app_context) else: ret.id = element.unit_id if element.is_unit(): ret.title = resources_display.display_unit_title( element, self._app_context) else: ret.title = element.title if parent_element: ret.parent_id = parent_element.unit_id if displayability.is_link_displayed: ret.link = link if (self._student_preferences and self._student_preferences.last_location and link and self._student_preferences.last_location.endswith(link)): ret.link_is_last_page_visited = True if hasattr(element, 'description'): ret.description = element.description return ret
def get_template(self, template_file, additional_dirs=None, prefs=None): """Computes location of template files for the current namespace.""" _p = self.app_context.get_environ() self.init_template_values(_p, prefs=prefs) template_environ = self.app_context.get_template_environ(self.app_context.get_current_locale(), additional_dirs) template_environ.filters["gcb_tags"] = jinja_utils.get_gcb_tags_filter(self) template_environ.globals.update( { "display_unit_title": (lambda unit: resources_display.display_unit_title(unit, self.app_context)), "display_short_unit_title": ( lambda unit: resources_display.display_short_unit_title(unit, self.app_context) ), "display_lesson_title": ( lambda unit, lesson: resources_display.display_lesson_title(unit, lesson, self.app_context) ), } ) return template_environ.get_template(template_file)
def unit_title(unit, app_context): return resources_display.display_unit_title(unit, app_context)