Skip to content

Commit

Permalink
Override viewlet to hide the Analyses table if there are no analyses
Browse files Browse the repository at this point in the history
  • Loading branch information
Lunga001 committed Nov 11, 2024
1 parent 971cb3b commit 0826bd2
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/senaite/timeseries/browser/overrides/overrides.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,13 @@
layer="senaite.timeseries.interfaces.ISenaiteTimeseriesLayer"
/>

<!-- Sample section viewlet: lab analyses lisiting -->
<browser:viewlet
for="bika.lims.interfaces.IAnalysisRequest"
name="senaite.core.samplesection.lab_analyses"
manager="senaite.core.browser.viewlets.interfaces.ISampleSection"
class=".sampleanalyses.LabAnalysesViewlet"
layer="senaite.core.interfaces.ISenaiteCore"
permission="zope2.View" />

</configure>
15 changes: 15 additions & 0 deletions src/senaite/timeseries/browser/overrides/sampleanalyses.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 0826bd2

Please sign in to comment.