kopia lustrzana https://github.com/wagtail/wagtail
Preserve `features` & `editor` kwargs on RichTextField.clone() (#7272)
rodzic
a1cd95646b
commit
fee65a9345
|
@ -28,6 +28,7 @@ Changelog
|
|||
* Fix: Respect cache_age parameters on embeds (Gordon Pendleton)
|
||||
* Fix: Page comparison view now reflects request-level customisations to edit handlers (Matt Westcott)
|
||||
* Fix: Add `block.super` to remaining `extra_js` & `extra_css` blocks (Andrew Stone)
|
||||
* Fix: Ensure that `editor` and `features` arguments on RichTextField are preserved by `clone()` (Daniel)
|
||||
|
||||
|
||||
2.13.3 (05.07.2021)
|
||||
|
|
|
@ -39,6 +39,7 @@ Bug fixes
|
|||
* Respect cache_age parameters on embeds (Gordon Pendleton)
|
||||
* Page comparison view now reflects request-level customisations to edit handlers (Matt Westcott)
|
||||
* Add ``block.super`` to remaining ``extra_js`` & ``extra_css`` blocks (Andrew Stone)
|
||||
* Ensure that ``editor`` and ``features`` arguments on RichTextField are preserved by ``clone()`` (Daniel)
|
||||
|
||||
Upgrade considerations
|
||||
======================
|
||||
|
|
|
@ -10,11 +10,20 @@ from wagtail.core.rich_text import get_text_for_indexing
|
|||
|
||||
class RichTextField(models.TextField):
|
||||
def __init__(self, *args, **kwargs):
|
||||
# 'editor' and 'features' are popped before super().__init__ has chance to capture them
|
||||
# for use in deconstruct(). This is intentional - they would not be useful in migrations
|
||||
# and retrospectively adding them would generate unwanted migration noise
|
||||
self.editor = kwargs.pop('editor', 'default')
|
||||
self.features = kwargs.pop('features', None)
|
||||
# TODO: preserve 'editor' and 'features' when deconstructing for migrations
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
def clone(self):
|
||||
name, path, args, kwargs = self.deconstruct()
|
||||
# add back the 'features' and 'editor' kwargs that were not preserved by deconstruct()
|
||||
kwargs["features"] = self.features
|
||||
kwargs["editor"] = self.editor
|
||||
return self.__class__(*args, **kwargs)
|
||||
|
||||
def formfield(self, **kwargs):
|
||||
from wagtail.admin.rich_text import get_rich_text_editor_widget
|
||||
defaults = {'widget': get_rich_text_editor_widget(self.editor, features=self.features)}
|
||||
|
|
Ładowanie…
Reference in New Issue