X-Git-Url: https://git.mdrn.pl/django-pagination.git/blobdiff_plain/465fb3a7654c3a1900b2692a55fa3fe64a73ddad..19af5cdf69b55c5bce39f2ca83e12372d395e49c:/linaro_django_pagination/paginator.py diff --git a/linaro_django_pagination/paginator.py b/linaro_django_pagination/paginator.py index f67aa23..8109e5e 100644 --- a/linaro_django_pagination/paginator.py +++ b/linaro_django_pagination/paginator.py @@ -1,5 +1,6 @@ from django.core.paginator import Paginator, Page, PageNotAnInteger, EmptyPage + class InfinitePaginator(Paginator): """ Paginator designed for cases when it's not important to know how many total @@ -81,8 +82,7 @@ class InfinitePage(Page): Checks for one more item than last on this page. """ try: - next_item = self.paginator.object_list[ - self.number * self.paginator.per_page] + self.paginator.object_list[self.number * self.paginator.per_page] except IndexError: return False return True @@ -107,6 +107,7 @@ class InfinitePage(Page): return self.paginator.link_template % (self.number - 1) return None + class FinitePaginator(InfinitePaginator): """ Paginator for cases when the list of items is already finite. @@ -150,6 +151,7 @@ class FinitePaginator(InfinitePaginator): page_items = self.object_list[:self.per_page] return FinitePage(page_items, number, self) + class FinitePage(InfinitePage): def has_next(self): @@ -157,7 +159,7 @@ class FinitePage(InfinitePage): Checks for one more item than last on this page. """ try: - next_item = self.paginator.object_list[self.paginator.per_page] + self.paginator.object_list[self.paginator.per_page] except IndexError: return False return True @@ -168,4 +170,4 @@ class FinitePage(InfinitePage): relative to total objects in the paginator. """ ## TODO should this holler if you haven't defined the offset? - return self.paginator.offset \ No newline at end of file + return self.paginator.offset