kopia lustrzana https://github.com/wagtail/wagtail
Set owner of copied pages to the user who copied them
rodzic
5221abeecf
commit
dabfb5f2b9
|
@ -837,6 +837,9 @@ class TestPageCopy(TestCase, WagtailTestUtils):
|
|||
# Check that the copy exists
|
||||
self.assertTrue(self.root_page.get_children().filter(slug='hello-world-2').exists())
|
||||
|
||||
# Check that the owner of the page is set correctly
|
||||
self.assertEqual(self.root_page.get_children().filter(slug='hello-world-2').first().owner, self.user)
|
||||
|
||||
def test_page_copy_post_existing_slug(self):
|
||||
# This tests the existing slug checking on page copy
|
||||
|
||||
|
|
|
@ -660,7 +660,7 @@ def copy(request, page_id):
|
|||
# Check if user is submitting
|
||||
if request.method == 'POST' and form.is_valid():
|
||||
# Copy the page
|
||||
page.copy(
|
||||
new_page = page.copy(
|
||||
recursive=form.cleaned_data['copy_subpages'],
|
||||
update_attrs={
|
||||
'title': form.cleaned_data['new_title'],
|
||||
|
@ -668,6 +668,9 @@ def copy(request, page_id):
|
|||
}
|
||||
)
|
||||
|
||||
# Assign usef of this request as the owner of all the new pages
|
||||
new_page.get_descendants(inclusive=True).update(owner=request.user)
|
||||
|
||||
# Give a success message back to the user
|
||||
if form.cleaned_data['copy_subpages']:
|
||||
messages.success(request, _("Page '{0}' and {1} subpages copied.").format(page.title, subpage_count))
|
||||
|
|
Ładowanie…
Reference in New Issue