1 # -*- coding: utf-8 -*-
 
   2 from django.views.generic import DetailView, ListView
 
   4 from curriculum.models import Level
 
   5 from publishers.models import Publisher
 
   6 from .models import Lesson
 
   9 class LessonListView(ListView):
 
  10     queryset = Level.objects.exclude(lesson=None)
 
  11     template_name = "catalogue/lesson_list.html"
 
  13     def get_context_data(self, **kwargs):
 
  14         context = super(LessonListView, self).get_context_data(**kwargs)
 
  15         context['appendix'] = Lesson.objects.filter(type='appendix')
 
  19 class LessonView(DetailView):
 
  22     def get_template_names(self):
 
  24             'catalogue/lesson/%s/lesson_detail.html' % self.object.type,
 
  25             'catalogue/lesson/lesson_detail.html',
 
  28     def get_context_data(self, **kwargs):
 
  29         context = super(LessonView, self).get_context_data(**kwargs)
 
  31             context['publisher'] = Publisher.objects.get(
 
  32                 name=context['object'].dc.get('publisher', '').strip())
 
  33         except (Publisher.DoesNotExist, Publisher.MultipleObjectsReturned):