Commit 8ac89c39 by Carlos Andrés Rocha

Use course metadata instead of setting attributes to display new course overlay

parent 22de7cbb
......@@ -251,11 +251,12 @@ def _sort_courses_and_mark_new(courses):
for course in courses:
days_to_start = _get_course_days_to_start(course)
# Add values as attributes, so they can be used in templates
setattr(course, '_days_to_start', days_to_start)
setattr(course, 'is_new', days_to_start > 1)
metadata = course.metadata
metadata['days_to_start'] = days_to_start
metadata['is_new'] = course.metadata.get('is_new', days_to_start > 1)
courses = sorted(courses, key=lambda d: d._days_to_start, reverse=True)
key = lambda c: c.metadata['days_to_start']
courses = sorted(courses, key=key, reverse=True)
return courses
......
......@@ -5,7 +5,7 @@
%>
<%page args="course" />
<article id="${course.id}" class="course">
%if course.is_new:
%if course.metadata['is_new']:
<span class="status">New</span>
%endif
<a href="${reverse('about_course', args=[course.id])}">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment