Allow ISO-8859-1 encoding is CSV files

Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
This commit is contained in:
Emmy D'Anello 2023-04-10 17:26:55 +02:00
parent 43af14ad77
commit 41e69992c0
Signed by: ynerant
GPG Key ID: 3A75C55819C8CF85
2 changed files with 41 additions and 32 deletions

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: TFJM\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-04-10 10:00+0200\n"
"POT-Creation-Date: 2023-04-10 17:24+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: Emmy D'Anello <emmy.danello@animath.fr>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -461,99 +461,102 @@ msgstr "rapporteur⋅e"
msgid "problem"
msgstr "numéro de problème"
#: participation/forms.py:30
#: participation/forms.py:32
msgid "This name is already used."
msgstr "Ce nom est déjà utilisé."
#: participation/forms.py:37 participation/models.py:40
#: participation/forms.py:39 participation/models.py:40
msgid "The trigram must be composed of three uppercase letters."
msgstr "Le trigramme doit être composé de trois lettres majuscules."
#: participation/forms.py:40
#: participation/forms.py:42
msgid "This trigram is already used."
msgstr "Ce trigramme est déjà utilisé."
#: participation/forms.py:55
#: participation/forms.py:57
msgid "No team was found with this access code."
msgstr "Aucune équipe n'a été trouvée avec ce code d'accès."
#: participation/forms.py:84 participation/forms.py:343
#: participation/forms.py:86 participation/forms.py:352
#: registration/forms.py:122 registration/forms.py:144
#: registration/forms.py:166 registration/forms.py:188
#: registration/forms.py:233
msgid "The uploaded file size must be under 2 Mo."
msgstr "Le fichier envoyé doit peser moins de 2 Mo."
#: participation/forms.py:86 registration/forms.py:124
#: participation/forms.py:88 registration/forms.py:124
#: registration/forms.py:146 registration/forms.py:168
#: registration/forms.py:190 registration/forms.py:235
msgid "The uploaded file must be a PDF, PNG of JPEG file."
msgstr "Le fichier envoyé doit être au format PDF, PNG ou JPEG."
#: participation/forms.py:104
#: participation/forms.py:106
msgid "I engage myself to participate to the whole TFJM²."
msgstr "Je m'engage à participer à l'intégralité du TFJM²."
#: participation/forms.py:119
#: participation/forms.py:121
msgid "Message to address to the team:"
msgstr "Message à adresser à l'équipe :"
#: participation/forms.py:154
#: participation/forms.py:156
msgid "The uploaded file size must be under 5 Mo."
msgstr "Le fichier envoyé doit peser moins de 5 Mo."
#: participation/forms.py:156 participation/forms.py:345
#: participation/forms.py:158 participation/forms.py:354
msgid "The uploaded file must be a PDF file."
msgstr "Le fichier envoyé doit être au format PDF."
#: participation/forms.py:160
#: participation/forms.py:162
msgid "The PDF file must not have more than 30 pages."
msgstr "Le fichier PDF ne doit pas avoir plus de 30 pages."
#: participation/forms.py:210
#: participation/forms.py:212
msgid "Add new jury"
msgstr "Ajouter un⋅e nouvelleau juré⋅e"
#: participation/forms.py:225
#: participation/forms.py:227
#: participation/templates/participation/pool_detail.html:101
#: participation/templates/participation/tournament_detail.html:111
msgid "Add"
msgstr "Ajouter"
#: participation/forms.py:238 registration/forms.py:35 registration/forms.py:60
#: participation/forms.py:240 registration/forms.py:35 registration/forms.py:60
#: registration/forms.py:91
msgid "This email address is already used."
msgstr "Cette adresse e-mail est déjà utilisée."
#: participation/forms.py:248
#: participation/forms.py:250
msgid "CSV file:"
msgstr "Tableur au format CSV :"
#: participation/forms.py:266
#: participation/forms.py:274
msgid ""
"This file contains non-UTF-8 content. Please send your sheet as a CSV file."
"This file contains non-UTF-8 and non-ISO-8859-1 content. Please send your "
"sheet as a CSV file."
msgstr ""
"Ce fichier contient des éléments non-UTF-8. Merci d'envoyer votre tableur au "
"format CSV."
"Ce fichier contient des éléments non-UTF-8 et non-ISO-8859-1. Merci "
"d'envoyer votre tableur au format CSV."
#: participation/forms.py:281
#: participation/forms.py:289
msgid "Can't determine the pool size. Are you sure your file is correct?"
msgstr "Impossible de déterminer la taille de la poule. Êtes-vous sûr⋅e que le fichier est correct ?"
msgstr ""
"Impossible de déterminer la taille de la poule. Êtes-vous sûr⋅e que le "
"fichier est correct ?"
#: participation/forms.py:301
#: participation/forms.py:309
msgid "The following note is higher of the maximum expected value:"
msgstr "La note suivante est supérieure au maximum attendu :"
#: participation/forms.py:309
#: participation/forms.py:318
msgid "The following user was not found:"
msgstr "L'utilisateur⋅rice suivant n'a pas été trouvé :"
#: participation/forms.py:326
#: participation/forms.py:335
msgid "The defender, the opponent and the reporter must be different."
msgstr ""
"Læ défenseur⋅se, l'opposant⋅e et læ rapporteur⋅e doivent être différent⋅es."
#: participation/forms.py:330
#: participation/forms.py:339
msgid "This defender did not work on this problem."
msgstr "Ce⋅tte défenseur⋅se ne travaille pas sur ce problème."
@ -1593,15 +1596,15 @@ msgstr "Nouveau compte de juré⋅e pour le TFJM²"
msgid "The jury {name} has been successfully added!"
msgstr "Læ juré⋅e {name} a été ajouté⋅e avec succès !"
#: participation/views.py:814
#: participation/views.py:815
msgid "The following user is not registered as a jury:"
msgstr "L'utilisateur⋅rice suivant n'est pas inscrit⋅e en tant que juré⋅e :"
#: participation/views.py:824
#: participation/views.py:825
msgid "Notes were successfully uploaded."
msgstr "Les notes ont bien été envoyées."
#: participation/views.py:1488
#: participation/views.py:1489
msgid "You can't upload a synthesis after the deadline."
msgstr "Vous ne pouvez pas envoyer de note de synthèse après la date limite."

View File

@ -262,10 +262,16 @@ class UploadNotesForm(forms.Form):
file = cleaned_data['file']
with file:
try:
csvfile = csv.reader(StringIO(file.read().decode()))
data: bytes = file.read()
try:
content = data.decode()
except UnicodeDecodeError:
# This is not UTF-8, grrrr
content = data.decode('latin1')
csvfile = csv.reader(StringIO(content))
self.process(csvfile, cleaned_data)
except UnicodeDecodeError:
self.add_error('file', _("This file contains non-UTF-8 content. "
self.add_error('file', _("This file contains non-UTF-8 and non-ISO-8859-1 content. "
"Please send your sheet as a CSV file."))
return cleaned_data
@ -276,7 +282,7 @@ class UploadNotesForm(forms.Form):
pool_size = 0
line_length = 0
for line in csvfile:
line = [s for s in line if s]
line = [s.strip() for s in line if s]
if line and line[0] == 'Problème':
pool_size = len(line) - 1
if pool_size < 3 or pool_size > 5: