X-Git-Url: https://git.mdrn.pl/edumed.git/blobdiff_plain/3e55a1e4c5f489fab91c977a6b20e94867bb8245..5d8a65f12464816813e1b03837d65af1580c6fe5:/catalogue/templatetags/catalogue_tags.py diff --git a/catalogue/templatetags/catalogue_tags.py b/catalogue/templatetags/catalogue_tags.py index 23ce402..32a5a0b 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,11 +17,6 @@ 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() @@ -34,6 +30,7 @@ def section_box(section): lessons[lesson.level][lesson.type] = [] lessons[lesson.level][lesson.type].append(lesson) return { + "section": section, "lessons": lessons, } @@ -41,19 +38,28 @@ def section_box(section): def lesson_nav(lesson): if lesson.type == 'course': root = lesson.section - siblings = root.lesson_set.filter(type='course') + siblings = Lesson.objects.filter(type='course', level=lesson.level, section=root) + mark_level = False else: root = None siblings = Lesson.objects.filter(type=lesson.type) + mark_level = True return { "lesson": lesson, "root": root, "siblings": siblings, + "mark_level": mark_level } +@register.inclusion_tag("catalogue/snippets/lesson_link.html") +def lesson_link(uri): + try: + return {'lesson': Lesson.objects.get(slug=WLURI(uri).slug)} + except Lesson.DoesNotExist: + return {} + @register.filter def person_list(persons): - from librarian.dcparser import Person return u", ".join(Person.from_text(p).readable() for p in persons)