From 733294cafa45a191478b4dccce4d7f5a22ee98de Mon Sep 17 00:00:00 2001 From: Robert Clark Date: Wed, 18 Jun 2014 11:04:39 -0400 Subject: [PATCH] return a queryset instead of the first sibling --- wagtail/wagtailcore/models.py | 8 ++++---- wagtail/wagtailcore/tests/test_page_queryset.py | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/wagtail/wagtailcore/models.py b/wagtail/wagtailcore/models.py index e2b728005..9dcc65f6f 100644 --- a/wagtail/wagtailcore/models.py +++ b/wagtail/wagtailcore/models.py @@ -645,11 +645,11 @@ class Page(MP_Node, ClusterableModel, Indexed): def get_siblings(self, inclusive=True): return Page.objects.sibling_of(self, inclusive) - def get_next_published_sibling(self): - return self.get_siblings().live().filter(path__gt=self.path).order_by('path').first() + def get_next_siblings(self): + return self.get_siblings().filter(path__gt=self.path).order_by('path') - def get_prev_published_sibling(self): - return self.get_siblings().live().filter(path__lt=self.path).order_by('-path').first() + def get_prev_siblings(self): + return self.get_siblings().filter(path__lt=self.path).order_by('-path') def get_navigation_menu_items(): # Get all pages that appear in the navigation menu: ones which have children, diff --git a/wagtail/wagtailcore/tests/test_page_queryset.py b/wagtail/wagtailcore/tests/test_page_queryset.py index 3db3bd5f8..020d98d15 100644 --- a/wagtail/wagtailcore/tests/test_page_queryset.py +++ b/wagtail/wagtailcore/tests/test_page_queryset.py @@ -262,7 +262,7 @@ class TestPageQuerySet(TestCase): # All pages must be live while current_page: self.assertTrue(current_page.live) - current_page = current_page.get_next_published_sibling() + current_page = current_page.get_next_siblings().live().first() def test_published_prev(self): events_index = Page.objects.get(url_path='/home/events/') @@ -271,4 +271,4 @@ class TestPageQuerySet(TestCase): # All pages must be live while current_page: self.assertTrue(current_page.live) - current_page = current_page.get_prev_published_sibling() + current_page = current_page.get_prev_siblings().live().first()