mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-13 22:01:06 +00:00
Using django paginator in group discuss
This commit is contained in:
18
utils/paginator.py
Normal file
18
utils/paginator.py
Normal file
@@ -0,0 +1,18 @@
|
||||
from django.core.paginator import Paginator as DefaultPaginator
|
||||
|
||||
class Paginator(DefaultPaginator):
|
||||
def get_page_range(self, current_page=1):
|
||||
"""
|
||||
Returns custom range of pages.
|
||||
"""
|
||||
first_page = 1
|
||||
total_page = self.num_pages
|
||||
if total_page <= 10:
|
||||
last_page = total_page
|
||||
else:
|
||||
if current_page < 6:
|
||||
last_page = 10
|
||||
else:
|
||||
first_page = current_page - 5
|
||||
last_page = current_page + 4 if current_page + 4 < total_page else total_page
|
||||
return range(first_page, last_page + 1)
|
Reference in New Issue
Block a user