Hooked blocks get_searchable_content into wagtailsearch

This commit is contained in:
Karl Hobley 2015-02-10 16:50:32 +00:00
parent acdf4bbefe
commit 3843123e41
2 changed files with 7 additions and 1 deletions

View file

@ -82,3 +82,6 @@ class StreamField(with_metaclass(models.SubfieldBase, models.Field)):
def value_to_string(self, obj):
value = self._get_val_from_obj(obj)
return self.get_prep_value(value)
def get_searchable_content(self, value):
return self.stream_block.get_searchable_content(value)

View file

@ -116,7 +116,10 @@ class BaseField(object):
def get_value(self, obj):
try:
field = self.get_field(obj.__class__)
return field._get_val_from_obj(obj)
value = field._get_val_from_obj(obj)
if hasattr(field, 'get_searchable_content'):
value = field.get_searchable_content(value)
return value
except models.fields.FieldDoesNotExist:
value = getattr(obj, self.field_name, None)
if hasattr(value, '__call__'):