Repository navigation
Conversation
The expected values decide which services a reference sample supports, and a sample that supports none is offered on a worksheet as a control that adds no analysis. They were copied from the definition by the edit form, in the browser, as soon as the definition was picked. A sample made any other way, over the API or from a setup data import, kept the link to its definition and no values at all. The accessor now falls back to the definition when the sample holds no values of its own, which is what the hazard categories of the same class already do.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description of the issue/feature this PR addresses
A reference sample points at the reference definition it was bought against. The definition carries the expected values, and those values decide which analysis services the sample supports.
Current behavior before PR
The values are copied from the definition to the sample by the edit form adapter, in the browser, on the
modifiedevent of theReferenceDefinitionfield (senaite/core/browser/form/adapters/referencesample.py). Nothing on the server does it.A reference sample created any other way therefore links a definition and holds no expected values:
api.creategetSupportedServicesreads the expected values, so such a sample supports no service. On a worksheet it is listed underAdd Blank/Add Controlwith an emptySupported Servicescolumn, and selecting it adds no reference analysis. The sample looks complete everywhere else: it has a definition, a lot number, an expiry date.Desired behavior after PR is merged
ReferenceSample.getReferenceResultsfalls back to the definition when the sample holds no values of its own. Values set on the sample still win, and clearing them hands the sample back to its definition.This is the behaviour
getHazardCategoriesin the same class already has, twenty lines further down, and for the same reason.Nothing about the edit form changes. A sample saved through it keeps its own copy of the values, as before.
Verification
A new doctest,
ReferenceSampleFromDefinition.rst, covers the three cases: a sample that inherits, a sample whose own values win, and a sample with neither a definition nor values of its own.Without the fix it fails on the first assertion; with it, it passes.
Run alongside the reference and QC doctests that read the same accessor, all green:
--
I confirm I have tested this PR thoroughly and coded it according to PEP8
and Plone's Python styleguide standards.