]> git.parisson.com Git - mezzo.git/commitdiff
Media : add pagination on list page
authorEmilie <zawadzki@ircam.fr>
Mon, 7 Nov 2016 10:46:56 +0000 (11:46 +0100)
committerEmilie <zawadzki@ircam.fr>
Mon, 7 Nov 2016 10:46:56 +0000 (11:46 +0100)
app/local_settings.py
app/organization/media/views.py
app/templates/media/playlist_list.html

index 525dd440aa56b286bc113fe0e286bdb9ccb8ca39..6a2711aed832aa7db590bca26bc5a2b46d0f49c7 100644 (file)
@@ -189,7 +189,8 @@ else:
 SLUGIFY = 'django.template.defaultfilters.slugify'
 
 BLOG_POST_PER_PAGE = 200
-ARTICLE_PER_PAGE = 4 # just for tests because we haven't got enough content
+ARTICLE_PER_PAGE = 10
+MEDIA_PER_PAGE = 9
 
 # The numeric mode to set newly-uploaded files to. The value should be
 # a mode you'd pass directly to os.chmod.
index 97046edae2349b214eb9b2858ed2e3bcda761223..5b04af6f7ad64b091caac4c7fe859b8d8f1baf23 100644 (file)
@@ -47,14 +47,19 @@ class PlaylistListView(ListView):
     template_name='media/playlist_list.html'
     context_object_name = 'playlists'
     def get_queryset(self):
-        qs = Playlist.objects.all()
+        self.qs = Playlist.objects.all()
         self.current_type = None
         if "type" in self.kwargs:
-            qs = qs.filter(type=self.kwargs['type'])
+            self.qs = self.qs.filter(type=self.kwargs['type'])
             self.current_type = self.kwargs['type']
-        return qs
+        return self.qs
     def get_context_data(self, **kwargs):
         context = super(PlaylistListView, self).get_context_data(**kwargs)
+
+        context['playlists'] = paginate(self.qs, self.request.GET.get("page", 1),
+                          settings.MEDIA_PER_PAGE,
+                          settings.MAX_PAGING_LINKS)
+
         context['current_type'] = self.current_type
         return context
 
index 301f63a4aeac365fbbefaa64feddf79ccf539d58..70f7227b9a27bc01953856b603fa20a428bba877 100644 (file)
@@ -42,4 +42,6 @@
         {% endfor %}
     </div>
 
+    {% pagination_for playlists %}
+
 {% endblock %}