Beispiel #1
0
def get_ordered_updates(request, course):
    """
    Returns any course updates in reverse chronological order.
    """
    info_module = get_course_info_section_module(request, request.user, course,
                                                 'updates')

    updates = info_module.items if info_module else []
    info_block = getattr(info_module, '_xmodule',
                         info_module) if info_module else None
    ordered_updates = [
        update for update in updates if update.get('status') == STATUS_VISIBLE
    ]
    ordered_updates.sort(key=lambda item:
                         (safe_parse_date(item['date']), item['id']),
                         reverse=True)
    for update in ordered_updates:
        update['content'] = info_block.system.replace_urls(update['content'])
    return ordered_updates
Beispiel #2
0
def get_ordered_updates(request, course):
    """
    Returns all public course updates in reverse chronological order, including dismissed ones.
    """
    info_module = get_course_info_section_module(request, request.user, course,
                                                 'updates')
    if not info_module:
        return []

    info_block = getattr(info_module, '_xmodule', info_module)
    ordered_updates = [
        update for update in info_module.items
        if update.get('status') == STATUS_VISIBLE
    ]
    ordered_updates.sort(key=lambda item:
                         (_safe_parse_date(item['date']), item['id']),
                         reverse=True)
    for update in ordered_updates:
        update['content'] = info_block.system.replace_urls(update['content'])
    return ordered_updates