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

Setting in setup for auto-reception of samples upon creation #1436

Merged
merged 4 commits into from
Sep 20, 2019

Conversation

xispa
Copy link
Member

@xispa xispa commented Sep 6, 2019

Description of the issue/feature this PR addresses

By default, the samples need to be received by lab personnel after they are created in the system. Quite often, lab personnel would like the samples that are created by themselves to be automatically received.

Current behavior before PR

Samples created by lab personnel cannot be auto-received upon creation

Desired behavior after PR is merged

Samples created by lab personnel can be auto-received upon creation

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

# Auto-receive samples is enabled. Receive the sample automatically,
# but only if the current user is a laboratory contact
user = api.get_current_user()
contact = api.get_user_contact(user, contact_types=["LabContact"])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it be better here to check the role of the user? E.g. if the user has the permission to receive the sample?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OMG, you're totally right!. Thanks for pointing this out.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also consider to cache the user role in the request in case of multi-reception. Not sure how "expensive" the role lookup is in terms of performance...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To handle exceptions, I suggest making an option with this setting as default in the sample add form.

@ramonski ramonski merged commit 2313584 into master Sep 20, 2019
@ramonski ramonski deleted the sample-reception branch September 20, 2019 09:46
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.

3 participants