Skip to content

Commit

Permalink
Merge pull request #205 from c3g/qc-fix-too-many-errors
Browse files Browse the repository at this point in the history
Qc fix too many errors
  • Loading branch information
UlysseFG authored Dec 16, 2021
2 parents 7c6aa59 + 5bea655 commit 4356683
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion backend/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.5.0
3.5.1
17 changes: 10 additions & 7 deletions backend/fms_core/template_importer/importers/_generic.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from django.core.exceptions import ValidationError
from pandas import pandas as pd
from django.db import transaction
import reversion
Expand Down Expand Up @@ -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)

Expand Down
5 changes: 1 addition & 4 deletions backend/fms_core/template_importer/row_handlers/_generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,4 @@ def get_result(self):
if v:
warnings.append(f"{k} : {v}")

return {'errors': [],
'validation_error': ValidationError(self.errors),
'warnings': warnings,
}
return {'errors': [], 'validation_error': ValidationError(self.errors), 'warnings': warnings}

0 comments on commit 4356683

Please sign in to comment.