Dan Carroll committed 65a56b5

Fix up links for previous/next pages in activity (fixes #27)

Comments (0)

Files changed (1)


 from django.core.paginator import Paginator, Page, PageNotAnInteger, EmptyPage
+from django.core.urlresolvers import reverse
 # Code borrowed from django-pagination.  I ripped it out since I didn't want the
 # rest of the functionality it provided (auto-pagination).
     template string for creating the links to the next and previous pages.
-    def __init__(self, object_list, per_page, allow_empty_first_page=True,
-        link_template='?page=%d'):
+    def __init__(self, object_list, per_page, allow_empty_first_page=True):
         orphans = 0 # no orphans
         super(InfinitePaginator, self).__init__(object_list, per_page, orphans,
         # no count or num pages
         del self._num_pages, self._count
-        # bonus links
-        self.link_template = link_template
     def validate_number(self, number):
     def next_link(self):
         if self.has_next():
-            return self.paginator.link_template % (self.number + 1)
+            return reverse('activity_paged', args=[self.number + 1])
         return None
     def previous_link(self):
         if self.has_previous():
-            return self.paginator.link_template % (self.number - 1)
+            if self.number == 2:
+                return reverse('main_activity')
+            else:
+                return reverse('activity_paged', args=[self.number - 1])
         return None
     def page_title(self):
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.