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

User with "Analyst" role cannot submit analyses from worksheet #1475

Merged
merged 3 commits into from
Nov 23, 2019
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 CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Changelog

**Fixed**

- #1475 User with "Analyst" role cannot submit analyses from worksheet
- #1474 Adding Control Reference to Worksheet causes print fail
- #1473 Hidden settings of analysis services lost on Sample creation
- #1472 Secondary samples - removal of analysis profile not possible
Expand Down
4 changes: 4 additions & 0 deletions bika/lims/content/worksheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,10 @@ def addAnalysis(self, analysis, position=None):
if method and analysis.isMethodAllowed(method):
analysis.setMethod(method)

# Assign the worksheet's analyst to the analysis
# https://github.com/senaite/senaite.core/issues/1409
analysis.setAnalyst(self.getAnalyst())

# Transition analysis to "assigned"
actions_pool = ActionHandlerPool.get_instance()
actions_pool.queue_pool()
Expand Down
9 changes: 6 additions & 3 deletions bika/lims/workflow/analysis/guards.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,16 @@
# Copyright 2018-2019 by it's authors.
# Some rights reserved, see README and LICENSE.

from plone.memoize.request import cache

from bika.lims import api
from bika.lims import logger
from bika.lims import workflow as wf
from bika.lims.api import security
from bika.lims.interfaces import ISubmitted
from bika.lims.interfaces import IVerified
from bika.lims.interfaces import IWorksheet
from bika.lims.interfaces.analysis import IRequestAnalysis
from plone.memoize.request import cache


def is_worksheet_context():
Expand Down Expand Up @@ -136,10 +138,11 @@ def guard_submit(analysis):
if not analysis.bika_setup.getAllowToSubmitNotAssigned():
if not user_has_super_roles():
# Cannot submit if unassigned
if not analysis.getAnalyst():
analyst = analysis.getAnalyst()
if not analyst:
return False
# Cannot submit if assigned analyst is not the current user
if analysis.getAnalyst() != api.get_current_user().getId():
if analyst != security.get_user_id():
return False

# Cannot submit unless all dependencies are submitted or can be submitted
Expand Down