diff --git a/backend/VERSION b/backend/VERSION index 1545d9665..d5c0c9914 100644 --- a/backend/VERSION +++ b/backend/VERSION @@ -1 +1 @@ -3.5.0 +3.5.1 diff --git a/backend/fms_core/template_importer/importers/_generic.py b/backend/fms_core/template_importer/importers/_generic.py index 4004daea2..b0e0cfb8c 100644 --- a/backend/fms_core/template_importer/importers/_generic.py +++ b/backend/fms_core/template_importer/importers/_generic.py @@ -1,3 +1,4 @@ +from django.core.exceptions import ValidationError from pandas import pandas as pd from django.db import transaction import reversion @@ -85,15 +86,17 @@ def initialize_data_for_template(self, **kwargs): def handle_row(self, row_handler_class, sheet, row_i, **kwargs): row_handler_obj = row_handler_class() - result = row_handler_obj.process_row(**kwargs) - sheet.rows_results[row_i].update(**result) - - if result['validation_error']: - self.errors_count += 1 - if self.errors_count >= self.ERRORS_CUTOFF: - raise ValueError('Too many errors. Template validation was stopped.') + result = {'errors': [], 'validation_error': ValidationError({}), 'warnings': {}} # Skip row handling, report no error + else: + result = row_handler_obj.process_row(**kwargs) + + if result['validation_error'].messages: + self.errors_count += 1 + if self.errors_count >= self.ERRORS_CUTOFF: + result = {'errors': [], 'validation_error': ValidationError({"Too many errors": f"Template validation interrupted."}), 'warnings': {}} + sheet.rows_results[row_i].update(**result) row_obj = row_handler_obj.row_object return (result, row_obj) diff --git a/backend/fms_core/template_importer/row_handlers/_generic.py b/backend/fms_core/template_importer/row_handlers/_generic.py index 9ccad6347..bcb28abd7 100644 --- a/backend/fms_core/template_importer/row_handlers/_generic.py +++ b/backend/fms_core/template_importer/row_handlers/_generic.py @@ -34,7 +34,4 @@ def get_result(self): if v: warnings.append(f"{k} : {v}") - return {'errors': [], - 'validation_error': ValidationError(self.errors), - 'warnings': warnings, - } \ No newline at end of file + return {'errors': [], 'validation_error': ValidationError(self.errors), 'warnings': warnings} \ No newline at end of file