From e93dfdd3c981e9be87dd41d4d6841ee878776fe2 Mon Sep 17 00:00:00 2001 From: Mike Metcalfe Date: Mon, 23 Sep 2024 13:58:45 +0200 Subject: [PATCH] Refactored timeseries_readonly --- .../browser/overrides/analysisrequest.py | 40 ++++++++++++------- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/src/senaite/timeseries/browser/overrides/analysisrequest.py b/src/senaite/timeseries/browser/overrides/analysisrequest.py index 40a56e4..1a7b42a 100644 --- a/src/senaite/timeseries/browser/overrides/analysisrequest.py +++ b/src/senaite/timeseries/browser/overrides/analysisrequest.py @@ -29,8 +29,7 @@ def _folder_item_result(self, analysis_brain, item): result = obj.getResult() capture_date = obj.getResultCaptureDate() - localized_capture_date = dtime.to_localized_time( - capture_date, long_format=1) + localized_capture_date = dtime.to_localized_time(capture_date, long_format=1) item["Result"] = result item["ResultCaptureDate"] = dtime.to_iso_format(capture_date) @@ -41,6 +40,8 @@ def _folder_item_result(self, analysis_brain, item): if unit: item["after"]["Result"] = self.render_unit(unit) + result_type = obj.getResultType() + # Edit mode enabled of this Analysis if self.is_analysis_edition_allowed(analysis_brain): # Allow to set Remarks @@ -64,7 +65,6 @@ def _folder_item_result(self, analysis_brain, item): item["Result"] = "{} {}".format(operand, result).strip() # Prepare result options - result_type = obj.getResultType() item["result_type"] = result_type choices = self.get_result_options(obj) @@ -77,10 +77,23 @@ def _folder_item_result(self, analysis_brain, item): if result_type == "numeric": item["help"]["Result"] = _( "Enter the result either in decimal or scientific " - "notation, e.g. 0.00005 or 1e-5, 10000 or 1e5") + "notation, e.g. 0.00005 or 1e-5, 10000 or 1e5" + ) if result_type == "timeseries": - item["time_series_columns"] = [o['ColumnTitle'] for o in obj.TimeSeriesColumns] + item["time_series_columns"] = [ + o["ColumnTitle"] for o in obj.TimeSeriesColumns + ] + item["time_series_graph_title"] = obj.GraphTitle + item["time_series_graph_xaxis"] = obj.GraphXAxisTitle + item["time_series_graph_yaxis"] = obj.GraphYAxisTitle + else: + # Edit mode is NOT enabled of this Analysis + if result_type == "timeseries": + item["result_type"] = "timeseries_readonly" + item["time_series_columns"] = [ + o["ColumnTitle"] for o in obj.TimeSeriesColumns + ] item["time_series_graph_title"] = obj.GraphTitle item["time_series_graph_xaxis"] = obj.GraphXAxisTitle item["time_series_graph_yaxis"] = obj.GraphYAxisTitle @@ -89,7 +102,8 @@ def _folder_item_result(self, analysis_brain, item): return formatted_result = obj.getFormattedResult( - sciformat=int(self.scinot), decimalmark=self.dmk) + sciformat=int(self.scinot), decimalmark=self.dmk + ) item["formatted_result"] = formatted_result def folderitems(self): @@ -112,10 +126,9 @@ class FieldAnalysesTable(AnalysesView): def __init__(self, context, request): super(FieldAnalysesTable, self).__init__(context, request) - self.contentFilter.update({ - "getPointOfCapture": "field", - "getAncestorsUIDs": [api.get_uid(context)] - }) + self.contentFilter.update( + {"getPointOfCapture": "field", "getAncestorsUIDs": [api.get_uid(context)]} + ) self.form_id = "%s_field_analyses" % api.get_id(context) self.allow_edit = True @@ -130,10 +143,9 @@ class LabAnalysesTable(AnalysesView): def __init__(self, context, request): super(LabAnalysesTable, self).__init__(context, request) - self.contentFilter.update({ - "getPointOfCapture": "lab", - "getAncestorsUIDs": [api.get_uid(context)] - }) + self.contentFilter.update( + {"getPointOfCapture": "lab", "getAncestorsUIDs": [api.get_uid(context)]} + ) self.form_id = "%s_lab_analyses" % api.get_id(context) self.allow_edit = True