lims_instrument: "Load Results from File" wizard: improve error messages

This commit is contained in:
Adri?n Bernardi 2019-02-01 09:40:31 -03:00
parent 135e61c689
commit 8c98e04be2
4 changed files with 46 additions and 9 deletions

View File

@ -2,6 +2,26 @@
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "error:lims.notebook.load_results_file:"
msgid "End date cannot be empty"
msgstr "La Fecha de finalización no puede estar vacía"
msgctxt "error:lims.notebook.load_results_file:"
msgid "End date cannot be lower than Start date"
msgstr "La Fecha de finalización no puede ser menor que la Fecha de inicio"
msgctxt "error:lims.notebook.load_results_file:"
msgid "Injection date cannot be lower than Start date"
msgstr "La Fecha de inyección no puede ser menor que la Fecha de inicio"
msgctxt "error:lims.notebook.load_results_file:"
msgid "Injection date cannot be upper than End date"
msgstr "La Fecha de inyección no puede ser mayor que la Fecha de finalización"
msgctxt "error:lims.notebook.load_results_file:"
msgid "Professional(s) with code %s not identified"
msgstr "Profesional(es) no identificado(s): %s"
msgctxt "error:lims.resultsimport:"
msgid "No module for importer type \"%s\""
msgstr "No se ha definido un módulo para el importador \"%s\""

View File

@ -299,6 +299,19 @@ class NotebookLoadResultsFile(Wizard):
Button('Done', 'end', 'tryton-close', default=True),
])
@classmethod
def __setup__(cls):
super(NotebookLoadResultsFile, cls).__setup__()
cls._error_messages.update({
'end_date': 'End date cannot be empty',
'end_date_start_date': 'End date cannot be lower than Start date',
'inj_date_start_date': ('Injection date cannot be lower than '
'Start date'),
'inj_date_end_date': ('Injection date cannot be upper than '
'End date'),
'professionals': 'Professional(s) with code %s not identified',
})
def transition_collect(self):
cursor = Transaction().connection.cursor()
pool = Pool()
@ -476,19 +489,23 @@ class NotebookLoadResultsFile(Wizard):
if line.imported_result != '-1000.0':
if not line.imported_end_date:
prevent_line = True
outcome = 'End date cannot be empty'
outcome = self.raise_user_error('end_date',
raise_exception=False)
elif (line.imported_end_date and line.start_date and
line.start_date > line.imported_end_date):
prevent_line = True
outcome = 'End date cannot be lower than Start date'
outcome = self.raise_user_error('end_date_start_date',
raise_exception=False)
elif (line.imported_inj_date and line.start_date and
line.start_date > line.imported_inj_date):
prevent_line = True
outcome = 'Injection date cannot be lower than Start date'
outcome = self.raise_user_error('inj_date_start_date',
raise_exception=False)
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'
outcome = self.raise_user_error('inj_date_end_date',
raise_exception=False)
else:
line.result = line.imported_result
line.end_date = line.imported_end_date
@ -527,9 +544,9 @@ class NotebookLoadResultsFile(Wizard):
outcome = msg
else:
prevent_line = True
outcome = ('Professional(s) with code '
+ unicode(line.imported_professionals)
+ ' not identified')
outcome = self.raise_user_error('professionals',
(unicode(line.imported_professionals),),
raise_exception=False)
if prevent_line:
row_num = 0

View File

@ -1,6 +1,6 @@
<?xml version="1.0"?>
<form>
<image name="tryton-dialog-information" xexpand="0" xfill="0"/>
<image name="tryton-info" xexpand="0" xfill="0"/>
<label string="No data could be collected from files" id="ask"
yalign="0.0" xalign="0.0" xexpand="1"/>
</form>

View File

@ -1,6 +1,6 @@
<?xml version="1.0"?>
<form>
<image name="tryton-dialog-information" xexpand="0" xfill="0"/>
<image name="tryton-info" xexpand="0" xfill="0"/>
<label string="Save the results in file" id="message"
yalign="0.0" xalign="0.0" xexpand="1"/>
<newline/>