From 60109bb51388f1f2f1c3b469304d9d0babf013da Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Fri, 24 Nov 2023 13:55:53 +0100 Subject: [PATCH] Import etudiant: accepte boursier=O|N (API USPN) --- app/models/__init__.py | 2 +- app/models/etudiants.py | 2 +- sco_version.py | 2 +- tests/api/test_api_etudiants.py | 4 ++++ 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/models/__init__.py b/app/models/__init__.py index b4eea1636..ed0b3bac2 100644 --- a/app/models/__init__.py +++ b/app/models/__init__.py @@ -79,7 +79,7 @@ class ScoDocModel: # virtual, by default, do nothing return args - def from_dict(self, args: dict, excluded: set[str] = None): + def from_dict(self, args: dict, excluded: set[str] | None = None): "Update object's fields given in dict. Add to session but don't commit." args_dict = self.convert_dict_fields( self.filter_model_attributes(args, excluded=excluded) diff --git a/app/models/etudiants.py b/app/models/etudiants.py index d0344166c..a7ecf2dfe 100644 --- a/app/models/etudiants.py +++ b/app/models/etudiants.py @@ -376,7 +376,7 @@ class Identite(db.Model, models.ScoDocModel): elif key == "civilite_etat_civil": value = input_civilite_etat_civil(value) elif key == "boursier": - value = bool(value) + value = scu.to_bool(value) elif key == "date_naissance": value = ndb.DateDMYtoISO(value) args_dict[key] = value diff --git a/sco_version.py b/sco_version.py index f2743e433..1522700f6 100644 --- a/sco_version.py +++ b/sco_version.py @@ -1,7 +1,7 @@ # -*- mode: python -*- # -*- coding: utf-8 -*- -SCOVERSION = "9.6.61" +SCOVERSION = "9.6.62" SCONAME = "ScoDoc" diff --git a/tests/api/test_api_etudiants.py b/tests/api/test_api_etudiants.py index ab29e432e..208ff1e82 100644 --- a/tests/api/test_api_etudiants.py +++ b/tests/api/test_api_etudiants.py @@ -971,10 +971,12 @@ def test_etudiant_create(api_headers): f"/etudiant/etudid/{etudid}/edit", { "civilite": "F", + "boursier": "N", }, headers=admin_header, ) assert etud["civilite"] == "F" + assert not etud["boursier"] assert etud["nom"] == args["nom"].upper() assert etud["admission"]["commentaire"] == args["admission"]["commentaire"] assert etud["admission"]["annee_bac"] == args["admission"]["annee_bac"] @@ -999,7 +1001,9 @@ def test_etudiant_create(api_headers): "admission": { "commentaire": "un nouveau commentaire", }, + "boursier": "O", # "oui", should be True }, headers=admin_header, ) assert etud["admission"]["commentaire"] == "un nouveau commentaire" + assert etud["boursier"]