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

Compatibility with core#2521 - AT2DX ARTemplate/SampleTemplate #35

Merged
merged 4 commits into from
Apr 12, 2024
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 docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Changelog
1.2.0 (unreleased)
------------------

- #35 Compatibility with core#2521 - AT2DX ARTemplate/SampleTemplate
- #34 Add transition "Reject antibiotics"
- #33 Display the Antibiotic Sensitivity section only when necessary
- #32 Compatibility with senaite.core#2492 (AnalysisProfile to DX)
Expand Down
6 changes: 3 additions & 3 deletions src/senaite/ast/adapters/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
provides="senaite.app.listing.interfaces.IListingViewAdapter"
factory=".listing.services.NonASTServicesViewAdapter" />

<!-- Do not display AST-type services for selection in Analysis Template -->
<!-- Do not display AST-type services for selection in Sample Template -->
<subscriber
for="bika.lims.browser.widgets.artemplateanalyseswidget.ARTemplateAnalysesView
bika.lims.interfaces.IARTemplate"
for="senaite.core.browser.widgets.sampletemplate_services_widget.SampleTemplateServicesWidget
senaite.core.interfaces.ISampleTemplate"
provides="senaite.app.listing.interfaces.IListingViewAdapter"
factory=".listing.services.NonASTServicesViewAdapter" />

Expand Down
10 changes: 9 additions & 1 deletion src/senaite/ast/upgrade/v01_00_000.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
from senaite.ast.setuphandlers import setup_navigation_types
from senaite.ast.utils import get_result_options
from senaite.core.catalog import SETUP_CATALOG
from senaite.core.interfaces import ISampleTemplate
from senaite.core.upgrade import upgradestep
from senaite.core.upgrade.utils import UpgradeUtils

Expand Down Expand Up @@ -160,11 +161,18 @@ def remove_ast_from_templates(portal):
logger.info("Removing AST-like analyses from templates ...")
ast_uids = get_ast_services_uids(portal)
query = {
"portal_type": "ARTemplate"
"portal_type": ["ARTemplate", "SampleTemplate"]
}
brains = api.search(query, SETUP_CATALOG)
for brain in brains:
obj = api.get_object(brain)
if ISampleTemplate.providedBy(obj):
ans = obj.getRawServices()
ans = filter(lambda an: an.get("uid") not in ast_uids, ans)
obj.setServices(list(ans))
continue

# Old AT object (https://github.com/senaite/senaite.core/pull/2521)
ans = obj.getAnalyses()
ans = filter(lambda an: an.get("service_uid") not in ast_uids, ans)
obj.setAnalyses(ans)
Expand Down