mirror of
https://github.com/Hopiu/wagtail.git
synced 2026-04-19 14:31:00 +00:00
Merge pull request #191 from kaedroho/page-changes
Override a few treebeard methods to add inclusive flag
This commit is contained in:
commit
a3d58126fd
2 changed files with 12 additions and 3 deletions
|
|
@ -558,6 +558,15 @@ class Page(MP_Node, ClusterableModel, Indexed):
|
|||
user_perms = UserPagePermissionsProxy(user)
|
||||
return user_perms.for_page(self)
|
||||
|
||||
def get_ancestors(self, inclusive=False):
|
||||
return Page.objects.ancestor_of(self, inclusive)
|
||||
|
||||
def get_descendants(self, inclusive=False):
|
||||
return Page.objects.descendant_of(self, inclusive)
|
||||
|
||||
def get_siblings(self, inclusive=True):
|
||||
return Page.objects.sibling_of(self, inclusive)
|
||||
|
||||
|
||||
def get_navigation_menu_items():
|
||||
# Get all pages that appear in the navigation menu: ones which have children,
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ class PageQuerySet(MP_NodeQuerySet):
|
|||
def not_parent_of(self, other):
|
||||
return self.exclude(self.parent_of_q(other))
|
||||
|
||||
def sibling_of_q(self, other, inclusive=False):
|
||||
def sibling_of_q(self, other, inclusive=True):
|
||||
q = Q(path__startswith=self.model._get_parent_path_from_path(other.path)) & Q(depth=other.depth)
|
||||
|
||||
if not inclusive:
|
||||
|
|
@ -92,10 +92,10 @@ class PageQuerySet(MP_NodeQuerySet):
|
|||
|
||||
return q
|
||||
|
||||
def sibling_of(self, other, inclusive=False):
|
||||
def sibling_of(self, other, inclusive=True):
|
||||
return self.filter(self.sibling_of_q(other, inclusive))
|
||||
|
||||
def not_sibling_of(self, other, inclusive=False):
|
||||
def not_sibling_of(self, other, inclusive=True):
|
||||
return self.exclude(self.sibling_of_q(other, inclusive))
|
||||
|
||||
def type_q(self, model):
|
||||
|
|
|
|||
Loading…
Reference in a new issue