Première version
This commit is contained in:
12
apply_patches.sh
Normal file
12
apply_patches.sh
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
patches_root="$(pwd)/patches.d/"
|
||||||
|
|
||||||
|
for patch_file in $(find $patches_root -name "*.patch")
|
||||||
|
do
|
||||||
|
pushd /
|
||||||
|
patch -p0 < $patch_file
|
||||||
|
popd
|
||||||
|
done
|
||||||
|
|
||||||
|
exit 0
|
13
etabs_with_individus.sh
Normal file
13
etabs_with_individus.sh
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
for etab in $(python3 find_individus.py -t current_etabs)
|
||||||
|
do
|
||||||
|
ldapsearch -LLL -x -b "ou=$etab,ou=tst-colleges,ou=education,o=gouv,c=fr" uid | grep -q uid
|
||||||
|
res=$?
|
||||||
|
if [ $res -eq 0 ]
|
||||||
|
then
|
||||||
|
echo $etab
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
exit 0
|
18
explore_ldap.py
Normal file
18
explore_ldap.py
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
from scribe.enseignants import LdapEnseignant
|
||||||
|
from scribe.eoleldap import Ldap
|
||||||
|
from scribe.storage import init_store
|
||||||
|
from scribe.importation import config
|
||||||
|
from scribe.storage import Enseigant
|
||||||
|
|
||||||
|
storage = init_store(config.DB_STORE)
|
||||||
|
|
||||||
|
connexion = Ldap()
|
||||||
|
connexion.connect()
|
||||||
|
|
||||||
|
user = LdapEnseignant()
|
||||||
|
user.ldap_admin = connexion
|
||||||
|
|
||||||
|
user.ldap_admin._search_one()
|
||||||
|
|
67
find_individus.py
Normal file
67
find_individus.py
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import xml.etree.ElementTree as ET
|
||||||
|
from pathlib import Path
|
||||||
|
from scribe.eoleldap import get_etabs
|
||||||
|
|
||||||
|
current_etabs = get_etabs()[1]
|
||||||
|
|
||||||
|
root = Path('/home/adhomes/admin/perso/comptes')
|
||||||
|
repartition = {}
|
||||||
|
etabs = []
|
||||||
|
individus = {}
|
||||||
|
for xml in root.glob('**/sts_emp*.xml'):
|
||||||
|
tree = ET.parse(xml)
|
||||||
|
tree_root = tree.getroot()
|
||||||
|
etab = tree_root.find('./PARAMETRES/UAJ').get('CODE')
|
||||||
|
etabs.append(etab)
|
||||||
|
for individu in tree_root.iter('INDIVIDU'):
|
||||||
|
id_ind = individu.get('ID')
|
||||||
|
nom_ind = individu.find('NOM_USAGE')
|
||||||
|
try:
|
||||||
|
nom_ind = nom_ind.text
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
prenom_ind = individu.find('PRENOM')
|
||||||
|
try:
|
||||||
|
prenom_ind = prenom_ind.text
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
fonction_ind = individu.find('FONCTION')
|
||||||
|
try:
|
||||||
|
fonction_ind = fonction_ind.text
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
key = id_ind
|
||||||
|
repartition.setdefault(key, [])
|
||||||
|
repartition[key].append(etab)
|
||||||
|
individus.setdefault(key, [])
|
||||||
|
individus[key].append({'nom': nom_ind, 'prenom': prenom_ind, 'fonction': fonction_ind})
|
||||||
|
|
||||||
|
etabs = list(set(etabs))
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
from argparse import ArgumentParser
|
||||||
|
parser = ArgumentParser()
|
||||||
|
parser.add_argument('-t', '--type')
|
||||||
|
parser.add_argument('-e', '--extended', action='store_true')
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
if args.type == 'individus':
|
||||||
|
if args.extended:
|
||||||
|
result = ["{}\t{}".format(individus[ind][0]['nom'], " ".join(sorted(set(e)))) for ind, e in repartition.items() if len(set(e)) > 1]
|
||||||
|
else:
|
||||||
|
result = [individus[ind][0]['nom'] for ind, e in repartition.items() if len(set(e)) > 1]
|
||||||
|
elif args.type == 'presents':
|
||||||
|
if args.extended:
|
||||||
|
result = ["{} {}\t\t{}".format(individus[ind][0]['nom'], individus[ind][0]['prenom'], " ".join(set(e))) for ind, e in repartition.items() if len(set(e).intersection(set(current_etabs))) > 1]
|
||||||
|
else:
|
||||||
|
result = [individus[ind][0]['nom'] for ind, e in repartition.items() if len(set(e).intersection(set(current_etabs))) > 1]
|
||||||
|
elif args.type == 'current_etabs':
|
||||||
|
result = current_etabs
|
||||||
|
elif args.type == 'etabs':
|
||||||
|
result = etabs
|
||||||
|
else:
|
||||||
|
result = []
|
||||||
|
print("\n".join(sorted(result)))
|
||||||
|
|
39
patches.d/scribe-backend.patch
Normal file
39
patches.d/scribe-backend.patch
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
diff --git usr/lib/python3/dist-packages/scribe/importation/writer.py usr/lib/python3/dist-packages/scribe/importation/writer.py
|
||||||
|
index 34ce0fb..e4ddfea 100644
|
||||||
|
--- usr/lib/python3/dist-packages/scribe/importation/writer.py
|
||||||
|
+++ usr/lib/python3/dist-packages/scribe/importation/writer.py
|
||||||
|
@@ -900,10 +900,10 @@ def write_enseignant(store, connexion, etab=None, current_ead_user=config.DEFAUL
|
||||||
|
else:
|
||||||
|
login = ''
|
||||||
|
else:
|
||||||
|
- login = _enseignant_exists(enseignant, user)
|
||||||
|
+ login = _enseignant_exists(enseignant, user, etab=etab)
|
||||||
|
if login != '':
|
||||||
|
# enseignant existant
|
||||||
|
- _maj_enseignant(enseignant, user, login, etab)
|
||||||
|
+ _maj_enseignant(enseignant, user, login, etab=etab)
|
||||||
|
else:
|
||||||
|
# nouvel enseignant
|
||||||
|
if str(enseignant.nom) == '' or str(enseignant.prenom) == '':
|
||||||
|
@@ -1027,7 +1027,7 @@ def write_administratif(store, connexion, etab=None, current_ead_user=config.DEF
|
||||||
|
# personnel existe
|
||||||
|
_maj_administratif(administratif, user, login)
|
||||||
|
else:
|
||||||
|
- login = _enseignant_exists(administratif, user)
|
||||||
|
+ login = _enseignant_exists(administratif, user, etab)
|
||||||
|
if login != '':
|
||||||
|
# le personnel a été crée comme un professeur...
|
||||||
|
log.infolog("(%s a un compte enseignant)" % login)
|
||||||
|
diff --git usr/lib/python3/dist-packages/scribe/linker.py usr/lib/python3/dist-packages/scribe/linker.py
|
||||||
|
index 71fb28d..09af637 100644
|
||||||
|
--- usr/lib/python3/dist-packages/scribe/linker.py
|
||||||
|
+++ usr/lib/python3/dist-packages/scribe/linker.py
|
||||||
|
@@ -99,7 +99,7 @@ def _responsable_exists(responsable, user):
|
||||||
|
return res['uid'][0]
|
||||||
|
return ''
|
||||||
|
|
||||||
|
-def _enseignant_exists(enseignant, user):
|
||||||
|
+def _enseignant_exists(enseignant, user, etab=None):
|
||||||
|
"""
|
||||||
|
recherche si un enseignant existe déjà dans l'annuaire
|
||||||
|
enseignant : storage.Enseignant()
|
12
unapply_patches.sh
Normal file
12
unapply_patches.sh
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
patches_root="$(pwd)/patches.d/"
|
||||||
|
|
||||||
|
for patch_file in $(find $patches_root -name "*.patch")
|
||||||
|
do
|
||||||
|
pushd /
|
||||||
|
patch -p0 -R < $patch_file
|
||||||
|
popd
|
||||||
|
done
|
||||||
|
|
||||||
|
exit 0
|
Reference in New Issue
Block a user