Parce que «Ça peut toujours servir»™ et que de toutes façons il y en a déjà des bouts qui sont dans le dépôt et que c'est chiant de git add -f.

Et puis bon, ça fait que 3Mo
This commit is contained in:
Vincent Le Gallic 2013-05-08 05:49:55 +02:00
parent 29f50c2ed9
commit 3bde363deb
299 changed files with 17466 additions and 0 deletions

37
archive/bdd/cles Normal file
View file

@ -0,0 +1,37 @@
['mailAlias',
'tel',
'cn',
'objectClass',
'uidNumber',
'etudes',
'shadowMax',
'shadowLastChange',
'uid',
'canonicalAlias',
'historique',
'userPassword',
'derniereConnexion',
'mail',
'paiement',
'nom',
'loginShell',
'gidNumber',
'chbre',
'rewriteMailHeaders',
'shadowWarning',
'info',
'prenom',
'gecos',
'homeDirectory',
'aid',
'carteEtudiant',
'controle',
'mailInvalide',
'blacklist',
'postalAddress',
'solde',
'droits',
'contourneGreylist',
'charteMA',
'homepageAlias']

34
archive/bdd/comptes.py Normal file
View file

@ -0,0 +1,34 @@
from sqlobject import *
#from comptes import CompteUnix
class Attribut(SQLObject):
nom = UnicodeCol()
url_desc = StringCol(default=None)
permissions = RelatedJoin('Permission')
groupes_unix = RelatedJoin('GroupeUnix')
comptes = RelatedJoin('CompteUnix')
class Permission(SQLObject):
nom = UnicodeCol()
attributs = RelatedJoin('Attribut')
class CompteUnix(SQLObject):
proprio = ForeignKey('Proprio')
solde = FloatCol()
attributs = RelatedJoin('Attribut')
# Champs standards
username = StringCol(unique=True)
passwd = UnicodeCol()
uid = IntCol(unique=True)
homedir = StringCol()
shell = StringCol()
gecos = StringCol()
pwdexpire = DateTimeCol(default=None)
gid = IntCol()
class GroupeUnix(SQLObject):
gid = IntCol(unique=True)
nom = StringCol(unique=True)
descr = UnicodeCol()
passwd = StringCol(default='!')

View file

@ -0,0 +1,9 @@
from sqlobject import *
import sys, os
sys.path.append('/usr/scripts/bdd/secret')
from mdp import mdp
connection_string = 'postgres://respbats:%s@localhost/gestion2?debug=False&cache=True' % mdp
connection = connectionForURI(connection_string)
sqlhub.processConnection = connection

7
archive/bdd/controle.py Normal file
View file

@ -0,0 +1,7 @@
from sqlobject import *
class Controle(SQLObject):
Proprio = ForeignKey('Proprio')
nom = Strincol()
date = DateCol()

12
archive/bdd/local.py Normal file
View file

@ -0,0 +1,12 @@
from sqlobject import *
class Local(SQLObject):
nom = StringCol(unique=True)
proprio = ForeignKey('Proprio')
batiment = ForeignKey('Batiment')
class Batiment(SQLObject):
nom = StringCol(unique=True)

160
archive/bdd/migration.py Executable file
View file

