]> git.parisson.com Git - mezzo.git/commitdiff
Topic : paginate article / 4 per pages just for tests
authorEmilie <zawadzki@ircam.fr>
Wed, 14 Sep 2016 09:58:14 +0000 (11:58 +0200)
committerEmilie <zawadzki@ircam.fr>
Wed, 14 Sep 2016 09:58:14 +0000 (11:58 +0200)
app/local_settings.py
app/organization/magazine/views.py
app/templates/magazine/topic/topic_detail.html

index cad3a8f643a514b00b8bee60c43e8f99a9d7adb5..7ac1ecef8e576afb9014079635c60d1ee7eead62 100644 (file)
@@ -112,6 +112,7 @@ 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
 
 # The numeric mode to set newly-uploaded files to. The value should be
 # a mode you'd pass directly to os.chmod.
index 8cfd7610e68ebf46138ed48b481ad84d7a82e4ab..29c2f01070a6b5b3c0070d86198c08d2a1a9bbc9 100644 (file)
@@ -10,6 +10,8 @@ from itertools import chain
 from dal import autocomplete
 from dal_select2_queryset_sequence.views import Select2QuerySetSequenceView
 from mezzanine_agenda.models import Event
+from mezzanine.utils.views import paginate
+from mezzanine.conf import settings
 from organization.magazine.models import Article, Topic, Brief
 from organization.network.models import DepartmentPage
 from organization.pages.models import CustomPage
@@ -53,6 +55,7 @@ class BriefDetailView(SlugMixin, DetailView):
         context = super(BriefDetailView, self).get_context_data(**kwargs)
         return context
 
+
 class BriefListView(SlugMixin, ListView):
 
     model = Brief
@@ -72,6 +75,11 @@ class TopicDetailView(SlugMixin, DetailView):
 
     def get_context_data(self, **kwargs):
         context = super(TopicDetailView, self).get_context_data(**kwargs)
+        # paginate "manually" articles because we are not in a ListView
+        articles = paginate(self.object.articles.all(), self.request.GET.get("page", 1),
+                          settings.ARTICLE_PER_PAGE,
+                          settings.MAX_PAGING_LINKS)
+        context['articles'] = articles
         return context
 
 
index 3a4a3f610baa77657939896dcf83588b5b0c18d1..d7db68d8b9a8e73d24f2b4afe630b40f82204283 100644 (file)
 
     <div class="container">
         <div class="row">
-            {% for article in topic.articles.all %}
+            {% for article in articles %}
                 <div class="col-lg-3 col-md-4 col-sm-4 col-xs-6">
                     {% include 'magazine/article/includes/article_card.html' %}
                 </div>
             {% endfor %}
         </div>
     </div>
-
+    {% pagination_for articles %}
 {% endblock %}