Skip to content

Commit

Permalink
Compatibility with core#2567
Browse files Browse the repository at this point in the history
  • Loading branch information
xispa committed Jun 15, 2024
1 parent 0da0abc commit f64d024
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
17 changes: 9 additions & 8 deletions src/senaite/ast/setuphandlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,10 @@ def setup_ast_category(portal):
"""
name = SERVICE_CATEGORY
logger.info("Setup category '{}' ...".format(name))
folder = api.get_setup().bika_analysiscategories
exists = filter(lambda c: api.get_title(c) == name, folder.objectValues())
if exists:
setup = api.get_senaite_setup()
folder = setup.analysiscategories
categories = search_by_title(folder, name)
if categories:
logger.info("Category '{}' exists already [SKIP]".format(name))
return

Expand Down Expand Up @@ -199,15 +200,15 @@ def setup_ast_services(portal, update_existing=True):
selective reporting
"""
logger.info("Setup AST services ...")

# Get the category to apply to all AST services
cats_folder = api.get_senaite_setup().analysiscategories
category = search_by_title(cats_folder, SERVICE_CATEGORY)[0]

setup = api.get_setup()
for key, settings in SERVICES_SETTINGS.items():
logger.info("Setup template service '{}' ...".format(key))

# Get the category
cat_name = SERVICE_CATEGORY
categories = setup.bika_analysiscategories.objectValues()
category = filter(lambda c: api.get_title(c) == cat_name, categories)[0]

title = settings["title"]
if "{}" in title:
title = title.format(_("Antibiotic Sensitivity"))
Expand Down
2 changes: 1 addition & 1 deletion src/senaite/ast/tests/doctests/AST.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ We need to create some basic objects for the test:
>>> sampletype = api.create(setup.bika_sampletypes, "SampleType", title="Blood", Prefix="B")
>>> labcontact = api.create(setup.bika_labcontacts, "LabContact", Firstname="Lab", Lastname="Manager")
>>> department = api.create(portal.setup.departments, "Department", title="Microbiology", Manager=labcontact)
>>> category = api.create(setup.bika_analysiscategories, "AnalysisCategory", title="Microbiology", Department=department)
>>> category = api.create(portal.setup.analysiscategories, "AnalysisCategory", title="Microbiology", Department=department)
>>> g = api.create(setup.bika_analysisservices, "AnalysisService", title="GRAM Test", Keyword="G", Price="15", Category=category.UID(), Accredited=True)


Expand Down

0 comments on commit f64d024

Please sign in to comment.