mirror of
https://github.com/Hopiu/wagtail.git
synced 2026-05-12 09:13:14 +00:00
Only give searchable content for text fields
This commit is contained in:
parent
3843123e41
commit
23c632b95a
2 changed files with 11 additions and 5 deletions
|
|
@ -353,9 +353,6 @@ class FieldBlock(Block):
|
|||
def clean(self, value):
|
||||
return self.field.clean(value)
|
||||
|
||||
def get_searchable_content(self, value):
|
||||
return [value]
|
||||
|
||||
|
||||
class CharBlock(FieldBlock):
|
||||
def __init__(self, required=True, help_text=None, max_length=None, min_length=None, **kwargs):
|
||||
|
|
@ -363,11 +360,16 @@ class CharBlock(FieldBlock):
|
|||
self.field = forms.CharField(required=required, help_text=help_text, max_length=max_length, min_length=min_length)
|
||||
super(CharBlock, self).__init__(**kwargs)
|
||||
|
||||
def get_searchable_content(self, value):
|
||||
return [value]
|
||||
|
||||
|
||||
class URLBlock(FieldBlock):
|
||||
def __init__(self, required=True, help_text=None, max_length=None, min_length=None, **kwargs):
|
||||
self.field = forms.URLField(required=required, help_text=help_text, max_length=max_length, min_length=min_length)
|
||||
super(URLBlock, self).__init__(**kwargs)
|
||||
|
||||
|
||||
class RichTextBlock(FieldBlock):
|
||||
@cached_property
|
||||
def field(self):
|
||||
|
|
@ -377,6 +379,10 @@ class RichTextBlock(FieldBlock):
|
|||
def render_basic(self, value):
|
||||
return mark_safe('<div class="rich-text">' + expand_db_html(value) + '</div>')
|
||||
|
||||
def get_searchable_content(self, value):
|
||||
return [value]
|
||||
|
||||
|
||||
class RawHTMLBlock(FieldBlock):
|
||||
def __init__(self, required=True, help_text=None, max_length=None, min_length=None, **kwargs):
|
||||
self.field = forms.CharField(
|
||||
|
|
|
|||
|
|
@ -292,7 +292,7 @@ class TestStructBlock(unittest.TestCase):
|
|||
'link': 'http://www.wagtail.io',
|
||||
})
|
||||
|
||||
self.assertEqual(content, ["Wagtail site", "http://www.wagtail.io"])
|
||||
self.assertEqual(content, ["Wagtail site"])
|
||||
|
||||
|
||||
class TestListBlock(unittest.TestCase):
|
||||
|
|
@ -447,7 +447,7 @@ class TestListBlock(unittest.TestCase):
|
|||
},
|
||||
])
|
||||
|
||||
self.assertEqual(content, ["Wagtail", "http://www.wagtail.io", "Django", "http://www.djangoproject.com"])
|
||||
self.assertEqual(content, ["Wagtail", "Django"])
|
||||
|
||||
|
||||
class TestStreamBlock(unittest.TestCase):
|
||||
|
|
|
|||
Loading…
Reference in a new issue