Merge branch 'master' of github.com:torchbox/wagtail

pull/765/head
Matt Westcott 2014-10-28 14:54:03 +00:00
commit ceb7139b71
2 zmienionych plików z 8 dodań i 10 usunięć

Wyświetl plik

@ -631,16 +631,10 @@ def copy(request, page_id):
update_attrs={
'title': form.cleaned_data['new_title'],
'slug': form.cleaned_data['new_slug'],
}
},
keep_live=(can_publish and form.cleaned_data.get('publish_copies')),
)
# Check if we should keep copied subpages published
publish_copies = can_publish and form.cleaned_data.get('publish_copies')
# Unpublish copied pages if we need to
if not publish_copies:
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)

Wyświetl plik

@ -703,7 +703,7 @@ class Page(six.with_metaclass(PageBase, MP_Node, ClusterableModel, index.Indexed
# Log
logger.info("Page moved: \"%s\" id=%d path=%s", self.title, self.id, new_url_path)
def copy(self, recursive=False, to=None, update_attrs=None, copy_revisions=True):
def copy(self, recursive=False, to=None, update_attrs=None, copy_revisions=True, keep_live=True):
# Make a copy
page_copy = Page.objects.get(id=self.id).specific
page_copy.pk = None
@ -712,6 +712,10 @@ class Page(six.with_metaclass(PageBase, MP_Node, ClusterableModel, index.Indexed
page_copy.numchild = 0
page_copy.path = None
if not keep_live:
page_copy.live = False
page_copy.has_unpublished_changes = True
if update_attrs:
for field, value in update_attrs.items():
setattr(page_copy, field, value)
@ -748,7 +752,7 @@ class Page(six.with_metaclass(PageBase, MP_Node, ClusterableModel, index.Indexed
# Copy child pages
if recursive:
for child_page in self.get_children():
child_page.specific.copy(recursive=True, to=page_copy, copy_revisions=copy_revisions)
child_page.specific.copy(recursive=True, to=page_copy, copy_revisions=copy_revisions, keep_live=keep_live)
return page_copy