diff --git a/castle/cms/indexing/configure.zcml b/castle/cms/indexing/configure.zcml index e7c37b239..abeb81987 100644 --- a/castle/cms/indexing/configure.zcml +++ b/castle/cms/indexing/configure.zcml @@ -43,11 +43,12 @@ - + + diff --git a/castle/cms/indexing/indexers.py b/castle/cms/indexing/indexers.py index e38b88851..cdb1d1436 100644 --- a/castle/cms/indexing/indexers.py +++ b/castle/cms/indexing/indexers.py @@ -22,10 +22,10 @@ from castle.cms.interfaces import ITrashed import logging from fbigov.contenttypes.interfaces.pressrelease import IPressRelease -# from castle.cms.interfaces import IVideo, IAudio -# from fbigov.contenttypes.interfaces.speech import ISpeech -# from fbigov.contenttypes.interfaces.story import IStory -# from fbigov.contenttypes.interfaces.testimony import ITestimony +from castle.cms.interfaces import IVideo, IAudio +from fbigov.contenttypes.interfaces.speech import ISpeech +from fbigov.contenttypes.interfaces.story import IStory +from fbigov.contenttypes.interfaces.testimony import ITestimony @indexer(IItem) @@ -231,10 +231,8 @@ def has_custom_markup(image): # full content query indexers -def get_searchable_text(obj, _type): - searchable_text = getattr(obj, 'SearchableText', '').__call__() - logging.info('setting display_full_content for {} object'.format(_type)) - return searchable_text +def get_description(obj, _type): + return obj.Description() def get_raw_text(obj, _type): logging.info('setting display_full_content for {} object'.format(_type)) @@ -251,29 +249,30 @@ def press_release_body_content(obj): return get_raw_text(obj, 'Press Release') @indexer(IFile) -def file_body_content(item): - import pdb; pdb.set_trace() - return get_searchable_text(item, 'File') - -# @indexer(IImage) -# def image_body_content(item): -# return get_searchable_text(item, 'Image') +def file_body_content(obj): + return 'Click here for more information' -# @indexer(IVideo) -# def video_body_content(item): -# return get_searchable_text(item, 'Video') +@indexer(IImage) +def image_body_content(obj): + return get_description(obj, 'Image') +@indexer(IVideo) +def video_body_content(obj): + return get_description(obj, 'Video') -# @indexer(IAudio) -# def audio_body_content(item): -# return get_searchable_text(item, 'Audio') +@indexer(IAudio) +def audio_body_content(obj): + return get_description(obj, 'Audio') -# @indexer(IStory) -# def story_body_content(item): -# return get_searchable_text(item, 'Story') +@indexer(IStory) +def story_body_content(obj): + return get_description(obj, 'Story') +@indexer(ISpeech) +def speech_body_content(obj): + return get_raw_text(obj, 'Speech') -# @indexer(ISpeech) -# def speech_body_content(item): -# return get_searchable_text(item, 'Speech') +@indexer(ITestimony) +def testimony_body_content(obj): + return get_description(obj, 'Story') diff --git a/castle/cms/upgrades/__init__.py b/castle/cms/upgrades/__init__.py index a8c11d66a..538e75c11 100644 --- a/castle/cms/upgrades/__init__.py +++ b/castle/cms/upgrades/__init__.py @@ -13,6 +13,7 @@ from castle.cms.interfaces import IVideo, IAudio from fbigov.contenttypes.interfaces.speech import ISpeech from fbigov.contenttypes.interfaces.story import IStory +from fbigov.contenttypes.interfaces.testimony import ITestimony from plone.app.contenttypes.interfaces import IFile, IImage CASTLE_LOGGER = getLogger('castle.cms') @@ -149,8 +150,10 @@ def upgrade_3011(site, logger=CASTLE_LOGGER): def upgrade_3017b(site, logger=CASTLE_LOGGER): logger.info('3017b') - query = api.content.find(object_provides=[IFile]) # , IPressRelease, IImage, IVideo, IAudio, IStory, ISpeech]) + query = api.content.find( + object_provides=[IFile, IPressRelease, IImage, IVideo, IAudio, IStory, ISpeech, ITestimony]) for item in query: + print('reindexing object {}'.format(item.Title)) obj = item.getObject() obj.reindexObject(idxs=['querylist_searchabletext']) print('upgrade completed') \ No newline at end of file