hook mailchimp to contact forms
[edumed.git] / catalogue / views.py
1 # -*- coding: utf-8 -*-
2 from django.views.generic import DetailView, ListView
3
4 from curriculum.models import Level
5 from publishers.models import Publisher
6 from .models import Lesson
7
8
9 class LessonListView(ListView):
10     queryset = Level.objects.exclude(lesson=None)
11     template_name = "catalogue/lesson_list.html"
12
13     def get_context_data(self, **kwargs):
14         context = super(LessonListView, self).get_context_data(**kwargs)
15         context['appendix'] = Lesson.objects.filter(type='appendix')
16         return context
17
18
19 class LessonView(DetailView):
20     model = Lesson
21
22     def get_template_names(self):
23         return [
24             'catalogue/lesson/%s/lesson_detail.html' % self.object.type,
25             'catalogue/lesson/lesson_detail.html',
26         ]
27
28     def get_context_data(self, **kwargs):
29         context = super(LessonView, self).get_context_data(**kwargs)
30         try:
31             context['publisher'] = Publisher.objects.get(
32                 name=context['object'].dc.get('publisher', '').strip())
33         except (Publisher.DoesNotExist, Publisher.MultipleObjectsReturned):
34             pass
35         return context