def get_syntetic(self):
return self.section.syntetic_lesson(self.level)
+ def get_previous(self):
+ if self.section is None: return None
+ try:
+ return self.section.lesson_set.filter(
+ type=self.type, level=self.level,
+ order__lt=self.order).order_by('-order')[0]
+ except IndexError:
+ return None
+
+ def get_next(self):
+ if self.section is None: return None
+ try:
+ return self.section.lesson_set.filter(
+ type=self.type, level=self.level,
+ order__gt=self.order).order_by('order')[0]
+ except IndexError:
+ return None
+
class Attachment(models.Model):
slug = models.CharField(max_length=255)
#main-bar {
width: 40em; }
+ #main-bar .top-link {
+ float: right; }
+
+.lesson-footer {
+ clear: both;
+ border-top: 1px solid #777;
+ margin-top: 2em;
+ padding-top: 1em; }
+ .lesson-footer .section-info {
+ text-align: center; }
+ .lesson-footer .previous-lesson {
+ float: left; }
+ .lesson-footer .next-lesson {
+ float: right; }
}
#main-bar {
width: 640*$px;
+
+ .top-link {
+ float:right;
+ }
+}
+
+.lesson-footer {
+ clear: both;
+ border-top: 1px solid #777;
+ margin-top: 2em;
+ padding-top: 1em;
+
+ .section-info {
+ text-align: center;
+ }
+ .previous-lesson {float: left;}
+ .next-lesson {float: right;}
}
<div id="main-bar">
{{ object.html_file.read|safe }}
+
+
+<a class="top-link" href="#">wróć na górę</a>
+<footer class="lesson-footer">
+
+{% if object.section %}
+
+<p class="section-info"><a href="{{ object.section.get_absolute_url }}">Temat: {{ object.section }}</a>
+<br/>(<a href="{% url 'catalogue_lessons' %}">spis wszystkich lekcji</a>)</p>
+
+<p>
+{% with object.get_previous as previous %}
+ {% if previous %}
+ <a class="previous-lesson" href="{{ previous.get_absolute_url }}">← {{ previous }}</a>
+ {% endif %}
+{% endwith %}
+
+{% with object.get_next as next %}
+ {% if next %}
+ <a class="next-lesson" href="{{ next.get_absolute_url }}">{{ next }} →</a>
+ {% endif %}
+{% endwith %}
+</p>
+{% endif %}
+
+<div class="clr"></div>
+</footer>
</div>
{% endblock %}