X-Git-Url: https://git.mdrn.pl/edumed.git/blobdiff_plain/d92d15f83d157e1f00458d95e19060ab7fbd35b1..2b5915c86273728f6f1936f2c4e704edc6d19222:/catalogue/templatetags/catalogue_tags.py diff --git a/catalogue/templatetags/catalogue_tags.py b/catalogue/templatetags/catalogue_tags.py index 23a4066..5c96e32 100755 --- a/catalogue/templatetags/catalogue_tags.py +++ b/catalogue/templatetags/catalogue_tags.py @@ -1,6 +1,6 @@ from django import template from django.utils.datastructures import SortedDict -from ..models import Section +from ..models import Lesson, Section register = template.Library() @@ -34,6 +34,25 @@ def section_box(section): "lessons": lessons, } +@register.inclusion_tag("catalogue/snippets/lesson_nav.html") +def lesson_nav(lesson): + if lesson.depth == 1: + root = lesson.section + siblings = root.lesson_set.filter(depth=1) + else: + root = None + siblings = Lesson.objects.filter(depth=0) + return { + "lesson": lesson, + "root": root, + "siblings": siblings, + } + +@register.filter +def person_list(persons): + from librarian.dcparser import Person + return u", ".join(Person.from_text(p).readable() for p in persons) + # FIXME: Move to fnpdjango import feedparser