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

Explicitly set client on sample creation #2240

Merged
merged 4 commits into from
Jan 26, 2023

Conversation

ramonski
Copy link
Contributor

Description of the issue/feature this PR addresses

This PR ensures that the Client schema field is set properly when creating new samples with create_analysisrequest.

Current behavior before PR

If the function create_analysisrequest is called programmatically outside the sample add form, the Client value was expected to be passed in with the values, instead of using it from the first parameter:

def create_analysisrequest(client, request, values, analyses=None,
                           results_ranges=None, prices=None):

As a result, these samples couldn't be copied:

AR-Add

Desired behavior after PR is merged

The client field is explicitly set to the client parameter.

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

@ramonski ramonski requested a review from xispa January 26, 2023 12:32
Copy link
Member

@xispa xispa left a comment

Choose a reason for hiding this comment

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

Just a minor comment


obj = api.get_object(obj)
field = obj.getField("Client")
value = field.get(obj)
Copy link
Member

Choose a reason for hiding this comment

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

You'll save unnecessary searches against uid_catalog and become faster if you do field.getRaw(obj) instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

cool, yes indeed! I'll add it

@xispa xispa merged commit 0c2f0b1 into 2.x Jan 26, 2023
@xispa xispa deleted the explicitly-set-client-on-sample-creation branch January 26, 2023 15:30
@xispa xispa added the To port label Feb 16, 2023
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