kopia lustrzana https://github.com/wagtail/wagtail
Added __bool__ method for proper evaluating the RichText object value
rodzic
6ae36c0baa
commit
33f53a6e78
|
@ -19,6 +19,7 @@ Changelog
|
||||||
* Fix: Fixed incorrect CSS path on ModelAdmin's "choose a parent page" view
|
* Fix: Fixed incorrect CSS path on ModelAdmin's "choose a parent page" view
|
||||||
* Fix: Prevent empty redirect by overnormalisation (Franklin Kingma, Ludolf Takens)
|
* Fix: Prevent empty redirect by overnormalisation (Franklin Kingma, Ludolf Takens)
|
||||||
* Fix: "Remove link" button in rich text editor didn't trigger "edit" event, leading to the change to sometimes not be persisted (Matt Westcott)
|
* Fix: "Remove link" button in rich text editor didn't trigger "edit" event, leading to the change to sometimes not be persisted (Matt Westcott)
|
||||||
|
* Fix: `RichText` values can now be correctly evaluated as booleans (Mike Dingjan, Bertrand Bordage)
|
||||||
|
|
||||||
|
|
||||||
1.5.2 (08.06.2016)
|
1.5.2 (08.06.2016)
|
||||||
|
|
|
@ -146,6 +146,7 @@ Contributors
|
||||||
* Franklin Kingma
|
* Franklin Kingma
|
||||||
* Ludolf Takens
|
* Ludolf Takens
|
||||||
* Oktay Altay
|
* Oktay Altay
|
||||||
|
* Bertrand Bordage
|
||||||
|
|
||||||
Translators
|
Translators
|
||||||
===========
|
===========
|
||||||
|
|
|
@ -34,6 +34,7 @@ Bug fixes
|
||||||
* Fixed incorrect CSS path on ModelAdmin's "choose a parent page" view
|
* Fixed incorrect CSS path on ModelAdmin's "choose a parent page" view
|
||||||
* Prevent empty redirect by overnormalisation
|
* Prevent empty redirect by overnormalisation
|
||||||
* "Remove link" button in rich text editor didn't trigger "edit" event, leading to the change to sometimes not be persisted (Matt Westcott)
|
* "Remove link" button in rich text editor didn't trigger "edit" event, leading to the change to sometimes not be persisted (Matt Westcott)
|
||||||
|
* ``RichText`` values can now be correctly evaluated as booleans (Mike Dingjan, Bertrand Bordage)
|
||||||
|
|
||||||
|
|
||||||
Upgrade considerations
|
Upgrade considerations
|
||||||
|
|
|
@ -195,3 +195,7 @@ class RichText(object):
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return mark_safe('<div class="rich-text">' + expand_db_html(self.source) + '</div>')
|
return mark_safe('<div class="rich-text">' + expand_db_html(self.source) + '</div>')
|
||||||
|
|
||||||
|
def __bool__(self):
|
||||||
|
return bool(self.source)
|
||||||
|
__nonzero__ = __bool__
|
||||||
|
|
|
@ -145,3 +145,10 @@ class TestRichTextValue(TestCase):
|
||||||
result,
|
result,
|
||||||
'<div class="rich-text"><p>Merry <a href="/events/christmas/">Christmas</a>!</p></div>'
|
'<div class="rich-text"><p>Merry <a href="/events/christmas/">Christmas</a>!</p></div>'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def test_evaluate_value(self):
|
||||||
|
value = RichText(None)
|
||||||
|
self.assertFalse(value)
|
||||||
|
|
||||||
|
value = RichText('<p>wagtail</p>')
|
||||||
|
self.assertTrue(value)
|
||||||
|
|
Ładowanie…
Reference in New Issue