X-Git-Url: https://git.mdrn.pl/edumed.git/blobdiff_plain/2b5915c86273728f6f1936f2c4e704edc6d19222..0fb18b38f2379e67d0098658eb2822c11a341d25:/catalogue/templatetags/catalogue_tags.py diff --git a/catalogue/templatetags/catalogue_tags.py b/catalogue/templatetags/catalogue_tags.py index 5c96e32..09113d9 100755 --- a/catalogue/templatetags/catalogue_tags.py +++ b/catalogue/templatetags/catalogue_tags.py @@ -1,6 +1,7 @@ from django import template from django.utils.datastructures import SortedDict from ..models import Lesson, Section +from librarian.dcparser import WLURI, Person register = template.Library() @@ -16,41 +17,42 @@ def catalogue_section_buttons(): "object_list": Section.objects.all() } -@register.inclusion_tag("catalogue/snippets/chosen_topics.html") -def catalogue_chosen_topics(): - return { - } - @register.inclusion_tag("catalogue/snippets/section_box.html") def section_box(section): lessons = SortedDict() for lesson in section.lesson_set.all(): if lesson.level not in lessons: - lessons[lesson.level] = SortedDict() - if lesson.depth not in lessons[lesson.level]: - lessons[lesson.level][lesson.depth] = [] - lessons[lesson.level][lesson.depth].append(lesson) + newdict = SortedDict() + newdict['synthetic'] = [] + newdict['course'] = [] + lessons[lesson.level] = newdict + if lesson.type not in lessons[lesson.level]: + lessons[lesson.level][lesson.type] = [] + lessons[lesson.level][lesson.type].append(lesson) return { "lessons": lessons, } @register.inclusion_tag("catalogue/snippets/lesson_nav.html") def lesson_nav(lesson): - if lesson.depth == 1: + if lesson.type == 'course': root = lesson.section - siblings = root.lesson_set.filter(depth=1) + siblings = root.lesson_set.filter(type='course') else: root = None - siblings = Lesson.objects.filter(depth=0) + siblings = Lesson.objects.filter(type=lesson.type) return { "lesson": lesson, "root": root, "siblings": siblings, } +@register.inclusion_tag("catalogue/snippets/lesson_link.html") +def lesson_link(uri): + return {'lesson': Lesson.objects.get(slug=WLURI(uri).slug)} + @register.filter def person_list(persons): - from librarian.dcparser import Person return u", ".join(Person.from_text(p).readable() for p in persons)