re-add school leader board by writing an AboutView TemplateView
authorSeth Woodworth <seth@sethish.com>
Fri, 25 Jan 2013 21:52:43 +0000 (16:52 -0500)
committerSeth Woodworth <seth@sethish.com>
Fri, 25 Jan 2013 21:52:43 +0000 (16:52 -0500)
karmaworld/apps/courses/views.py
karmaworld/templates/about.html
karmaworld/urls.py

index f8fab63090350c58b2350a13ccfb5c114da1d5ea..a9dd145b3716370b3aa3176a73fa44c40ada0eaa 100644 (file)
@@ -3,8 +3,10 @@
 # Copyright (C) 2012  FinalsClub Foundation
 
 from django.views.generic import DetailView
+from django.views.generic import TemplateView
 
 from karmaworld.apps.courses.models import Course
+from karmaworld.apps.courses.models import School
 
 class CourseDetailView(DetailView):
     """ Class-based view for the course html page """
@@ -12,3 +14,14 @@ class CourseDetailView(DetailView):
     model = Course
     # name passed to template
     context_object_name = u"course"
+
+
+class AboutView(TemplateView):
+    """ Display the About page with the Schools leaderboard """
+    template_name = "about.html"
+
+    def get_context_data(self, **kwargs):
+        """ get the list of schools with the most files for leaderboard """
+        context = { 'params': kwargs, \
+                    'schools': School.objects.all()[:3] }
+        return context
index af11f7b55ac5f3d763f0d3a8052521deb0492092..da15b1ed4071effb73a3687b160172ac7a384ac8 100644 (file)
     </div>
 
 
-<!--     <div class="row">
+    <div class="row">
       <div id="leaderboard_table" class="ten columns offset-by-one">
 
-        {% for school in leader_schools %}
+        {% for school in schools %}
         <div class="row leaderboard_item">
           <div class="one column leaderboard_rank">
             {{ forloop.counter }}
           </div>
           <div class="eight columns leaderboard_school">
             {{ school.name }}
-          </div> /leaderboard_school 
+          </div> <!-- /leaderboard_school -->
           <div class="one column leaderboard_score">
-            {{ school.karma|intcomma }}
-          </div> /leaderboard_score 
-        </div> /leaderboard_item
+            {{ school.file_count }}
+          </div> <!-- /leaderboard_score -->
+        </div> <!-- /leaderboard_item -->
         {% endfor %}
 
-      </div> /leaderboard_table
+      </div> <!-- /leaderboard_table -->
     </div>  
--->
 
   </section><!--/about_content-->
 {% endblock %}
index 07b8fc878ecd91f916553aac76a4dcbf8cd69ca1..7b597d93c66764c544c5757e5257f3ad856923ac 100644 (file)
@@ -9,6 +9,7 @@ from django.views.generic.simple import direct_to_template
 
 from karmaworld.apps.ajaxuploader.views import ajax_uploader
 from karmaworld.apps.courses.models import Course
+from karmaworld.apps.courses.views import AboutView
 from karmaworld.apps.courses.views import CourseDetailView
 from karmaworld.apps.notes.views import NoteView
 from karmaworld.apps.notes.views import raw_file
@@ -22,9 +23,10 @@ urlpatterns = patterns('',
     url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
     url(r'^admin/', include(admin.site.urls)),
 
-    url(r'^about/$', direct_to_template, { 'template': 'about.html' }, name='about'),
     url(r'^terms/$', direct_to_template, { 'template': 'terms.html' }, name='terms'),
 
+    url(r'^about/$', AboutView.as_view(), name='about'),
+
     url(r'^raw/(?P<pk>\d+)$', raw_file, name='note_raw'),
     url(r'^(?P<school_slug>[^/]+)/(?P<slug>[^/]+)$', \
         CourseDetailView.as_view(), name='course_detail'),