make unpublish() a method on PageQuerySet as suggested by @kaedroho in https://github.com/torchbox/wagtail/pull/566#commitcomment-8037361

This commit is contained in:
Matt Westcott 2014-10-04 18:11:30 +02:00
parent e49f64aea3
commit 223dcbc14d
2 changed files with 7 additions and 1 deletions

View file

@ -631,7 +631,7 @@ def copy(request, page_id):
# Unpublish copied pages if we need to
if not publish_copies:
new_page.get_descendants(inclusive=True).update(live=False, has_unpublished_changes=True)
new_page.get_descendants(inclusive=True).unpublish()
# Assign user of this request as the owner of all the new pages
new_page.get_descendants(inclusive=True).update(owner=request.user)

View file

@ -198,3 +198,9 @@ class PageQuerySet(MP_NodeQuerySet):
"""
search_backend = get_search_backend(backend)
return search_backend.search(query_string, self, fields=None)
def unpublish(self):
"""
This unpublishes all pages in the queryset
"""
self.update(live=False, has_unpublished_changes=True)