Skip to content

Commit

Permalink
Fix user defined range operators are omitted in results report (senai…
Browse files Browse the repository at this point in the history
…te#143)

* Fix user defined range operators are omitted in results report

* Changelog

* Set default operator for max to '<'

* Organize imports
  • Loading branch information
xispa authored Oct 3, 2023
1 parent 157d12a commit fcfc103
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
1 change: 1 addition & 0 deletions docs/Changelog.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
2.5.0 (unreleased)
------------------

- #143 Fix user defined range operators are omitted in results report
- #142 Display custom comment for out of range results
- #141 Display reportable interim fields as result variables in results report
- #140 Refactor report sections into separate components
Expand Down
17 changes: 14 additions & 3 deletions src/senaite/impress/analysisrequest/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@

import itertools

from bika.lims import api
from bika.lims.config import MAX_OPERATORS
from bika.lims.config import MIN_OPERATORS
from bika.lims.utils import format_supsub
from bika.lims.utils import formatDecimalMark
from bika.lims.utils import to_utf8
from bika.lims.utils.analysis import format_uncertainty
from bika.lims import api
from senaite.app.supermodel import SuperModel as BaseModel
from senaite.impress import logger
from senaite.impress.decorators import returns_super_model
Expand Down Expand Up @@ -146,13 +148,22 @@ def get_formatted_uncertainty(self, analysis):

def get_formatted_specs(self, analysis):
specs = analysis.getResultsRange()

# get the min operator
min_operator = specs.get("min_operator")
min_operator = MIN_OPERATORS.getValue(min_operator, default=">")

# get the max operator
max_operator = specs.get("max_operator")
max_operator = MAX_OPERATORS.getValue(max_operator, default="<")

fs = ''
if specs.get('min', None) and specs.get('max', None):
fs = '%s - %s' % (specs['min'], specs['max'])
elif specs.get('min', None):
fs = '> %s' % specs['min']
fs = '%s %s' % (min_operator, specs['min'])
elif specs.get('max', None):
fs = '< %s' % specs['max']
fs = '%s %s' % (max_operator, specs['max'])
return formatDecimalMark(fs, self.decimal_mark)

def get_resultsinterpretation(self):
Expand Down

0 comments on commit fcfc103

Please sign in to comment.