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

Migrate WorksheetTemplates to DX #2599

Merged
merged 47 commits into from
Nov 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
85cadc4
init migration for worksheet templates
Bugerman58 Jul 18, 2024
3855fe2
method for migrate
Bugerman58 Jul 18, 2024
fd79288
fixed typo's
Bugerman58 Jul 19, 2024
bf9ba19
refactoring for new methods name
Bugerman58 Jul 19, 2024
570fe56
fix test, refactoring
Bugerman58 Jul 19, 2024
7f97467
fixed configure adapter
Bugerman58 Jul 25, 2024
1edd710
merge 2.x
Bugerman58 Jul 25, 2024
675aace
Merge branch '2.x' into migrate-ws-tempaltes-to-dx
Bugerman58 Jul 25, 2024
f9b3c95
Merge branch '2.x' into migrate-ws-tempaltes-to-dx
Bugerman58 Jul 27, 2024
beb7919
merge 2.x
Bugerman58 Jul 28, 2024
33eee5b
symplified upgrade step
Bugerman58 Jul 29, 2024
2654011
temporary fix linter warning
Bugerman58 Jul 29, 2024
c1bfa56
Merge branch '2.x' into migrate-ws-tempaltes-to-dx
Bugerman58 Jul 30, 2024
ffd6cc2
listing services for ws template
Bugerman58 Jul 30, 2024
77ab4d5
commit local changes
Bugerman58 Aug 2, 2024
745ed0b
merge 2.x
Bugerman58 Aug 7, 2024
3ef7404
add vocabulary for analyses types
Bugerman58 Aug 7, 2024
c158058
local changes
Bugerman58 Aug 29, 2024
578605b
merge 2.x
Bugerman58 Aug 29, 2024
e87b69e
intermediate commit
Bugerman58 Sep 16, 2024
45484bd
merge 2.x
Bugerman58 Sep 16, 2024
7c17edb
fix migrate step for upgrade
Bugerman58 Sep 16, 2024
3f95f07
fixdefault factory for template layout
Bugerman58 Sep 16, 2024
35db7ef
fix calling default factory for tempalte layout
Bugerman58 Sep 16, 2024
436fff8
fix upgrade step for migrate
Bugerman58 Sep 16, 2024
6699137
fix upgrade step for migrate - setting analysis and layout
Bugerman58 Sep 16, 2024
321fb4f
add display template for ws; add change num positions
Bugerman58 Sep 26, 2024
32f27a7
fix typo
Bugerman58 Sep 26, 2024
a2ac332
update changelog
Bugerman58 Sep 26, 2024
540b5e8
merge 2.x
Bugerman58 Oct 5, 2024
ac605ef
Merge branch '2.x' into migrate-ws-tempaltes-to-dx
ramonski Oct 6, 2024
977f986
Merge branch '2.x' into migrate-ws-tempaltes-to-dx
ramonski Oct 16, 2024
3eeea56
Merge branch '2.x' into migrate-ws-tempaltes-to-dx
Bugerman58 Oct 18, 2024
bab1213
delete unused field EnableMultipleUseOfInstrument
Bugerman58 Oct 18, 2024
dd1e1bc
refactoring for duplicate code
Bugerman58 Oct 18, 2024
746d9ad
fix exportimport setupdata for WST
Bugerman58 Oct 18, 2024
f99703b
update demodata
Bugerman58 Oct 18, 2024
62c11a7
Merge branch '2.x' into migrate-ws-tempaltes-to-dx
Bugerman58 Oct 21, 2024
21ae508
add old methods for backward compatibility with annotation of deprecated
Bugerman58 Oct 21, 2024
cc43ec8
delete conflicting method
Bugerman58 Oct 21, 2024
36c5055
fix import worksheet templates
Bugerman58 Oct 22, 2024
f79dc75
fix after review
Bugerman58 Oct 23, 2024
880fa66
Merge branch '2.x' into migrate-ws-tempaltes-to-dx
Bugerman58 Oct 27, 2024
55157b0
fix update num_position if it is empty
Bugerman58 Oct 27, 2024
316dd6a
fix import wst with definitions title
Bugerman58 Oct 29, 2024
e98ae66
Merge branch '2.x' into migrate-ws-tempaltes-to-dx
Bugerman58 Oct 29, 2024
fe27460
Merge branch '2.x' into migrate-ws-tempaltes-to-dx
ramonski Nov 1, 2024
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 @@ -4,6 +4,7 @@ Changelog
2.6.0 (unreleased)
------------------

- #2599 Migrate WorksheetTemplates to Dexterity
- #2632 Refactor Catalog Indexing
- #2630 Fix references from sample templates are not kept when partitioning
- #2634 Pin et-xmlfile to a Python 2 compatible version
Expand Down
5 changes: 0 additions & 5 deletions src/bika/lims/browser/worksheet/templates/results.pt
Original file line number Diff line number Diff line change
Expand Up @@ -252,11 +252,6 @@
</div>
<!-- /Remarks Widget -->

