Repository navigation
Map some container model errors for the container creation form. - #1204
Conversation
|
The migration is some model alterations that were not made (forgotten) during last release (small mismatch). |
| for error in errors: | ||
| for pattern, field in patterns: | ||
| if re.fullmatch(pattern, error): | ||
| raise ValidationError({field: ",".join(errors)}) |
There was a problem hiding this comment.
So if there is coordinate error, we assume all errors are related to coordinate?
There was a problem hiding this comment.
Well there is potentially more than one error but these are the ones that are likely to creep up here if additional error arise and are not caught you'll add them to whatever get assigned ... if nothing get assigned it will be listed under barcode ...
Maybe i should just liste the error matching and once they fix it they would get another one ...
| for error in errors: | ||
| for pattern, field in patterns: | ||
| if re.fullmatch(pattern, error): | ||
| raise ValidationError({field: error}) | ||
| raise ValidationError({"barcode": ",".join(errors)}) # Default errors to the Barcode form field until we map it. |
There was a problem hiding this comment.
Can't you have a dictionary that collects errors for coordinate and barcode?
There was a problem hiding this comment.
You need to say more to say anything ... This is already a dictionary with coordinate or barcode error.
There was a problem hiding this comment.
😪
To clarify what I'm saying, you are returning error either for barcode or coordinate. Why not with both kinds of errors at once?
There was a problem hiding this comment.
Like loop over each error, if you come across a barcode error errors["barcode"] = ..., if it's a coordinate error errors["coordinate"] = .... And then return errors at the end of the loop.
There was a problem hiding this comment.
ok I am not sure if this would be the best way to present it in the frontend ... The form will list the errors that match the fields. If more than one error match you would likely get a absurdedly long error line to parse. The Barcode is just a catchall category to make sure the error message displays on the form.
There was a problem hiding this comment.
I will parse through the whole set of errors. For now there is no clash to be expected anyway ...
| if re.fullmatch(pattern, error): | ||
| parsed_errors[field] += error |
There was a problem hiding this comment.
At least a space between errors?
… error and forward it to the form.
| .then(() => { setFormErrors({}) }) | ||
| .catch(err => { setFormErrors(err.data || {}) }) | ||
| .then(() => Promise.all([refreshTable()])) |
There was a problem hiding this comment.
I wonder if .then(() => { setFormErrors({}) }) is even useful since you'd be redirected to another page anyway.
No description provided.