Order import: warn when char-replacement happens due to unknown encoding (#2184)

Co-authored-by: Raphael Michel <michel@rami.io>
This commit is contained in:
Richard Schreiber
2021-08-27 15:03:35 +02:00
committed by GitHub
parent e7068020d5
commit 529092a4ed
2 changed files with 14 additions and 3 deletions

View File

@@ -119,7 +119,17 @@ class ProcessView(EventPermissionRequiredMixin, AsyncAction, FormView):
@cached_property
def parsed(self):
return parse_csv(self.file.file, 1024 * 1024)
try:
return parse_csv(self.file.file, 1024 * 1024)
except UnicodeDecodeError:
messages.warning(
self.request,
_(
"We could not identify the character encoding of the CSV file. "
"Some characters were replaced with a placeholder."
)
)
return parse_csv(self.file.file, 1024 * 1024, "replace")
def get(self, request, *args, **kwargs):
if 'async_id' in request.GET and settings.HAS_CELERY: