add lesson footer
authorRadek Czajka <radoslaw.czajka@nowoczesnapolska.org.pl>
Fri, 8 Feb 2013 13:17:16 +0000 (14:17 +0100)
committerRadek Czajka <radoslaw.czajka@nowoczesnapolska.org.pl>
Fri, 8 Feb 2013 13:18:41 +0000 (14:18 +0100)
catalogue/models.py
catalogue/static/catalogue/css/layout.css
catalogue/static/catalogue/css/layout.scss
catalogue/templates/catalogue/lesson_detail.html

index ee0222c..f1c5377 100644 (file)
@@ -173,6 +173,24 @@ class Lesson(models.Model):
     def get_syntetic(self):
         return self.section.syntetic_lesson(self.level)
 
     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)
 
 class Attachment(models.Model):
     slug = models.CharField(max_length=255)
index 1836845..09ff5af 100644 (file)
 
 #main-bar {
   width: 40em; }
 
 #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; }
index 5596539..7bea63a 100755 (executable)
@@ -74,4 +74,21 @@ $new_black: #363a3e;
 }
 #main-bar {
     width: 640*$px;
 }
 #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;}
 }
 }
index 233c271..8cf7bf4 100755 (executable)
 
 <div id="main-bar">
 {{ object.html_file.read|safe }}
 
 <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 }}">&larr; {{ previous }}</a>
+    {% endif %}
+{% endwith %}
+
+{% with object.get_next as next %}
+    {% if next %}
+        <a class="next-lesson" href="{{ next.get_absolute_url }}">{{ next }} &rarr;</a>
+    {% endif %}
+{% endwith %}
+</p>
+{% endif %}
+
+<div class="clr"></div>
+</footer>
 </div>
 
 {% endblock %}
 </div>
 
 {% endblock %}