From 51fec2d301b7f5224c483dc0f3ed1a6e0e604761 Mon Sep 17 00:00:00 2001
From: Emmanuel Viennet <emmanuel.viennet@gmail.com>
Date: Wed, 29 Sep 2021 14:47:43 +0200
Subject: [PATCH] =?UTF-8?q?Change=20le=20type=20de=20bulletin=20par=20d?=
 =?UTF-8?q?=C3=A9faut=20pour=20les=20nouveaux=20d=C3=A9partements.=20Le=20?=
 =?UTF-8?q?type=20"exemple"=20n'est=20propos=C3=A9=20qu'en=20dev.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 README.md       |  9 ++++++---
 app/__init__.py | 10 +++++++---
 2 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/README.md b/README.md
index 753fc3dc9..014e6869f 100644
--- a/README.md
+++ b/README.md
@@ -106,13 +106,15 @@ Ou avec couverture (`pip install pytest-cov`)
 
 #### Utilisation des tests unitaires pour initialiser la base de dev
 On peut aussi utiliser les tests unitaires pour mettre la base 
-de données de développement dans un état connu, par exemple pour éviter de recréer à la main étudianst et semestres quand on développe.
+de données de développement dans un état connu, par exemple pour éviter de
+recréer à la main étudianst et semestres quand on développe. 
 
 Il suffit de positionner une variable d'environnement indiquant la BD utilisée par les tests:
 
     export SCODOC_TEST_DATABASE_URI=postgresql:///SCODOC_DEV
 
-puis de les lancer normalement, par exemple:
+(si elle n'existe pas, voir plus loin pour la créer) puis de les lancer
+normalement, par exemple: 
 
     pytest tests/unit/test_sco_basic.py
 
@@ -133,7 +135,8 @@ On utilise SQLAlchemy avec Alembic et Flask-Migrate.
 
 Ne pas oublier de commiter les migrations (`git add migrations` ...).
 
-Mémo pour développeurs: séquence re-création d'une base:
+Mémo pour développeurs: séquence re-création d'une base (vérifiez votre `.env`
+ou variables d'environnement pour interroger la bonne base !).
 
     dropdb SCODOC_DEV
     tools/create_database.sh SCODOC_DEV # créé base SQL
diff --git a/app/__init__.py b/app/__init__.py
index a3f048391..25ea4f6b3 100644
--- a/app/__init__.py
+++ b/app/__init__.py
@@ -259,15 +259,19 @@ def create_app(config_class=DevConfig):
         )
     # ---- INITIALISATION SPECIFIQUES A SCODOC
     from app.scodoc import sco_bulletins_generator
-    from app.scodoc.sco_bulletins_example import BulletinGeneratorExample
+
     from app.scodoc.sco_bulletins_legacy import BulletinGeneratorLegacy
     from app.scodoc.sco_bulletins_standard import BulletinGeneratorStandard
     from app.scodoc.sco_bulletins_ucac import BulletinGeneratorUCAC
 
-    sco_bulletins_generator.register_bulletin_class(BulletinGeneratorExample)
-    sco_bulletins_generator.register_bulletin_class(BulletinGeneratorLegacy)
+    # l'ordre est important, le premeir sera le "défaut" pour les nouveaux départements.
     sco_bulletins_generator.register_bulletin_class(BulletinGeneratorStandard)
+    sco_bulletins_generator.register_bulletin_class(BulletinGeneratorLegacy)
     sco_bulletins_generator.register_bulletin_class(BulletinGeneratorUCAC)
+    if app.testing or app.debug:
+        from app.scodoc.sco_bulletins_example import BulletinGeneratorExample
+
+        sco_bulletins_generator.register_bulletin_class(BulletinGeneratorExample)
 
     return app
 
-- 
GitLab