Trees | Indices | Help |
|
---|
|
1 #!/usr/bin/env python 2 # -*- coding: utf-8 -*- 3 # 4 # 5 # 6 # Copyright (c) 2008-2011 University of Dundee. 7 # 8 # This program is free software: you can redistribute it and/or modify 9 # it under the terms of the GNU Affero General Public License as 10 # published by the Free Software Foundation, either version 3 of the 11 # License, or (at your option) any later version. 12 # 13 # This program is distributed in the hope that it will be useful, 14 # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 # GNU Affero General Public License for more details. 17 # 18 # You should have received a copy of the GNU Affero General Public License 19 # along with this program. If not, see <http://www.gnu.org/licenses/>. 20 # 21 # Author: Aleksandra Tarkowska <A(dot)Tarkowska(at)dundee(dot)ac(dot)uk>, 2008. 22 # 23 # Version: 1.0 24 # 25 26 from django.conf import settings 27 PAGE = settings.PAGE 2830 31 conn = None 32 35 38 39 ########################################################### 40 # Paging 416743 total = list() 44 t = (total_size/limit) + (total_size%limit > 0 and 1 or 0) 45 if total_size > (limit*10): 46 if page > 10 : 47 total.append(-1) 48 for i in range((1, page-9)[ page-9 >= 1 ], (t+1, page+10)[ page+9 < t ]): 49 total.append(i) 50 if page < t-9: 51 total.append(-1) 52 53 elif total_size > limit and total_size <= (limit*10): 54 for i in range(1, t+1): 55 total.append(i) 56 else: 57 total.append(1) 58 next = None 59 if page_size == limit and (page*limit) < total_size: 60 next = page + 1 61 prev = None 62 if page > 1: 63 prev = page - 1 64 if len(total)>1: 65 return {'page': page, 'total':total, 'next':next, "prev":prev} 66 return None
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Tue Sep 23 15:04:56 2014 | http://epydoc.sourceforge.net |