1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-15 23:00:57 +00:00

Show 20 users per-page in pubuser

This commit is contained in:
zhengxie
2013-04-11 17:30:55 +08:00
parent e4ca2d8038
commit 9b6d7387da
3 changed files with 58 additions and 19 deletions

View File

@@ -1,18 +1,20 @@
from django.core.paginator import Paginator as DefaultPaginator
def get_page_range(current_page, num_pages):
first_page = 1
if num_pages <= 10:
last_page = num_pages
else:
if current_page < 6:
last_page = 10
else:
first_page = current_page - 5
last_page = current_page + 4 if current_page + 4 < num_pages else num_pages
return range(first_page, last_page + 1)
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)
return get_page_range(current_page, self.num_pages)