diff --git a/app/scodoc/sco_excel.py b/app/scodoc/sco_excel.py index e8c02fe9..6904062c 100644 --- a/app/scodoc/sco_excel.py +++ b/app/scodoc/sco_excel.py @@ -568,10 +568,9 @@ def excel_bytes_to_list(bytes_content): return _excel_to_list(filelike) except: raise ScoValueError( + """Le fichier xlsx attendu n'est pas lisible ! + Peut-être avez-vous fourni un fichier au mauvais format (txt, xls, ..) """ - scolars_import_excel_file: un contenu xlsx semble corrompu! - peut-être avez vous fourni un fichier au mauvais format (txt, xls, ..) - """ ) @@ -580,10 +579,9 @@ def excel_file_to_list(filename): return _excel_to_list(filename) except: raise ScoValueError( - """scolars_import_excel_file: un contenu xlsx - semble corrompu ! - Peut-être avez-vous fourni un fichier au mauvais format (txt, xls, ...) - """ + """Le fichier xlsx attendu n'est pas lisible ! + Peut-être avez-vous fourni un fichier au mauvais format (txt, xls, ...) + """ ) diff --git a/app/scodoc/sco_import_etuds.py b/app/scodoc/sco_import_etuds.py index 1c366268..1107b11f 100644 --- a/app/scodoc/sco_import_etuds.py +++ b/app/scodoc/sco_import_etuds.py @@ -25,16 +25,16 @@ # ############################################################################## -""" Importation des etudiants à partir de fichiers CSV +""" Importation des étudiants à partir de fichiers CSV """ import collections +import io import os import re import time from datetime import date -import flask from flask import g, url_for import app.scodoc.sco_utils as scu @@ -252,7 +252,7 @@ def students_import_excel( def scolars_import_excel_file( - datafile, + datafile: io.BytesIO, formsemestre_id=None, check_homonyms=True, require_ine=False, @@ -414,16 +414,14 @@ def scolars_import_excel_file( if NbHomonyms: NbImportedHomonyms += 1 # Insert in DB tables - formsemestre_to_invalidate.add( - _import_one_student( - cnx, - formsemestre_id, - values, - GroupIdInferers, - annee_courante, - created_etudids, - linenum, - ) + formsemestre_id_etud = _import_one_student( + cnx, + formsemestre_id, + values, + GroupIdInferers, + annee_courante, + created_etudids, + linenum, ) # Verification proportion d'homonymes: si > 10%, abandonne @@ -522,7 +520,7 @@ def _import_one_student( annee_courante, created_etudids, linenum, -): +) -> int: """ Import d'un étudiant et inscription dans le semestre. Return: id du semestre dans lequel il a été inscrit. @@ -566,7 +564,7 @@ def _import_one_student( ) do_formsemestre_inscription_with_modules( - args["formsemestre_id"], + int(args["formsemestre_id"]), etudid, group_ids, etat="I", diff --git a/app/views/scolar.py b/app/views/scolar.py index 6750ddf4..ab02fa31 100644 --- a/app/views/scolar.py +++ b/app/views/scolar.py @@ -1757,6 +1757,7 @@ def check_group_apogee(group_id, etat=None, fix=False, fixmail=False): @scodoc7func def form_students_import_excel(formsemestre_id=None): "formulaire import xls" + formsemestre_id = int(formsemestre_id) if formsemestre_id else None if formsemestre_id: sem = sco_formsemestre.get_formsemestre(formsemestre_id) dest_url = ( @@ -1889,7 +1890,7 @@ Les champs avec un astérisque (*) doivent être présents (nulls non autorisés else: return sco_import_etuds.students_import_excel( tf[2]["csvfile"], - formsemestre_id=formsemestre_id, + formsemestre_id=int(formsemestre_id) if formsemestre_id else None, check_homonyms=tf[2]["check_homonyms"], require_ine=tf[2]["require_ine"], ) diff --git a/sco_version.py b/sco_version.py index dd1416cb..dc3e8dbd 100644 --- a/sco_version.py +++ b/sco_version.py @@ -1,7 +1,7 @@ # -*- mode: python -*- # -*- coding: utf-8 -*- -SCOVERSION = "9.0.44" +SCOVERSION = "9.0.45" SCONAME = "ScoDoc"