return ret
-class CourseListSubView(ListView):
+class CourseListSubView(TemplateView):
""" Lists all courses. Called by CourseListView. """
- model = Course
-
- def get_queryset(self):
- return Course.objects.all().select_related('note_set', 'school', 'department', 'department__school')
+ template_name = 'courses/course_list.html'
def get_context_data(self, **kwargs):
""" Add the CourseForm to ListView context """
- # get the original context
- context = super(CourseListSubView, self).get_context_data(**kwargs)
# get the total number of notes
- context['note_count'] = Note.objects.count()
+ kwargs['note_count'] = Note.objects.count()
# get the course form for the form at the bottom of the homepage
- context['course_form'] = CourseForm()
+ kwargs['course_form'] = CourseForm()
schools = set()
- for course in self.object_list:
+ for course in Course.objects.all().select_related('school', 'department', 'department__school'):
if course.school:
schools.add(course.school)
elif course.department and course.department.school:
schools.add(course.department.school)
- context['schools'] = sorted(list(schools), key=lambda x: x.name)
+ kwargs['schools'] = sorted(list(schools), key=lambda x: x.name)
# Include settings constants for honeypot
for key in ('HONEYPOT_FIELD_NAME', 'HONEYPOT_VALUE'):
- context[key] = getattr(settings, key)
+ kwargs[key] = getattr(settings, key)
- return context
+ return kwargs
class CourseAddFormView(CreateView):
+++ /dev/null
-<tr class="table-row">
- <td class="hide">{{ course.updated_at|date:"U" }}</td>
- <td class="hide">{{ course.file_count|stringformat:"010g" }}</td>
- <td class="hide">{{ course.thank_count|stringformat:"010g" }}</td>
- {% if course.school %}
- <td class="hide">{{ course.school.name }}</td>
- {% else %}
- <td class="hide">{{ course.department.school.name }}</td>
- {% endif %}
-
- <td class="small-12 columns data-table-entry-wrapper">
- <div class="data-table-entry">
- <div class="table-entry-first-line">
- <span class="table-school">
- {% if course.school.name %}
- {{ course.school.name }}
- {% endif %}
- {% if course.department.school.name %}
- {{ course.department.school.name }}
- {% endif %}
- </span>
- {% if course.department %}
- •
- <span class="table-department">{{ course.department.name }}</span>
- {% endif %}
- {% if course.instructor_name %}
- •
- <span class="table-instructor">{{ course.instructor_name }}</span>
- {% endif %}
- {% if course.instructor.name %}
- •
- <span class="table-instructor">{% for prof in course.professor.all %}
- {{ prof.name }}{% if not forloop.last %},{% endif %}
- {% endfor %}</span>
- {% endif %}
- </div>
-
- <div class="table-entry-second-line museo700">
- <span class="table-course-name"><a href="{{ course.get_absolute_url }}">{{ course.name }}</a></span>
- </div>
-
- <div class="table-entry-third-line">
- <span class="table-note-count"><i class="fa fa-file-text-o"></i> {{ course.file_count }} Notes</span>
- <span class="table-thanks-count"><i class="fa fa-thumbs-up"></i> {{ course.thank_count }} Thanks </span>
- <span>Updated {{ course.updated_at|date:"b d, o"|capfirst }}</span>
- </div>
- </div>
-
- </td>
-</tr>