def latest_update_html(cls, request, course): """ Returns the course's latest update message or None if it doesn't have one. """ # Return the course update with the most recent publish date ordered_updates = get_ordered_updates(request, course) content = None if ordered_updates: content = ordered_updates[0]['content'] return content
def latest_update_html(cls, request, course): """ Returns the course's latest update message or None if it doesn't have one. """ # Return the course update with the most recent publish date ordered_updates = get_ordered_updates(request, course) content = None if ordered_updates: content = ordered_updates[0]['content'] return content
def render_to_fragment(self, request, course_id=None, **kwargs): """ Renders the latest update message fragment for the specified course. Returns: A fragment, or None if there is no latest update message. """ course_key = CourseKey.from_string(course_id) course = get_course_with_access(request.user, 'load', course_key, check_if_enrolled=True) ordered_updates = get_ordered_updates(request, course) if not ordered_updates: return None context = { 'ordered_updates': ordered_updates, } html = render_to_string( 'course_experience/course-home-updates-fragment.html', context) return Fragment(html)