<!-- XXX: Where is this used? -->
<input type="hidden"
id="instrument_multiple_use"
tal:attributes="value python:context.getWorksheetTemplate().getEnableMultipleUseOfInstrument() if context.getWorksheetTemplate() else 'True';"/>

</metal:content-core>

</body>
Expand Down
6 changes: 3 additions & 3 deletions src/bika/lims/browser/worksheet/views/add_analyses.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def update(self):
new_states = []
if wst:

wst_service_uids = wst.getRawService()
wst_service_uids = wst.getRawServices()
# restrict to the selected template services
if wst_service_uids:
new_states.append({
Expand Down Expand Up @@ -222,8 +222,8 @@ def handle_submit(self):
def worksheet_template_setup_url(self):
"""Returns the Worksheet Template Setup URL
"""
setup = api.get_setup()
return "{}/{}".format(api.get_url(setup), "bika_worksheettemplates")
setup = api.get_senaite_setup()
return "{}/{}".format(api.get_url(setup), "worksheettemplates")

@view.memoize
def is_edit_allowed(self):
Expand Down
14 changes: 7 additions & 7 deletions src/bika/lims/content/worksheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ def get_suitable_slot_for_duplicate(self, src_slot):
# If there is a match with the layout defined in the Worksheet
# Template, use that slot instead of adding a new one at the end of
# the worksheet
layout = wst.getLayout()
layout = wst.getTemplateLayout()
for pos in layout:
if pos['type'] != 'd' or to_int(pos['dup']) != slot_from:
continue
Expand Down Expand Up @@ -612,7 +612,7 @@ def get_suitable_slot_for_reference(self, reference):
# If there is a match with the layout defined in the Worksheet Template,
# use that slot instead of adding a new one at the end of the worksheet
slot_type = reference.getBlank() and 'b' or 'c'
layout = wst.getLayout()
layout = wst.getTemplateLayout()

for pos in layout:
if pos['type'] != slot_type:
Expand Down Expand Up @@ -795,7 +795,7 @@ def resolve_available_slots(self, worksheet_template, type='a'):
return list()

ws_slots = self.get_slot_positions(type)
layout = worksheet_template.getLayout()
layout = worksheet_template.getTemplateLayout()
slots = list()

for row in layout:
Expand Down Expand Up @@ -832,7 +832,7 @@ def _apply_worksheet_template_routine_analyses(self, wst):
:returns: None
"""
# Get the services from the Worksheet Template
service_uids = wst.getRawService()
service_uids = wst.getRawServices()
if not service_uids:
# No service uids assigned to this Worksheet Template, skip
logger.warn("Worksheet Template {} has no services assigned"
Expand Down Expand Up @@ -918,7 +918,7 @@ def _apply_worksheet_template_duplicate_analyses(self, wst):
:param wst: worksheet template used as the layout
:returns: None
"""
wst_layout = wst.getLayout()
wst_layout = wst.getTemplateLayout()

for row in wst_layout:
if row['type'] != 'd':
Expand Down Expand Up @@ -994,7 +994,7 @@ def _resolve_reference_samples(self, wst, type):

slots_sample = list()
available_slots = self.resolve_available_slots(wst, type)
wst_layout = wst.getLayout()
wst_layout = wst.getTemplateLayout()
for row in wst_layout:
slot = int(row['pos'])
if slot not in available_slots:
Expand All @@ -1013,7 +1013,7 @@ def _resolve_reference_samples(self, wst, type):

# We only want the reference samples that fit better with the type
# and with the analyses defined in the Template
services = wst.getService()
services = wst.getServices()
services = [s.UID() for s in services]
candidates = list()
for sample in samples:
Expand Down
1 change: 1 addition & 0 deletions src/bika/lims/content/worksheettemplate.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@
schema["description"].widget.description = ""


# TODO: Migrated to DX - https://github.com/senaite/senaite.core/pull/2599
class WorksheetTemplate(BaseContent):
"""Worksheet Templates
"""
Expand Down
113 changes: 1 addition & 112 deletions src/bika/lims/controlpanel/bika_worksheettemplates.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,131 +18,20 @@
# Copyright 2018-2024 by it's authors.
# Some rights reserved, see README and LICENSE.

import collections

from bika.lims import api
from bika.lims import bikaMessageFactory as _
from bika.lims.browser.bika_listing import BikaListingView
from bika.lims.config import PROJECTNAME
from bika.lims.interfaces import IWorksheetTemplates
from bika.lims.utils import get_link
from plone.app.folder.folder import ATFolder
from plone.app.folder.folder import ATFolderSchema
from Products.Archetypes import atapi
from Products.ATContentTypes.content import schemata
from senaite.core.interfaces import IHideActionsMenu
from senaite.core.permissions import AddWorksheetTemplate
from zope.interface.declarations import implements


class WorksheetTemplatesView(BikaListingView):
"""Listing View for Worksheet Templates
"""

def __init__(self, context, request):
super(WorksheetTemplatesView, self).__init__(context, request)

self.catalog = "senaite_catalog_setup"

self.contentFilter = {
"portal_type": "WorksheetTemplate",
"sort_on": "sortable_title",
"sort_order": "ascending",
}

self.context_actions = {
_("Add"):
{
"url": "createObject?type_name=WorksheetTemplate",
"permission": AddWorksheetTemplate,
"icon": "++resource++bika.lims.images/add.png"
}
}

self.title = self.context.translate(_("Worksheet Templates"))
self.icon = "{}/{}".format(
self.portal_url,
"/++resource++bika.lims.images/worksheettemplate_big.png"
)

self.show_select_row = False
self.show_select_column = True

self.columns = collections.OrderedDict((
("Title", {
"title": _("Title"),
"index": "sortable_title",
}),
("Description", {
"title": _("Description"),
"index": "description",
"toggle": True,
}),
("Method", {
"title": _("Method"),
"toggle": True}),
("Instrument", {
"title": _("Instrument"),
"index": "instrument_title",
"toggle": True,
}),
))

self.review_states = [
{
"id": "default",
"title": _("Active"),
"contentFilter": {"is_active": True},
"columns": self.columns.keys(),
}, {
"id": "inactive",
"title": _("Inactive"),
"contentFilter": {'is_active': False},
"columns": self.columns.keys()
}, {
"id": "all",
"title": _("All"),
"contentFilter": {},
"columns": self.columns.keys(),
},
]

def folderitem(self, obj, item, index):
"""Service triggered each time an item is iterated in folderitems.
The use of this service prevents the extra-loops in child objects.
:obj: the instance of the class to be foldered
:item: dict containing the properties of the object to be used by
the template
:index: current index of the item
"""
obj = api.get_object(obj)
item["Description"] = obj.Description()
item["replace"]["Title"] = get_link(item["url"], item["Title"])

instrument = obj.getInstrument()
if instrument:
instrument_url = api.get_url(instrument)
instrument_title = api.get_title(instrument)
item["Instrument"] = instrument_title
item["replace"]["Instrument"] = get_link(
instrument_url, value=instrument_title)

# Method
method_uid = obj.getMethodUID()
if method_uid:
method = api.get_object_by_uid(method_uid)
method_url = api.get_url(method)
method_title = api.get_title(method)
item["Method"] = method_title
item["replace"]["Method"] = get_link(
method_url, value=method_title)

return item


schema = ATFolderSchema.copy()


# TODO: Migrated to DX - https://github.com/senaite/senaite.core/pull/2599
class WorksheetTemplates(ATFolder):
implements(IWorksheetTemplates, IHideActionsMenu)
displayContentsTab = False
Expand Down
8 changes: 0 additions & 8 deletions src/bika/lims/controlpanel/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,4 @@
layer="bika.lims.interfaces.IBikaLIMS"
/>

<browser:page
for="bika.lims.interfaces.IWorksheetTemplates"
name="folder_view"
class=".bika_worksheettemplates.WorksheetTemplatesView"
permission="senaite.core.permissions.ManageBika"
layer="bika.lims.interfaces.IBikaLIMS"
/>

</configure>
1 change: 0 additions & 1 deletion src/bika/lims/profiles/default/factorytool.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,5 @@
<type portal_type="Pricelist"/>
<type portal_type="SampleType"/>
<type portal_type="SupplierContact"/>
<type portal_type="WorksheetTemplate"/>
</factorytypes>
</object>
1 change: 0 additions & 1 deletion src/bika/lims/profiles/default/propertiestool.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@
<element value="SampleType"/>
<element value="BatchLabel"/>
<element value="Worksheet"/>
<element value="WorksheetTemplate"/>
<element value="ATBooleanCriterion"/>
<element value="ATDateCriteria"/>
<element value="ATDateRangeCriterion"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@ bika_calculations,Calculations
bika_instruments,Instruments
bika_labcontacts,LabContacts
bika_referencedefinitions,ReferenceDefinitions
bika_worksheettemplates,WorksheetTemplates
laboratory,Laboratory
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@ bika_calculations
bika_instruments
bika_labcontacts
bika_referencedefinitions
bika_worksheettemplates
laboratory

This file was deleted.

2 changes: 0 additions & 2 deletions src/bika/lims/profiles/default/types.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@
<object name="SupplierContact" meta_type="Factory-based Type Information with dynamic views"/>
<object name="Worksheet" meta_type="Factory-based Type Information with dynamic views"/>
<object name="WorksheetFolder" meta_type="Factory-based Type Information with dynamic views"/>
<object name="WorksheetTemplate" meta_type="Factory-based Type Information with dynamic views"/>
<object name="WorksheetTemplates" meta_type="Factory-based Type Information with dynamic views"/>
<object name="AutoImportLog" meta_type="Factory-based Type Information with dynamic views"/>

</object>
48 changes: 0 additions & 48 deletions src/bika/lims/profiles/default/types/WorksheetTemplate.xml

This file was deleted.

28 changes: 0 additions & 28 deletions src/bika/lims/profiles/default/types/WorksheetTemplates.xml

This file was deleted.

1 change: 1 addition & 0 deletions src/senaite/core/browser/controlpanel/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,6 @@
<include package=".storagelocations" />
<include package=".subgroups" />
<include package=".suppliers" />
<include package=".worksheettemplates" />

</configure>
Loading
Loading