mirror of
https://gitlab.com/animath/si/plateforme.git
synced 2024-12-25 19:02:33 +00:00
Only process CSV files when they are correctly read
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
This commit is contained in:
parent
bcf4e294e0
commit
80cfe874f5
@ -261,12 +261,11 @@ class UploadNotesForm(forms.Form):
|
|||||||
with file:
|
with file:
|
||||||
try:
|
try:
|
||||||
csvfile = csv.reader(StringIO(file.read().decode()))
|
csvfile = csv.reader(StringIO(file.read().decode()))
|
||||||
|
self.process(csvfile, cleaned_data)
|
||||||
except UnicodeDecodeError:
|
except UnicodeDecodeError:
|
||||||
self.add_error('file', _("This file contains non-UTF-8 content. "
|
self.add_error('file', _("This file contains non-UTF-8 content. "
|
||||||
"Please send your sheet as a CSV file."))
|
"Please send your sheet as a CSV file."))
|
||||||
|
|
||||||
self.process(csvfile, cleaned_data)
|
|
||||||
|
|
||||||
return cleaned_data
|
return cleaned_data
|
||||||
|
|
||||||
def process(self, csvfile: Iterable[str], cleaned_data: dict):
|
def process(self, csvfile: Iterable[str], cleaned_data: dict):
|
||||||
|
Loading…
Reference in New Issue
Block a user