@ -0,0 +1,160 @@
#! /usr/bin/python
if __name__ == '__main__':
import sys
sys.path.append('/usr/scripts/gestion')
from ldap_crans import crans_ldap
ldap = crans_ldap()
import connection
from proprio import Proprio
from comptes import CompteUnix
from local import Local
from comptes import Attribut
from comptes import GroupeUnix
adherents_ldap = ldap.search('nom=*')['adherent'] # Pour les tests, on ne selectionne que les nounous
#adherents_ldap = []
for adherent_ldap in adherents_ldap:
data = adherent_ldap._data
args = {}
args['categorie'] = u'adherent'
args['id_ldap'] = int(adherent_ldap.id())
args['nom'] = adherent_ldap.nom()
args['prenom'] = adherent_ldap.prenom()
args['titre'] = None
args['naissance'] = None
args['adresse1'] = adherent_ldap.adresse()[0]
args['adresse2'] = adherent_ldap.adresse()[1]
args['code_postal'] = adherent_ldap.adresse()[2]
args['ville'] = adherent_ldap.adresse()[3]
args['pays'] = None
args['telephone'] = adherent_ldap.tel()
args['email'] = adherent_ldap.email()
args['etablissement'] = adherent_ldap.etudes(0)
args['annee_etudes'] = adherent_ldap.etudes(1)
args['filiere'] = adherent_ldap.etudes(2)
args['remarques'] = '\n'.join(adherent_ldap.info())
args['fictif'] = False
args['responsableID'] = None
selection = Proprio.select(Proprio.q.id_ldap == adherent_ldap.id())
if selection.count() == 0:
proprio_pg = Proprio(**args)
else:
proprio_pg = selection[0]
proprio_pg.set(**args)
if 'uid' in adherent_ldap._data:
args = {}
args['proprioID'] = proprio_pg.id
args['username'] = adherent_ldap.mail()
args['passwd'] = '!'
args['uid'] = int(adherent_ldap._data['uidNumber'][0])
args['homedir'] = adherent_ldap._data['homeDirectory'][0]
args['shell'] = adherent_ldap._data['loginShell'][0]
args['gecos'] = adherent_ldap._data['gecos'][0]
args['gid'] = 3
args['solde'] = adherent_ldap.solde()
selection = CompteUnix.select(CompteUnix.q.proprioID == proprio_pg.id)
if selection.count() == 0:
compte_pg = CompteUnix(**args)
else:
compte_pg = selection[0]
compte_pg.set(**args)
for droit in adherent_ldap.droits():
selection = Attribut.select(Attribut.q.nom == droit)
if selection.count() == 0:
attribut = Attribut(nom=droit)
else:
attribut = selection[0]
if attribut not in compte_pg.attributs:
compte_pg.addAttribut(attribut)
print adherent_ldap.nom()
clubs_ldap = ldap.search('cid=*')['club'] # Pour les tests, on ne selectionne que les nounous
for club_ldap in clubs_ldap:
data = club_ldap._data
args = {}
args['categorie'] = u'club'
args['id_ldap'] = int(club_ldap.id())
args['nom'] = club_ldap.nom()
args['prenom'] = None
args['titre'] = None
args['naissance'] = None
args['adresse1'] = None
args['adresse2'] = None
args['code_postal'] = None
args['ville'] = None
args['pays'] = None
args['telephone'] = None
args['email'] = None
args['etablissement'] = None
args['annee_etudes'] = None
args['filiere'] = None
args['remarques'] = '\n'.join(club_ldap.info())
args['fictif'] = False
args['responsableID'] = Proprio.select(Proprio.q.id_ldap == club_ldap._data['responsable'][0])[0].id
selection = Proprio.select(Proprio.q.id_ldap == club_ldap.id())
if selection.count() == 0:
proprio_pg = Proprio(**args)
else:
proprio_pg = selection[0]
proprio_pg.set(**args)
if 'uid' in club_ldap._data:
args = {}
args['proprioID'] = proprio_pg.id
args['username'] = club_ldap._data['uid']
args['passwd'] = '!'
args['uid'] = int(club_ldap._data['uidNumber'][0])
args['homedir'] = club_ldap._data['homeDirectory'][0]
args['shell'] = club_ldap._data['loginShell'][0]
args['gecos'] = None
args['gid'] = 3
args['solde'] = club_ldap.solde()
selection = CompteUnix.select(CompteUnix.q.proprioID == proprio_pg.id)
if selection.count() == 0:
compte_pg = CompteUnix(**args)
else:
compte_pg = selection[0]
compte_pg.set(**args)
print club_ldap.nom()
nounou = Attribut.select(Attribut.q.nom == u'Nounou')[0]
selection = GroupeUnix.select(GroupeUnix.q.nom == 'ssh_partout')
if selection.count() == 0:
ssh_partout = GroupeUnix(nom='ssh_partout', gid=200, descr='Groupes des utilisateur autorises a se logger partout')
else:
ssh_partout = selection[0]
if ssh_partout not in nounou.groupes_unix:
nounou.addGroupeUnix(ssh_partout)

57
archive/bdd/proprio.py Normal file
View file

@ -0,0 +1,57 @@
from sqlobject import *
from datetime import datetime
from local import Local
class Proprio(SQLObject):
id_ldap = IntCol(unique=True)
""" L'aid/cid est uniquement la pour la retrocompatibilite avec LDAP
Attention : dans LDAP, le meme aid peut etre utilise par deux adherents successivement """
categorie = UnicodeCol()
""" Categorie : club ou adherent """
nom = UnicodeCol()
prenom = UnicodeCol()
titre = StringCol()
""" M, Mmme, Mlle """
naissance = DateCol()
adresse1 = UnicodeCol()
adresse2 = UnicodeCol()
code_postal = StringCol()
ville = UnicodeCol()
pays = UnicodeCol()
telephone = StringCol()
email = StringCol()
etablissement = UnicodeCol()
annee_etudes = UnicodeCol()
filiere = UnicodeCol()
responsable = ForeignKey('Proprio')
fictif = BoolCol()
remarques = UnicodeCol()
#A faire plutot en SQL ?
#def sync(self):
# if not self._SO_createValues:
# return
#for champ in self._SO_createValues.keys():
# diff = '%s -> %s'
# hist = HistProprio(responsable = None, date = datetime.now(), \
# cible = self, champ = champ, \
# valeur = self._SO_createValues[champ])
# SQLObject.sync(self)
class HistProprio(SQLObject):
date = DateTimeCol()
responsable = ForeignKey('Proprio', notNone=False)
cible = ForeignKey('Proprio')
champ = StringCol()
valeur = StringCol()

54
archive/bdd/reset.py Executable file
View file

@ -0,0 +1,54 @@
#!/usr/bin/python
import connection
from proprio import Proprio
from proprio import HistProprio
from comptes import CompteUnix
from comptes import GroupeUnix
from comptes import Attribut
from comptes import Permission
erreurs = 0
try:
Proprio.dropTable(cascade=True)
except:
erreurs += 1
Proprio.createTable()
try:
HistProprio.dropTable(cascade=True)
except:
erreurs += 1
HistProprio.createTable()
try:
CompteUnix.dropTable(cascade=True)
except:
erreurs += 1
CompteUnix.createTable()
try:
GroupeUnix.dropTable(cascade=True)
except:
erreurs += 1
GroupeUnix.createTable()
try:
Attribut.dropTable(cascade=True)
except:
erreurs += 1
Attribut.createTable()
try:
Permission.dropTable(cascade=True)
except:
erreurs += 1
Permission.createTable()
print 'erreurs : ', erreurs

View file

@ -0,0 +1 @@
mdp = 'AspIrAtEUr'

View file

@ -0,0 +1,6 @@
CREATE OR REPLACE VIEW compte_unix_groupe_unix AS SELECT attribut_compte_unix.compte_unix_id, attribut_groupe_unix.groupe_unix_id FROM attribut_compte_unix, attribut_groupe_unix WHERE attribut_compte_unix.attribut_id = attribut_groupe_unix.attribut_id;
SELECT C.uid, G.gid; FROM compte_unix C JOIN attribut_compte_unix AC ON (AC.compte_unix_id = C.id) JOIN attribut A ON (A.id = AC.attribut_id) JOIN attribut_groupe_unix AG ON (AG.attribut_id = A.id) JOIN groupe_unix G ON (G.id = AG.groupe_unix_id) GROUP BY C.uid, G.gid;
CRETAE OR REPLACE VIEW groupmember AS SELECT C.uid, C.username, G.gid
FROM compte_unix C JOIN attribut_compte_unix AC ON (AC.compte_unix_id = C.id) JOIN attribut A ON (A.id = AC.attribut_id) JOIN attribut_groupe_unix AG ON (AG.attribut_id = A.id) JOIN groupe_unix G ON (G.id = AG.groupe_unix_id) GROUP BY C.uid, G.gid, C.username;

6
archive/bdd/temp.py Executable file
View file

@ -0,0 +1,6 @@
#!/usr/bin/python
import hub
from chambre import Chambre
Chambre.createTable()