From: floguy Date: Fri, 30 May 2008 03:49:57 +0000 (+0000) Subject: Probably fixed a potential bug with extraneous ellipses. X-Git-Tag: 1.0.6~46 X-Git-Url: https://git.mdrn.pl/django-pagination.git/commitdiff_plain/69ed0512ee955e1d7497b83d93c218280bb78e89?hp=1067434d01bcfcc2bf5a7c56e561fae82307ce27 Probably fixed a potential bug with extraneous ellipses. git-svn-id: https://django-pagination.googlecode.com/svn/trunk@11 7f1efe38-554e-0410-b69d-834cb44da2d5 --- diff --git a/pagination/templatetags/pagination_tags.py b/pagination/templatetags/pagination_tags.py index 3c1d17b..bba21b8 100644 --- a/pagination/templatetags/pagination_tags.py +++ b/pagination/templatetags/pagination_tags.py @@ -89,14 +89,19 @@ def paginate(context, window=4): current = set(page_range[current_start:current_end]) pages = [] if len(first.intersection(current)) == 0: - pages.extend(sorted(list(first))) - pages.append(None) - pages.extend(sorted(list(current))) + first_list = sorted(list(first)) + second_list = sorted(list(current)) + pages.extend(first_list) + if first_list[-1] + 1 != second_list[0]: + pages.append(None) + pages.extend(second_list) else: pages.extend(sorted(list(first.union(current)))) if len(current.intersection(last)) == 0: - pages.append(None) - pages.extend(sorted(list(last))) + second_list = sorted(list(last)) + if pages[-1] + 1 != second_list[0]: + pages.append(None) + pages.extend(second_list) else: pages.extend(sorted(list(last.difference(current)))) return {