Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Dexterity Contents in Catalog Indexers #1488

Merged
merged 2 commits into from
Dec 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Changelog

**Changed**

- #1488 Support Dexterity Contents in Catalog Indexers
- #1486 Clean-up of indexes and metadata from `setup_catalog`

**Removed**
Expand Down
17 changes: 8 additions & 9 deletions bika/lims/catalog/indexers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,26 @@
# Copyright 2018-2019 by it's authors.
# Some rights reserved, see README and LICENSE.

from Products.Archetypes.interfaces import IBaseObject
from Products.CMFPlone.CatalogTool import sortable_title as plone_sortable_title
from Products.CMFPlone.utils import safe_callable
from plone.indexer import indexer

from bika.lims import api
from bika.lims import logger
from bika.lims.api import safe_getattr
from bika.lims.catalog.bika_catalog import BIKA_CATALOG
from bika.lims.interfaces import IBikaCatalog
from plone.indexer import indexer
from Products.CMFCore.interfaces import IContentish
from Products.CMFPlone.CatalogTool import \
sortable_title as plone_sortable_title
from Products.CMFPlone.utils import safe_callable


@indexer(IBaseObject)
@indexer(IContentish)
def is_active(instance):
"""Returns False if the status of the instance is 'cancelled' or 'inactive'.
Otherwise returns True
"""
return api.is_active(instance)


@indexer(IBaseObject)
@indexer(IContentish)
def sortable_title(instance):
"""Uses the default Plone sortable_text index lower-case
"""
Expand All @@ -62,7 +61,7 @@ def sortable_sortkey_title(instance):
return "{:010.3f}{}".format(sort_key, title)


@indexer(IBaseObject, IBikaCatalog)
@indexer(IContentish, IBikaCatalog)
def listing_searchable_text(instance):
""" Retrieves all the values of metadata columns in the catalog for
wildcard searches
Expand Down
16 changes: 8 additions & 8 deletions bika/lims/catalog/indexers/bikasetup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
#
# Copyright 2018-2019 by it's authors.
# Some rights reserved, see README and LICENSE.
from Products.Archetypes.interfaces import IBaseObject
from plone.indexer import indexer

from bika.lims import api
from bika.lims.catalog.bikasetup_catalog import SETUP_CATALOG
Expand All @@ -31,15 +29,17 @@
from bika.lims.interfaces import IHavePrice
from bika.lims.interfaces import IInstrument
from bika.lims.interfaces import ISampleTypeAwareMixin
from plone.indexer import indexer
from Products.CMFCore.interfaces import IContentish


@indexer(ISampleTypeAwareMixin, IBikaSetupCatalog)
def sampletype_uid(instance):
"""Returns the list of SampleType UIDs the instance is assigned to

This is a KeywordIndex, so it will be indexed as a list, even if only one
SampleType can be assigned to the instance. Moreover, if the instance has no
SampleType assigned, it returns a tuple with a None value. This allows
SampleType can be assigned to the instance. Moreover, if the instance has
no SampleType assigned, it returns a tuple with a None value. This allows
searches for `MissingValue` entries too.
"""
sample_type = instance.getSampleType()
Expand All @@ -62,9 +62,9 @@ def method_available_uid(instance):
"""Returns a list of Method UIDs that are available for this instance

If the instance (AnalysisService) has InstrumentEntryOfResults set to True,
it returns the methods available from the instruments capable to perform the
service, as well as the methods set manually to the analysis. Otherwise, it
returns the methods assigned manually only.
it returns the methods available from the instruments capable to perform
the service, as well as the methods set manually to the analysis.
Otherwise, it returns the methods assigned manually only.

If the instance has no available method assigned, it returns a tuple with
a None value. This allows searches for `MissingValue` entries too.
Expand Down Expand Up @@ -128,7 +128,7 @@ def point_of_capture(instance):
return instance.getPointOfCapture()


@indexer(IBaseObject, IBikaSetupCatalog)
@indexer(IContentish, IBikaSetupCatalog)
def listing_searchable_text(instance):
""" Retrieves all the values of metadata columns in the catalog for
wildcard searches
Expand Down