kopia lustrzana https://github.com/wagtail/wagtail
added __eq__ for comparison of the source of RichText and also added compare test case
Fixes #10523pull/10542/head
rodzic
bd76b020af
commit
7b3b55ff93
|
@ -13,6 +13,7 @@ Changelog
|
|||
* Fix: Remove comment button on InlinePanel fields (Sage Abdullah)
|
||||
* Fix: Fix missing link to `UsageView` from `EditView` for snippets (Christer Jensen)
|
||||
* Fix: Prevent lowercase conversions of IndexView column headers (Virag Jain)
|
||||
* Fix: Ensure that `RichText` objects with the same values compare as equal (NikilTn)
|
||||
* Docs: Document how to add non-ModelAdmin views to a `ModelAdminGroup` (Onno Timmerman)
|
||||
* Docs: Document how to add StructBlock data to a StreamField (Ramon Wenger)
|
||||
* Docs: Update ReadTheDocs settings to v2 to resolve urllib3 issue in linkcheck extension (Thibaud Colas)
|
||||
|
|
|
@ -715,6 +715,7 @@ Contributors
|
|||
* Lukas von Allmen
|
||||
* Ester Beltrami
|
||||
* Justin Koestinger
|
||||
* NikilTn
|
||||
|
||||
Translators
|
||||
===========
|
||||
|
|
|
@ -28,6 +28,7 @@ FieldPanels can now be marked as read-only with the `read_only=True` keyword arg
|
|||
* Remove comment button on InlinePanel fields (Sage Abdullah)
|
||||
* Fix missing link to `UsageView` from `EditView` for snippets (Christer Jensen)
|
||||
* Prevent lowercase conversions of IndexView column headers (Virag Jain)
|
||||
* Ensure that `RichText` objects with the same values compare as equal (NikilTn)
|
||||
|
||||
### Documentation
|
||||
|
||||
|
|
|
@ -99,6 +99,11 @@ class RichText:
|
|||
def __bool__(self):
|
||||
return bool(self.source)
|
||||
|
||||
def __eq__(self, other):
|
||||
if isinstance(other, RichText):
|
||||
return self.source == other.source
|
||||
return False
|
||||
|
||||
|
||||
class EntityHandler:
|
||||
"""
|
||||
|
|
|
@ -131,6 +131,14 @@ class TestRichTextValue(TestCase):
|
|||
value = RichText("<p>wagtail</p>")
|
||||
self.assertTrue(value)
|
||||
|
||||
def test_compare_value(self):
|
||||
value1 = RichText("<p>wagtail</p>")
|
||||
value2 = RichText("<p>wagtail</p>")
|
||||
value3 = RichText("<p>django</p>")
|
||||
self.assertNotEqual(value1, value3)
|
||||
self.assertNotEqual(value1, 12345)
|
||||
self.assertEqual(value1, value2)
|
||||
|
||||
|
||||
class TestFeatureRegistry(TestCase):
|
||||
def test_register_rich_text_features_hook(self):
|
||||
|
|
Ładowanie…
Reference in New Issue