Skip to content

Commit

Permalink
Added upgrade step
Browse files Browse the repository at this point in the history
  • Loading branch information
xispa committed Nov 28, 2024
1 parent 62573b4 commit dc0773c
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/senaite/ast/profiles/default/metadata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
dependencies before installing this add-on own profile.
-->
<metadata>
<version>1202</version>
<version>1203</version>

<!-- Be sure to install the following dependencies if not yet installed -->
<dependencies>
Expand Down
34 changes: 34 additions & 0 deletions src/senaite/ast/upgrade/v01_02_000.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@
from senaite.ast import logger
from senaite.ast import PRODUCT_NAME
from senaite.ast.config import AST_POINT_OF_CAPTURE
from senaite.ast.config import SERVICES_SETTINGS
from senaite.ast.setuphandlers import revoke_edition_permissions
from senaite.ast.setuphandlers import setup_workflows
from senaite.core.catalog import ANALYSIS_CATALOG
from senaite.core.catalog import SETUP_CATALOG
from senaite.core.upgrade import upgradestep
from senaite.core.upgrade.utils import UpgradeUtils

Expand Down Expand Up @@ -91,3 +93,35 @@ def update_role_mappings_for(object_or_brain):
def revoke_setup_permissions(tool):
portal = tool.aq_inner.aq_parent
revoke_edition_permissions(portal)


def restore_ast_result_type(tool):
"""Setup analysis/service result types
"""
logger.info("Restore ResultType from AST-like services ...")
# analysis services
query = {
"portal_type": "AnalysisService",
"point_of_capture": AST_POINT_OF_CAPTURE
}
brains = api.search(query, SETUP_CATALOG)
total = len(brains)
for num, brain in enumerate(brains):

if num and num % 1000 == 0:
logger.info("Setup result types %s/%s" % (num, total))

obj = api.get_object(brain)
if not obj:
continue

keyword = obj.getKeyword()
settings = SERVICES_SETTINGS.get(keyword)
if not settings:
continue

result_type = settings.get("result_type")
obj.setResultType(result_type)
obj._p_deactivate()

logger.info("Restore ResultType from AST-like services [DONE]")
8 changes: 8 additions & 0 deletions src/senaite/ast/upgrade/v01_02_000.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@
xmlns="http://namespaces.zope.org/zope"
xmlns:genericsetup="http://namespaces.zope.org/genericsetup">

<genericsetup:upgradeStep
title="SENAITE AST 1.2.0: Restore ResultType for AST-like services"
description="Restore ResultType for AST-like services"
source="1202"
destination="1203"
handler="senaite.ast.upgrade.v01_02_000.restore_ast_result_type"
profile="senaite.ast:default"/>

<genericsetup:upgradeStep
title="SENAITE AST 1.2.0: Revoke edit permissions for AST setup objects"
description="Revoke edit permissions for AST setup objects"
Expand Down

0 comments on commit dc0773c

Please sign in to comment.