mirror of
https://github.com/Hopiu/wagtail.git
synced 2026-05-12 17:23:15 +00:00
make block names work properly when passed as binary strings
This commit is contained in:
parent
64d5ffe2b2
commit
342fd7a061
2 changed files with 10 additions and 1 deletions
|
|
@ -115,7 +115,7 @@ class Block(six.with_metaclass(BaseBlock, object)):
|
|||
def set_name(self, name):
|
||||
self.name = name
|
||||
if not self.meta.label:
|
||||
self.label = capfirst(name.replace('_', ' '))
|
||||
self.label = capfirst(force_text(name).replace('_', ' '))
|
||||
|
||||
@property
|
||||
def media(self):
|
||||
|
|
|
|||
|
|
@ -408,6 +408,15 @@ class TestStreamBlock(unittest.TestCase):
|
|||
|
||||
self.assertEqual(list(block.child_blocks.keys()), ['heading', 'paragraph'])
|
||||
|
||||
def test_initialisation_with_binary_string_names(self):
|
||||
# migrations will sometimes write out names as binary strings, just to keep us on our toes
|
||||
block = blocks.StreamBlock([
|
||||
(b'heading', blocks.CharBlock()),
|
||||
(b'paragraph', blocks.CharBlock()),
|
||||
])
|
||||
|
||||
self.assertEqual(list(block.child_blocks.keys()), [b'heading', b'paragraph'])
|
||||
|
||||
def test_initialisation_from_subclass(self):
|
||||
class ArticleBlock(blocks.StreamBlock):
|
||||
heading = blocks.CharBlock()
|
||||
|
|
|
|||
Loading…
Reference in a new issue