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

Fix error when creating a partition as analyst user #1525

Merged
merged 2 commits into from
Feb 10, 2020

Conversation

xispa
Copy link
Member

@xispa xispa commented Feb 10, 2020

Description of the issue/feature this PR addresses

Analyst user was allowed to create partitions because the 'create_partition' guard was governed by permission "Edit Results" and the permission required for partition magic view was "ManageAnalysisRequests". Nevertheless, analysts do not have view permissions for some setup objects (like SampleType), so the system was throwing an exception after pressing the button "Create Partitions" from partition magic view:

Traceback (innermost last):
Module ZPublisher.Publish, line 138, in publish
Module ZPublisher.mapply, line 77, in mapply
Module ZPublisher.Publish, line 48, in call_object
Module bika.lims.browser.partition_magic, line 97, in call
Module bika.lims.utils.analysisrequest, line 480, in create_partition
Module bika.lims.utils.analysisrequest, line 87, in create_analysisrequest
Module Products.Archetypes.BaseObject, line 636, in processForm
Module bika.lims.content.analysisrequest, line 1420, in _renameAfterCreation
Module bika.lims.idserver, line 518, in renameAfterCreation
Module bika.lims.idserver, line 462, in generateUniqueId
Module bika.lims.idserver, line 227, in get_variables
AttributeError: 'NoneType' object has no attribute 'getPrefix'

This PR makes the "create_partition" transition, and the partition magic view to rely on permission "senaite.core: Add AnalysisRequest", so the transition is not longer available to analyst, and even if he/she tries to access manually to partition magic view, the system will display an "Insufficient privileges" message.

Current behavior before PR

A traceback is rised when an analyst tries to create partitions

Desired behavior after PR is merged

Analyst does not have privileges to create partitions

--
I confirm I have tested this PR thoroughly and coded it according to PEP8
and Plone's Python styleguide standards.

Analyst user was allowed to create partitions because the 'create_partition'
guard was governed by permission "Edit Results" and the permission required for
partition magic view was "ManageAnalysisRequests". Nevertheless, analysts do not
have view permissions for some setup objects (like SampleType), so the system
was throwing an exception after pressing the button "Create Partitions" from
partition magiv view:

```
Traceback (innermost last):
Module ZPublisher.Publish, line 138, in publish
Module ZPublisher.mapply, line 77, in mapply
Module ZPublisher.Publish, line 48, in call_object
Module bika.lims.browser.partition_magic, line 97, in call
Module bika.lims.utils.analysisrequest, line 480, in create_partition
Module bika.lims.utils.analysisrequest, line 87, in create_analysisrequest
Module Products.Archetypes.BaseObject, line 636, in processForm
Module bika.lims.content.analysisrequest, line 1420, in _renameAfterCreation
Module bika.lims.idserver, line 518, in renameAfterCreation
Module bika.lims.idserver, line 462, in generateUniqueId
Module bika.lims.idserver, line 227, in get_variables
AttributeError: 'NoneType' object has no attribute 'getPrefix'
```

This commit makes the "create_partition" transition, and the partition magic
view to rely on permission "senaite.core: Add AnalysisRequest", so the
transition is not longer available to analyst, and even if he/she tries to
access manually to partition magic view, the system will display an
"Insufficient privileges" message.
@ramonski ramonski merged commit d96fba0 into master Feb 10, 2020
@ramonski ramonski deleted the error-create-partitions-analyst branch February 10, 2020 22:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

2 participants