kopia lustrzana https://github.com/wagtail/wagtail
Fix #3167 - Ensure TableBlock content is indexed
Changes include: * adding the 'get_searchable_content' method on the TableBlock * ... and the related testpull/3071/merge
rodzic
3d37f84311
commit
4e23e46159
|
@ -31,6 +31,7 @@ Changelog
|
||||||
* Fix: Users with only publish permission are no longer given implicit permission to delete pages (Matt Westcott)
|
* Fix: Users with only publish permission are no longer given implicit permission to delete pages (Matt Westcott)
|
||||||
* Fix: `search_garbage_collect` management command now works when wagtailsearchpromotions is not installed (Morgan Aubert)
|
* Fix: `search_garbage_collect` management command now works when wagtailsearchpromotions is not installed (Morgan Aubert)
|
||||||
* Fix: `wagtail.contrib.settings` context processor no longer fails when `request.site` is unavailable (Diederik van der Boor)
|
* Fix: `wagtail.contrib.settings` context processor no longer fails when `request.site` is unavailable (Diederik van der Boor)
|
||||||
|
* Fix: `TableBlock` content is now indexed for search (Morgan Aubert)
|
||||||
|
|
||||||
|
|
||||||
1.7 (20.10.2016)
|
1.7 (20.10.2016)
|
||||||
|
|
|
@ -62,6 +62,8 @@ Bug fixes
|
||||||
* Users with only publish permission are no longer given implicit permission to delete pages (Matt Westcott)
|
* Users with only publish permission are no longer given implicit permission to delete pages (Matt Westcott)
|
||||||
* ``search_garbage_collect`` management command now works when wagtailsearchpromotions is not installed (Morgan Aubert)
|
* ``search_garbage_collect`` management command now works when wagtailsearchpromotions is not installed (Morgan Aubert)
|
||||||
* ``wagtail.contrib.settings`` context processor no longer fails when ``request.site`` is unavailable (Diederik van der Boor)
|
* ``wagtail.contrib.settings`` context processor no longer fails when ``request.site`` is unavailable (Diederik van der Boor)
|
||||||
|
* ``TableBlock`` content is now indexed for search (Morgan Aubert)
|
||||||
|
|
||||||
|
|
||||||
Upgrade considerations
|
Upgrade considerations
|
||||||
======================
|
======================
|
||||||
|
|
|
@ -74,6 +74,12 @@ class TableBlock(FieldBlock):
|
||||||
def is_html_renderer(self):
|
def is_html_renderer(self):
|
||||||
return self.table_options['renderer'] == 'html'
|
return self.table_options['renderer'] == 'html'
|
||||||
|
|
||||||
|
def get_searchable_content(self, value):
|
||||||
|
content = []
|
||||||
|
for row in value.get('data', []):
|
||||||
|
content.extend([v for v in row if v])
|
||||||
|
return content
|
||||||
|
|
||||||
def render(self, value, context=None):
|
def render(self, value, context=None):
|
||||||
template = getattr(self.meta, 'template', None)
|
template = getattr(self.meta, 'template', None)
|
||||||
if template and value:
|
if template and value:
|
||||||
|
|
|
@ -172,6 +172,14 @@ class TestTableBlock(TestTableBlockRenderingBase):
|
||||||
block2 = TableBlock(table_options=new_options)
|
block2 = TableBlock(table_options=new_options)
|
||||||
self.assertEqual(block2.is_html_renderer(), True)
|
self.assertEqual(block2.is_html_renderer(), True)
|
||||||
|
|
||||||
|
def test_searchable_content(self):
|
||||||
|
value = {'first_row_is_table_header': False, 'first_col_is_header': False,
|
||||||
|
'data': [['Test 1', 'Test 2', 'Test 3'], [None, 'Bar', None],
|
||||||
|
[None, 'Foo', None]]}
|
||||||
|
block = TableBlock()
|
||||||
|
content = block.get_searchable_content(value)
|
||||||
|
self.assertEqual(content, ['Test 1', 'Test 2', 'Test 3', 'Bar', 'Foo', ])
|
||||||
|
|
||||||
def test_render_with_extra_context(self):
|
def test_render_with_extra_context(self):
|
||||||
"""
|
"""
|
||||||
Test that extra context variables passed in block.render are passed through
|
Test that extra context variables passed in block.render are passed through
|
||||||
|
|
Ładowanie…
Reference in New Issue