StaticBlock renders empty in templates (#12425)

pull/12429/head
Sævar Öfjörð Magnússon 2024-10-18 11:05:29 +00:00 zatwierdzone przez Matt Westcott
rodzic ee635534af
commit 207e9e50d9
4 zmienionych plików z 10 dodań i 0 usunięć

Wyświetl plik

@ -128,6 +128,7 @@ Changelog
* Add "soft" client-side validation for `StreamBlock` / `ListBlock` `min_num` / `max_num` (Matt Westcott)
* Log accessibility checker results in the console to help developers with troubleshooting (Thibaud Colas)
* Disable pointer events on checker highlights to simplify DevTools inspections (Thibaud Colas)
* `StaticBlock` now renders nothing by default when no template is specified (Sævar Öfjörð Magnússon)
* Fix: Make `WAGTAILIMAGES_CHOOSER_PAGE_SIZE` setting functional again (Rohit Sharma)
* Fix: Enable `richtext` template tag to convert lazy translation values (Benjamin Bach)
* Fix: Ensure permission labels on group permissions page are translated where available (Matt Westcott)

Wyświetl plik

@ -71,6 +71,7 @@ This feature was developed by Bart Cieliński, alexkiro, and Sage Abdullah.
* Prompt the user about unsaved changes when editing snippets (Sage Abdullah)
* Add support for specifying different preview modes to the "View draft" URL for pages (Robin Varghese)
* Implement new designs for the footer actions dropdown with more contrast and larger text (Sage Abdullah)
* `StaticBlock` now renders nothing by default when no template is specified (Sævar Öfjörð Magnússon)
### Bug fixes

Wyświetl plik

@ -33,6 +33,9 @@ class StaticBlock(Block):
def normalize(self, value):
return None
def render_basic(self, value, context=None):
return ""
class Meta:
admin_text = None
default = None

Wyświetl plik

@ -5015,6 +5015,11 @@ class TestStaticBlock(unittest.TestCase):
result = block.render(None)
self.assertEqual(result, "<p>PostsStaticBlock template</p>")
def test_render_without_template(self):
block = blocks.StaticBlock()
result = block.render(None)
self.assertEqual(result, "")
def test_serialize(self):
block = blocks.StaticBlock()
result = block.get_prep_value(None)