lims_instrument: "Load Results from File" wizard: validation refactoring

This commit is contained in:
Adri?n Bernardi 2019-01-31 18:37:34 -03:00
parent 43cede2430
commit 135e61c689
1 changed files with 16 additions and 15 deletions

View File

@ -474,24 +474,25 @@ class NotebookLoadResultsFile(Wizard):
outcome = 'OK' outcome = 'OK'
if line.imported_result != '-1000.0': if line.imported_result != '-1000.0':
line.result = line.imported_result if not line.imported_end_date:
if (line.start_date and prevent_line = True
line.start_date <= line.imported_end_date): outcome = 'End date cannot be empty'
line.end_date = line.imported_end_date elif (line.imported_end_date and line.start_date and
else: line.start_date > line.imported_end_date):
prevent_line = True prevent_line = True
outcome = 'End date cannot be lower than Start date' outcome = 'End date cannot be lower than Start date'
if (line.start_date and elif (line.imported_inj_date and line.start_date and
line.start_date <= line.imported_inj_date): line.start_date > line.imported_inj_date):
line.injection_date = line.imported_inj_date prevent_line = True
outcome = 'Injection date cannot be lower than Start date'
elif (line.imported_end_date and line.imported_inj_date and
line.imported_inj_date > line.imported_end_date):
prevent_line = True
outcome = 'Injection date cannot be upper than End date'
else: else:
prevent_line = True line.result = line.imported_result
outcome = ('Injection date cannot be lower than ' line.end_date = line.imported_end_date
'Start date') line.injection_date = line.imported_inj_date
if line.imported_inj_date > line.imported_end_date:
prevent_line = True
outcome = ('Injection date cannot be upper than '
'End date')
else: else:
line.result = None line.result = None