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 reference definition range validation #2452

Merged
merged 10 commits into from
Dec 20, 2023

Conversation

ramonski
Copy link
Contributor

Description of the issue/feature this PR addresses

This PR fixes the field validation for the result, min and max values of the reference definition ranges.

Current behavior before PR

  • min value can be above max value
  • min/max values are kept when result changes, e.g. it is possible to change the result above the max value or below the min value afterwards.

Desired behavior after PR is merged

  • min value is validated to be below max value
  • min/max values are shifted when the result changes

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

return "% Error must be between 0 and 100"
return None

validation.register(ReferenceValuesValidator())
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch, thanks for searching over the codebase once again! Fixed in b75d84e

@ramonski
Copy link
Contributor Author

Do you think it is worth to make a migration step for this?
E.g. if someone defined a higher max than min value?

@xispa
Copy link
Member

xispa commented Dec 19, 2023

Do you think it is worth to make a migration step for this? E.g. if someone defined a higher max than min value?

Good point!. Yes, I think is worth. I don't expect instances to have a lot of Reference Definitions, so the upgrade step would not take too much to complete.

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.

Note we can still have min > max values in reference definition when user inputs a negative percentage:

Captura de 2023-12-20 12-43-42

We have some options here:

  1. Move this code after line 234
  2. Do s_err=abs(float(s_err)) before line 232. In such case, we might need to also do "error": str(s_err) at line 236.
  3. Rather consider negative percentage as a feature and leave it as it is

What do you think?

@xispa
Copy link
Member

xispa commented Dec 20, 2023

Note we can still have min > max values in reference definition when user inputs a negative percentage:
[...]

With c23508d we do the abs, so min above max are no longer possible.

@xispa xispa merged commit 78af080 into 2.x Dec 20, 2023
2 checks passed
@xispa xispa deleted the fix-referencedefinition-values-validation branch December 20, 2023 13:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

2 participants