Skip to content

Commit

Permalink
Compatibility with Senaite catalog migration (#30)
Browse files Browse the repository at this point in the history
* Changed import of get_searchable_text_tokens

* Changed import

* Removed obsolete upgrade steps

* Updated buildout

* Updated setup.py

* Updated catalog imports

* Changelog updated

* Setup catalog with core handlers

* Let storage catalog interface inherit from ISenaiteCatalog

* New storage catalog based on Senaite base catalog

* Removed bootstrap.py

* Migrate storage catalogs

* Updated setuphandler and added uninstall handler

* Rebuild the whole catalog

* Refresh the sample catalog

* Fixed api call

* Changed base interface
  • Loading branch information
ramonski committed Nov 15, 2021
1 parent 5f2957c commit 3aceec5
Show file tree
Hide file tree
Showing 23 changed files with 186 additions and 538 deletions.
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Changelog
2.1.0 (unreleased)
------------------

- #30 Compatibility with Senaite catalog migration
- #28 Added upgrade step event subscriber
- #27 Integrate dispatch workflow from senaite.core
- #26 Disallow to modify portal content when stored/booked out samples
Expand Down
210 changes: 0 additions & 210 deletions bootstrap.py

This file was deleted.

4 changes: 2 additions & 2 deletions buildout.cfg
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[buildout]
index = https://pypi.org/simple/
extends = https://dist.plone.org/release/5.2.3/versions.cfg
extends = https://dist.plone.org/release/5.2.6/versions.cfg
find-links =
https://dist.plone.org/release/5.2.3/
https://dist.plone.org/release/5.2.6/
https://dist.plone.org/thirdparty/

parts =
Expand Down
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@
zip_safe=False,
install_requires=[
"setuptools",
"senaite.lims>=2.0.0rc3",
"archetypes.schemaextender",
"senaite.lims>2.0.0",
],
extras_require={
"test": [
Expand Down
4 changes: 2 additions & 2 deletions src/senaite/storage/adapters/utilization.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-

from bika.lims import api
from senaite.storage.catalog import SENAITE_STORAGE_CATALOG
from senaite.storage.catalog import STORAGE_CATALOG
from senaite.storage.interfaces import IStorageSamplesContainer
from senaite.storage.interfaces import IStorageUtilization
from zope.interface import implementer
Expand Down Expand Up @@ -34,7 +34,7 @@ def get_layout_containers(self):
"path": {
"query": api.get_path(self.context),
}}
brains = api.search(query, SENAITE_STORAGE_CATALOG)
brains = api.search(query, STORAGE_CATALOG)
objs = map(api.get_object, brains)
return filter(lambda o: IStorageSamplesContainer.providedBy(o), objs)

Expand Down
6 changes: 3 additions & 3 deletions src/senaite/storage/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

from bika.lims import api
from senaite.storage import logger
from senaite.storage.catalog import SENAITE_STORAGE_CATALOG
from senaite.storage.catalog import STORAGE_CATALOG
from senaite.storage.config import STORAGE_WORKFLOW_ID


Expand All @@ -41,7 +41,7 @@ def get_storage_sample(sample, as_brain=False):
"""
query = dict(portal_type="StorageSamplesContainer",
get_samples_uids=[api.get_uid(sample)])
brains = api.search(query, SENAITE_STORAGE_CATALOG)
brains = api.search(query, STORAGE_CATALOG)
if not brains:
return None
if as_brain:
Expand All @@ -52,7 +52,7 @@ def get_storage_sample(sample, as_brain=False):
def get_storage_catalog():
"""Returns the storage catalog
"""
return api.get_tool(SENAITE_STORAGE_CATALOG)
return api.get_tool(STORAGE_CATALOG)


def get_storage_workflow():
Expand Down
4 changes: 2 additions & 2 deletions src/senaite/storage/browser/container/move_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from senaite.storage import senaiteMessageFactory as _
from senaite.storage.api import get_parents
from senaite.storage.browser import BaseView
from senaite.storage.catalog import SENAITE_STORAGE_CATALOG
from senaite.storage.catalog import STORAGE_CATALOG
from senaite.storage.interfaces import IStorageContainer
from senaite.storage.interfaces import IStorageFacility
from senaite.storage.interfaces import IStorageSamplesContainer
Expand Down Expand Up @@ -144,7 +144,7 @@ def get_move_targets_for(self, container):
"portal_type": target_types,
"review_state": "active"
}
brains = api.search(query, SENAITE_STORAGE_CATALOG)
brains = api.search(query, STORAGE_CATALOG)
for brain in brains:
path = api.get_path(brain)
if path.startswith(container_path):
Expand Down
5 changes: 2 additions & 3 deletions src/senaite/storage/browser/container/samples.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@

from bika.lims import api
from bika.lims import senaiteMessageFactory as _s
from bika.lims.catalog.analysisrequest_catalog import \
CATALOG_ANALYSIS_REQUEST_LISTING
from senaite.app.listing.view import ListingView
from senaite.core.catalog import SAMPLE_CATALOG
from senaite.storage import senaiteMessageFactory as _
from senaite.storage.permissions import TransitionAddSamples

Expand All @@ -36,7 +35,7 @@ class SampleListingView(ListingView):
def __init__(self, context, request):
super(SampleListingView, self).__init__(context, request)

self.catalog = CATALOG_ANALYSIS_REQUEST_LISTING
self.catalog = SAMPLE_CATALOG

self.contentFilter = {
"UID": context.get_samples_uids(),
Expand Down
4 changes: 2 additions & 2 deletions src/senaite/storage/browser/storage/listing.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from bika.lims.utils import get_progress_bar_html
from senaite.app.listing import ListingView
from senaite.storage import senaiteMessageFactory as _
from senaite.storage.catalog import SENAITE_STORAGE_CATALOG
from senaite.storage.catalog import STORAGE_CATALOG
from senaite.storage.interfaces import IStorageUtilization


Expand All @@ -37,7 +37,7 @@ class StorageListing(ListingView):
def __init__(self, context, request):
super(StorageListing, self).__init__(context, request)

self.catalog = SENAITE_STORAGE_CATALOG
self.catalog = STORAGE_CATALOG

self.title = api.get_title(context)
self.description = api.get_description(context)
Expand Down
4 changes: 2 additions & 2 deletions src/senaite/storage/browser/viewlets/sample_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from bika.lims.browser import ulocalized_time
from plone.app.layout.viewlets import ViewletBase
from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
from senaite.storage.catalog import SENAITE_STORAGE_CATALOG
from senaite.storage.catalog import STORAGE_CATALOG


class SampleContainerViewlet(ViewletBase):
Expand All @@ -49,7 +49,7 @@ def get_sample_container_info(self):
# Search the container the sample is stored in
query = {"portal_type": "StorageSamplesContainer",
"get_samples_uids": api.get_uid(self.context)}
brains = api.search(query, SENAITE_STORAGE_CATALOG)
brains = api.search(query, STORAGE_CATALOG)
if not brains:
return None

Expand Down
Loading

0 comments on commit 3aceec5

Please sign in to comment.