Add BlockQuoteBlock to core block types

pull/3190/head
Scot Hacker 2016-11-28 14:31:08 -08:00 zatwierdzone przez Matt Westcott
rodzic 4e23e46159
commit 2882775842
5 zmienionych plików z 31 dodań i 1 usunięć

Wyświetl plik

@ -15,6 +15,7 @@ Changelog
* `PageChooserBlock` now accepts a `target_model` option to specify the required page type (Tim Heap)
* Modeladmin forms now respect `fields` / `exclude` options passed on custom model forms (Thejaswi Puthraya)
* Added new StreamField block type `StaticBlock` (Benoît Vogel)
* Added new StreamField block type `BlockQuoteBlock` (Scot Hacker)
* Updated Cloudflare cache module to use the v4 API (Albert O'Connor)
* Added `exclude_from_explorer` attribute to the `ModelAdmin` class to allow hiding instances of a page type from Wagtail's explorer views (Andy Babic)
* Added `above_login`, `below_login`, `fields` and `login_form` customisation blocks to the login page template (Tim Heap)

Wyświetl plik

@ -41,6 +41,7 @@ Minor features
* ``PageChooserBlock`` now accepts a ``target_model`` option to specify the required page type (Tim Heap)
* Modeladmin forms now respect ``fields`` / ``exclude`` options passed on custom model forms (Thejaswi Puthraya)
* Added new StreamField block type ``StaticBlock`` for blocks that occupy a position in a stream but otherwise have no configuration; see :ref:`streamfield_staticblock` (Benoît Vogel)
* Added new StreamField block type ``BlockQuoteBlock`` (Scot Hacker)
* Updated Cloudflare cache module to use the v4 API (Albert O'Connor)
* Added ``exclude_from_explorer`` attribute to the ``ModelAdmin`` class to allow hiding instances of a page type from Wagtail's explorer views (Andy Babic)
* Added ``above_login``, ``below_login``, ``fields`` and ``login_form`` customisation blocks to the login page template - see :doc:`/advanced_topics/customisation/admin_templates` (Tim Heap)

Wyświetl plik

@ -190,6 +190,14 @@ A text area for entering raw HTML which will be rendered unescaped in the page o
.. WARNING::
When this block is in use, there is nothing to prevent editors from inserting malicious scripts into the page, including scripts that would allow the editor to acquire administrator privileges when another administrator views the page. Do not use this block unless your editors are fully trusted.
BlockQuoteBlock
~~~~~~~~~~~~~~~
``wagtail.wagtailcore.blocks.BlockQuoteBlock``
A text field, the contents of which will be wrapped in an HTML `<blockquote>` tag pair. The keyword arguments ``required``, ``max_length``, ``min_length`` and ``help_text`` are accepted.
ChoiceBlock
~~~~~~~~~~~

Wyświetl plik

@ -139,6 +139,18 @@ class TextBlock(FieldBlock):
icon = "pilcrow"
class BlockQuoteBlock(TextBlock):
def render_basic(self, value, context=None):
if value:
return format_html('<blockquote>{0}</blockquote>', value)
else:
return ''
class Meta:
icon = "openquote"
class FloatBlock(FieldBlock):
def __init__(self, required=True, max_value=None, min_value=None, *args,
@ -600,7 +612,7 @@ block_classes = [
FieldBlock, CharBlock, URLBlock, RichTextBlock, RawHTMLBlock, ChooserBlock,
PageChooserBlock, TextBlock, BooleanBlock, DateBlock, TimeBlock,
DateTimeBlock, ChoiceBlock, EmailBlock, IntegerBlock, FloatBlock,
DecimalBlock, RegexBlock
DecimalBlock, RegexBlock, BlockQuoteBlock
]
DECONSTRUCT_ALIASES = {
cls: 'wagtail.wagtailcore.blocks.%s' % cls.__name__

Wyświetl plik

@ -221,6 +221,14 @@ class TestEmailBlock(unittest.TestCase):
block.clean("example.email.com")
class TestBlockQuoteBlock(unittest.TestCase):
def test_render(self):
block = blocks.BlockQuoteBlock()
quote = block.render("Now is the time...")
self.assertEqual(quote, "<blockquote>Now is the time...</blockquote>")
class TestFloatBlock(TestCase):
def test_type(self):
block = blocks.FloatBlock()