-
-
Notifications
You must be signed in to change notification settings - Fork 152
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
Allow to edit Profiles in Samples for pre verified/published states #1657
Merged
Merged
Changes from 5 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
77c20c2
Added custom setter method to handle profiles
ramonski cee4bf1
Allow to edit profiles in pre verified/published states
ramonski 3759e71
Added upgrade step
ramonski 48b4db8
Changelog updated
ramonski f770319
Run typeinfo from senaite.core package
ramonski 1bb18a3
Added missing comma
ramonski 05b030d
Run import steps from snaite.core and bika.lims
ramonski a900bd0
Added doctest
ramonski 04275a9
Added missing method argument
ramonski e3b69eb
Fix tests
ramonski 921703a
Check the status of the Sample is "sample_received" (doctest)
xispa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,10 +19,12 @@ | |
# Some rights reserved, see README and LICENSE. | ||
|
||
from bika.lims import api | ||
from bika.lims.catalog import CATALOG_ANALYSIS_REQUEST_LISTING | ||
from bika.lims.catalog import SETUP_CATALOG | ||
from bika.lims.setuphandlers import add_dexterity_setup_items | ||
from senaite.core import logger | ||
from senaite.core.config import PROJECTNAME as product | ||
from senaite.core.setuphandlers import _run_import_step | ||
from senaite.core.upgrade import upgradestep | ||
from senaite.core.upgrade.utils import UpgradeUtils | ||
|
||
|
@@ -68,15 +70,21 @@ def upgrade(tool): | |
# Install the new SENAITE CORE package | ||
install_senaite_core(portal) | ||
|
||
# Add Interpretation Template(s) content type | ||
setup.runImportStepFromProfile(profile, "typeinfo") | ||
setup.runImportStepFromProfile(profile, "workflow") | ||
# N.B.: We use `_run_import_step` to run profiles which are still located | ||
# in the `bika.lims` profile! | ||
_run_import_step(portal, "typeinfo", profile="profile-bika.lims:default") | ||
_run_import_step(portal, "workflow", profile="profile-bika.lims:default") | ||
|
||
add_dexterity_setup_items(portal) | ||
|
||
# Published results tab is not displayed to client contacts | ||
# https://github.com/senaite/senaite.core/pull/1638 | ||
fix_published_results_permission(portal) | ||
|
||
# Update workflow mappings for samples to allow profile editing | ||
update_workflow_mappings_samples(portal) | ||
|
||
logger.info("{0} upgraded to version {1}".format(product, version)) | ||
return True | ||
|
||
|
@@ -140,3 +148,36 @@ def fix_published_results_permission(portal): | |
if action.id == "published_results": | ||
action.permissions = ("View", ) | ||
break | ||
|
||
|
||
def update_workflow_mappings_samples(portal): | ||
"""Allow to edit analysis profiles | ||
""" | ||
logger.info("Updating role mappings for Samples ...") | ||
wf_id = "bika_ar_workflow" | ||
query = {"portal_type": "AnalysisRequest", | ||
"review_state": [ | ||
"sample_due", | ||
"sample_registered", | ||
"scheduled_sampling", | ||
"to_be_sampled", | ||
"sample_received", | ||
"attachment_due", | ||
"to_be_verified" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You missed a comma here, so the role mappings update do not apply to samples that are in "to_be_verified" or in "to_be_preserved" statuses. |
||
"to_be_preserved", | ||
]} | ||
brains = api.search(query, CATALOG_ANALYSIS_REQUEST_LISTING) | ||
update_workflow_mappings_for(portal, wf_id, brains) | ||
logger.info("Updating role mappings for Samples [DONE]") | ||
|
||
|
||
def update_workflow_mappings_for(portal, wf_id, brains): | ||
wf_tool = api.get_tool("portal_workflow") | ||
workflow = wf_tool.getWorkflowById(wf_id) | ||
total = len(brains) | ||
for num, brain in enumerate(brains): | ||
if num and num % 100 == 0: | ||
logger.info("Updating role mappings: {0}/{1}".format(num, total)) | ||
obj = api.get_object(brain) | ||
workflow.updateRoleMappingsFor(obj) | ||
obj.reindexObject(idxs=["allowedRolesAndUsers"]) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You still need to keep
setup.runImportStepFromProfile(profile, "workflow")
because of #1620: workflow definitions forInterpretationTemplate
andInterpretationTemplates
are located insenaite.core
profile.