Prepared for SP 4-6.
[edumed.git] / catalogue / views.py
1 import os.path
2 from django.conf import settings
3 from django.views.generic import DetailView, ListView
4 from .models import Lesson, Section
5 from curriculum.models import Level
6 from publishers.models import Publisher
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:
34             pass
35         return context