Skip to content

Commit

Permalink
Fixed #LIMS-1209 - Ensure the overriden folderitems set the categories
Browse files Browse the repository at this point in the history
as a sideaffect
  • Loading branch information
mikejmets committed Dec 6, 2024
1 parent eb6dccd commit e6f8e1f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
9 changes: 7 additions & 2 deletions src/senaite/timeseries/browser/overrides/analysisrequest.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,17 @@ def folderitems(self):
# Note we call AnalysesView's base class!
items = super(AnalysesView, self).folderitems()
newitems = []
cats = []
for item in items:
if not item.get("time_series_columns"):
if item.get("result_type") != "timeseries":
newitems.append(item)
cats.append(item["category"])
logger.info(
"AnalysisRequestOverride::folderitems: found {} items".format(len(newitems))
"AnalysisRequestOverride::folderitems: found {} items with no timeseries items".format(
len(newitems)
)
)
self.categories = cats
return newitems


Expand Down
6 changes: 3 additions & 3 deletions src/senaite/timeseries/browser/overrides/sampleanalyses.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
class LabAnalysesViewlet(LAV):
def available(self):
"""Returns a boolean if the len(sample analyses) by point of capture
is equal to len(timeseries_analyses), meaning there are only
timeseries analyses.
is equal to len(timeseries_analyses), meaning there are only
timeseries analyses.
"""
analyses = self.sample.getAnalyses(getPointOfCapture=self.capture)
timeseries_analyses = get_timeseries_analyses(self.sample)
return len(analyses) != len(timeseries_analyses)
return len(analyses) - len(timeseries_analyses) > 0
15 changes: 12 additions & 3 deletions src/senaite/timeseries/browser/results.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@

from bika.lims import api
from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
from senaite.core import logger
from senaite.core.browser.viewlets.sampleanalyses import LabAnalysesViewlet
from senaite.timeseries.config import is_installed
from senaite.timeseries.config import _
from senaite.timeseries.browser.overrides.analysisrequest import AnalysesView
from senaite.core.browser.viewlets.sampleanalyses import LabAnalysesViewlet


class TimeSeriesAnalysesViewlet(LabAnalysesViewlet):
Expand Down Expand Up @@ -98,9 +99,17 @@ def folderitems(self):
# Note we call AnalysesView's base class!
items = super(AnalysesView, self).folderitems()
newitems = []
cats = []
for item in items:
if item.get("time_series_columns"):
if item.get("result_type") == "timeseries":
newitems.append(item)
cats.append(item["category"])
logger.info(
"AnalysisRequestOverride::folderitems: found {} items with timeseries items".format(
len(newitems)
)
)
self.categories = cats
return newitems


Expand All @@ -118,5 +127,5 @@ def get_timeseries_analyses(sample, short_title=None, skip_invalid=True):
# Skip invalid analyses
skip = skip_invalid and ["cancelled", "retracted", "rejected"] or []
analyses = filter(lambda a: api.get_review_status(a) not in skip, analyses)
analyses = filter(lambda a: a.TimeSeriesColumns, analyses)
analyses = filter(lambda a: a.getResultType() == "timeseries", analyses)
return analyses

0 comments on commit e6f8e1f

Please sign in to comment.