fnp
/
django-pagination.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'master' of git://github.com/tzangms/django-pagination
[django-pagination.git]
/
linaro_django_pagination
/
paginator.py
diff --git
a/linaro_django_pagination/paginator.py
b/linaro_django_pagination/paginator.py
index
f67aa23
..
8109e5e
100644
(file)
--- 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
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
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:
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
except IndexError:
return False
return True
@@
-107,6
+107,7
@@
class InfinitePage(Page):
return self.paginator.link_template % (self.number - 1)
return None
return self.paginator.link_template % (self.number - 1)
return None
+
class FinitePaginator(InfinitePaginator):
"""
Paginator for cases when the list of items is already finite.
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)
page_items = self.object_list[:self.per_page]
return FinitePage(page_items, number, self)
+
class FinitePage(InfinitePage):
def has_next(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:
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
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?
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