Add related lessons.
authorRadek Czajka <radoslaw.czajka@nowoczesnapolska.org.pl>
Fri, 8 Feb 2013 12:42:42 +0000 (13:42 +0100)
committerRadek Czajka <radoslaw.czajka@nowoczesnapolska.org.pl>
Fri, 8 Feb 2013 12:42:42 +0000 (13:42 +0100)
catalogue/templates/catalogue/lesson_detail.html
catalogue/templates/catalogue/snippets/lesson_link.html [new file with mode: 0755]
catalogue/templatetags/catalogue_tags.py

index 6ccce2d..233c271 100755 (executable)
@@ -1,6 +1,6 @@
 {% extends "base.html" %}
 {% load url from future %}
-{% load lesson_nav person_list from catalogue_tags %}
+{% load lesson_link lesson_nav person_list from catalogue_tags %}
 {% load competence curriculum url_for_level from curriculum_tags %}
 
 
         {% lesson_nav object %}
     </section>
 
+    {% if object.dc.relations %}
+    <section class="section-minor">
+        <h1>PowiÄ…zane lekcje</h1>
+        {% for uri in object.dc.relations %}
+        <ul class="link-list">
+            <li>{% lesson_link uri %}</li>
+        </ul>
+        {% endfor %}
+    </section>
+    {% endif %}
+
     {% if object.dc.competences %}
     <section class="section-minor">
         <h1>Kompetencje:</h1>
diff --git a/catalogue/templates/catalogue/snippets/lesson_link.html b/catalogue/templates/catalogue/snippets/lesson_link.html
new file mode 100755 (executable)
index 0000000..15b8cf0
--- /dev/null
@@ -0,0 +1 @@
+<a href="{{ lesson.get_absolute_url }}">{{ lesson }}</a>
index 23ce402..80b1a0c 100755 (executable)
@@ -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()
 
@@ -51,9 +52,12 @@ def lesson_nav(lesson):
         "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)