Skip to content

Commit

Permalink
new query works
Browse files Browse the repository at this point in the history
  • Loading branch information
Wiessfelt, Katie committed Sep 30, 2024
1 parent b0923b6 commit d4c6493
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 30 deletions.
5 changes: 3 additions & 2 deletions castle/cms/indexing/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,12 @@
<adapter name="image_info" factory=".indexers.image_info" />
<adapter name="has_custom_markup" factory=".indexers.has_custom_markup" />
<adapter name="querylist_searchabletext" factory=".indexers.press_release_body_content" />
<!-- <adapter name="querylist_searchabletext" factory=".indexers.file_body_content" />
<adapter name="querylist_searchabletext" factory=".indexers.file_body_content" />
<adapter name="querylist_searchabletext" factory=".indexers.image_body_content" />
<adapter name="querylist_searchabletext" factory=".indexers.video_body_content" />
<adapter name="querylist_searchabletext" factory=".indexers.audio_body_content" />
<adapter name="querylist_searchabletext" factory=".indexers.story_body_content" />
<adapter name="querylist_searchabletext" factory=".indexers.speech_body_content" /> -->
<adapter name="querylist_searchabletext" factory=".indexers.speech_body_content" />
<adapter name="querylist_searchabletext" factory=".indexers.testimony_body_content" />

</configure>
53 changes: 26 additions & 27 deletions castle/cms/indexing/indexers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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))
Expand All @@ -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')
5 changes: 4 additions & 1 deletion castle/cms/upgrades/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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')

0 comments on commit d4c6493

Please sign in to comment.