mirror of
https://github.com/wagtail/wagtail.git
synced 2024-11-22 11:07:57 +01:00
Clear submitted_for_moderation and approved_go_live_at of copied revisions
This commit is contained in:
parent
3857576f90
commit
28b0f29d18
@ -3,3 +3,4 @@ coverage==3.7.1
|
||||
flake8==2.2.1
|
||||
mock==1.0.1
|
||||
python-dateutil==2.2
|
||||
pytz==2014.7
|
||||
|
1
tox.ini
1
tox.ini
@ -15,6 +15,7 @@ base =
|
||||
elasticsearch==1.1.0
|
||||
mock==1.0.1
|
||||
python-dateutil==2.2
|
||||
pytz==2014.7
|
||||
Embedly
|
||||
coverage
|
||||
|
||||
|
@ -635,6 +635,8 @@ class Page(six.with_metaclass(PageBase, MP_Node, ClusterableModel, index.Indexed
|
||||
if copy_revisions:
|
||||
for revision in self.revisions.all():
|
||||
revision.pk = None
|
||||
revision.submitted_for_moderation = False
|
||||
revision.approved_go_live_at = None
|
||||
revision.page = page_copy
|
||||
revision.save()
|
||||
|
||||
|
@ -1,4 +1,7 @@
|
||||
import warnings
|
||||
import datetime
|
||||
|
||||
import pytz
|
||||
|
||||
from django.test import TestCase, Client
|
||||
from django.test.utils import override_settings
|
||||
@ -426,6 +429,32 @@ class TestCopyPage(TestCase):
|
||||
# Check that the revisions weren't removed from old page
|
||||
self.assertEqual(christmas_event.revisions.count(), 1, "Revisions were removed from the original page")
|
||||
|
||||
def test_copy_page_copies_revisions_and_doesnt_submit_for_moderation(self):
|
||||
christmas_event = EventPage.objects.get(url_path='/home/events/christmas/')
|
||||
christmas_event.save_revision(submitted_for_moderation=True)
|
||||
|
||||
# Copy it
|
||||
new_christmas_event = christmas_event.copy(update_attrs={'title': "New christmas event", 'slug': 'new-christmas-event'})
|
||||
|
||||
# Check that the old revision is still submitted for moderation
|
||||
self.assertTrue(christmas_event.revisions.first().submitted_for_moderation)
|
||||
|
||||
# Check that the new revision is not submitted for moderation
|
||||
self.assertFalse(new_christmas_event.revisions.first().submitted_for_moderation)
|
||||
|
||||
def test_copy_page_copies_revisions_and_doesnt_schedule(self):
|
||||
christmas_event = EventPage.objects.get(url_path='/home/events/christmas/')
|
||||
christmas_event.save_revision(approved_go_live_at=datetime.datetime(2014, 9, 16, 9, 12, 00, tzinfo=pytz.utc))
|
||||
|
||||
# Copy it
|
||||
new_christmas_event = christmas_event.copy(update_attrs={'title': "New christmas event", 'slug': 'new-christmas-event'})
|
||||
|
||||
# Check that the old revision is still scheduled
|
||||
self.assertEqual(christmas_event.revisions.first().approved_go_live_at, datetime.datetime(2014, 9, 16, 9, 12, 00, tzinfo=pytz.utc))
|
||||
|
||||
# Check that the new revision is not scheduled
|
||||
self.assertEqual(new_christmas_event.revisions.first().approved_go_live_at, None)
|
||||
|
||||
def test_copy_page_copies_child_objects_with_nonspecific_class(self):
|
||||
# Get chrismas page as Page instead of EventPage
|
||||
christmas_event = Page.objects.get(url_path='/home/events/christmas/')
|
||||
|
Loading…
Reference in New Issue
Block a user