Adding instructions
[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
6
7 class SectionView(ListView):
8     model = Section
9
10     def get_context_data(self, **kwargs):
11         context = super(SectionView, self).get_context_data(**kwargs)
12         context['appendix'] = Lesson.objects.filter(type='appendix')
13         context['package_url'] = os.path.join(settings.MEDIA_URL, settings.CATALOGUE_PACKAGE)
14         context['package_student_url'] = os.path.join(settings.MEDIA_URL, settings.CATALOGUE_PACKAGE_STUDENT)
15         return context
16
17
18 class LessonView(DetailView):
19     model = Lesson
20
21     def get_template_names(self):
22         return [
23             'catalogue/lesson/%s/lesson_detail.html' % self.object.type,
24             'catalogue/lesson/lesson_detail.html',
25         ]
26