auto-count on main
authorRadek Czajka <radoslaw.czajka@nowoczesnapolska.org.pl>
Thu, 20 Jun 2013 12:53:36 +0000 (14:53 +0200)
committerRadek Czajka <radoslaw.czajka@nowoczesnapolska.org.pl>
Thu, 20 Jun 2013 12:53:36 +0000 (14:53 +0200)
catalogue/templates/catalogue/snippets/carousel.html
catalogue/templatetags/catalogue_tags.py

index 75a3b2c..82984cf 100755 (executable)
@@ -6,7 +6,8 @@
         <li style="background-image: url(/static/carousel/img1.jpg); z-index: 100;">
             <a href="{{ jak }}" class="catalogue-carousel-link">
                 <div class="catalogue-carousel-note">
         <li style="background-image: url(/static/carousel/img1.jpg); z-index: 100;">
             <a href="{{ jak }}" class="catalogue-carousel-link">
                 <div class="catalogue-carousel-note">
-                    <p><strong>74</strong> <em>kompletne lekcje</em> - zobacz jak wykorzystać</p>
+                    <p><strong>{{ lessons_count }}</strong> <em>{{ lessons_desc }}</em>
+                    - zobacz jak wykorzystać</p>
                 </div>
             </a>
         </li>
                 </div>
             </a>
         </li>
index 32a5a0b..7003dfe 100755 (executable)
@@ -8,8 +8,12 @@ register = template.Library()
 
 @register.inclusion_tag("catalogue/snippets/carousel.html")
 def catalogue_carousel():
 
 @register.inclusion_tag("catalogue/snippets/carousel.html")
 def catalogue_carousel():
-    return {
-    }
+    lessons_count = Lesson.objects.filter(type__in=('course', 'synthetic')).count()
+    if 1 < lessons_count % 10 < 5 and lessons_count / 10 % 10 != 1:
+        lessons_desc = u'kompletne lekcje'
+    else:
+        lessons_desc = u'kompletnych lekcji'
+    return locals()
 
 @register.inclusion_tag("catalogue/snippets/section_buttons.html")
 def catalogue_section_buttons():
 
 @register.inclusion_tag("catalogue/snippets/section_buttons.html")
 def catalogue_section_buttons():