From 0826bd2e31cb117427bbd41443403350a5fe50a1 Mon Sep 17 00:00:00 2001 From: Lunga Baliwe Date: Mon, 11 Nov 2024 10:27:20 +0200 Subject: [PATCH] Override viewlet to hide the Analyses table if there are no analyses --- .../timeseries/browser/overrides/overrides.zcml | 9 +++++++++ .../browser/overrides/sampleanalyses.py | 15 +++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 src/senaite/timeseries/browser/overrides/sampleanalyses.py diff --git a/src/senaite/timeseries/browser/overrides/overrides.zcml b/src/senaite/timeseries/browser/overrides/overrides.zcml index 9797b2b..e6f01d6 100644 --- a/src/senaite/timeseries/browser/overrides/overrides.zcml +++ b/src/senaite/timeseries/browser/overrides/overrides.zcml @@ -25,4 +25,13 @@ layer="senaite.timeseries.interfaces.ISenaiteTimeseriesLayer" /> + + + diff --git a/src/senaite/timeseries/browser/overrides/sampleanalyses.py b/src/senaite/timeseries/browser/overrides/sampleanalyses.py new file mode 100644 index 0000000..6421cac --- /dev/null +++ b/src/senaite/timeseries/browser/overrides/sampleanalyses.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- + +from senaite.core.browser.viewlets.sampleanalyses import LabAnalysesViewlet as LAV +from senaite.timeseries.browser.results import get_timeseries_analyses + + +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. + """ + analyses = self.sample.getAnalyses(getPointOfCapture=self.capture) + timeseries_analyses = get_timeseries_analyses(self.sample) + return len(analyses) != len(timeseries_analyses)