mirror of
https://github.com/wagtail/wagtail.git
synced 2024-11-29 01:22:07 +01:00
Fix exclude_fields_in_copy
issues with default/unique values
- Ensure that revisions also exclude the field as an initial revision is created on page creation - Fixes #11428 - Fixes #10922 - See also #11323 & #11323
This commit is contained in:
parent
fa267c9b1a
commit
175b7ac044
@ -80,6 +80,7 @@ Changelog
|
||||
* Fix: Ensure the panel anchor button sizes meet accessibility guidelines for minimum dimensions (Nandini Arora)
|
||||
* Fix: Raise a 404 for bulk actions for models which don't exist instead of throwing a 500 error (Alex Tomkins)
|
||||
* Fix: Raise a `SiteSetting.DoesNotExist` error when retrieving settings for an unrecognised site (Nick Smith)
|
||||
* Fix: Ensure that defaulted or unique values declared in `exclude_fields_in_copy` are correctly excluded in new copies, resolving to the default value (Elhussein Almasri)
|
||||
* Docs: Document, for contributors, the use of translate string literals passed as arguments to tags and filters using `_()` within templates (Chiemezuo Akujobi)
|
||||
* Docs: Document all features for the Documents app in one location (Neeraj Yetheendran)
|
||||
* Docs: Add section to testing docs about creating pages and working with page content (Mariana Bedran Lesche)
|
||||
|
@ -113,6 +113,7 @@ Thank you to Thibaud Colas, Badr Fourane, and Sage Abdullah for their work on th
|
||||
* Ensure the panel anchor button sizes meet accessibility guidelines for minimum dimensions (Nandini Arora)
|
||||
* Raise a 404 for bulk actions for models which don't exist instead of throwing a 500 error (Alex Tomkins)
|
||||
* Raise a `SiteSetting.DoesNotExist` error when retrieving settings for an unrecognised site (Nick Smith)
|
||||
* Ensure that defaulted or unique values declared in `exclude_fields_in_copy` are correctly excluded in new copies, resolving to the default value (Elhussein Almasri)
|
||||
|
||||
|
||||
### Documentation
|
||||
|
@ -221,6 +221,14 @@ class CopyPageAction:
|
||||
child_object["translation_key"]
|
||||
)
|
||||
|
||||
for exclude_field in specific_page.exclude_fields_in_copy:
|
||||
if exclude_field in revision_content and hasattr(
|
||||
page_copy, exclude_field
|
||||
):
|
||||
revision_content[exclude_field] = getattr(
|
||||
page_copy, exclude_field, None
|
||||
)
|
||||
|
||||
revision.content = revision_content
|
||||
|
||||
# Save
|
||||
|
@ -1909,13 +1909,16 @@ class TestCopyPage(TestCase):
|
||||
special_field="Context is for Kings",
|
||||
)
|
||||
)
|
||||
page.save_revision()
|
||||
new_page = page.copy(to=homepage, update_attrs={"slug": "disco-2"})
|
||||
exclude_field = new_page.latest_revision.content["special_field"]
|
||||
|
||||
self.assertEqual(page.title, new_page.title)
|
||||
self.assertNotEqual(page.id, new_page.id)
|
||||
self.assertNotEqual(page.path, new_page.path)
|
||||
# special_field is in the list to be excluded
|
||||
self.assertNotEqual(page.special_field, new_page.special_field)
|
||||
self.assertEqual(new_page.special_field, exclude_field)
|
||||
|
||||
def test_page_with_generic_relation(self):
|
||||
"""Test that a page with a GenericRelation will have that relation ignored when
|
||||
|
Loading…
Reference in New Issue
Block a user