[dialog/adherent] possibilité de changer les études d'un adhérent
This commit is contained in:
parent
c95859507e
commit
865699e911
3 changed files with 225 additions and 6 deletions
|
@ -46,6 +46,11 @@ class TailCaller(object) :
|
||||||
"""
|
"""
|
||||||
Classe permetant, en décorant des fonctions avec, d'avoir de la tail récursion
|
Classe permetant, en décorant des fonctions avec, d'avoir de la tail récursion
|
||||||
faite "à la main" en python (voir http://kylem.net/programming/tailcall.html)
|
faite "à la main" en python (voir http://kylem.net/programming/tailcall.html)
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
----------
|
||||||
|
f : function
|
||||||
|
Fonction décoré
|
||||||
"""
|
"""
|
||||||
other_callers = {}
|
other_callers = {}
|
||||||
def __init__(self, f) :
|
def __init__(self, f) :
|
||||||
|
@ -193,6 +198,7 @@ class Dialog(object):
|
||||||
# décorée par TailCaller et pas les méthodes statiques de la classe Dialog
|
# décorée par TailCaller et pas les méthodes statiques de la classe Dialog
|
||||||
if getattr(ret, 'tailCaller', False) and not isinstance(ret, TailCaller):
|
if getattr(ret, 'tailCaller', False) and not isinstance(ret, TailCaller):
|
||||||
ret = TailCaller(ret)
|
ret = TailCaller(ret)
|
||||||
|
ret.__doc__ = ret.f.__doc__
|
||||||
setattr(self, attr, ret)
|
setattr(self, attr, ret)
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ class Dialog(proprio.Dialog):
|
||||||
menu = {
|
menu = {
|
||||||
'Administratif' : {'text' : "Adhésion, carte étudiant, chartes", "callback":self.adherent_administratif},
|
'Administratif' : {'text' : "Adhésion, carte étudiant, chartes", "callback":self.adherent_administratif},
|
||||||
'Personnel' : {'text' : "Nom, prénom, téléphone... (ajouter l'age ?)", 'callback':self.adherent_personnel},
|
'Personnel' : {'text' : "Nom, prénom, téléphone... (ajouter l'age ?)", 'callback':self.adherent_personnel},
|
||||||
'Études' : {'text' : "Étude en cours (perso, je pense que c'est à supprimer)", "callback":self.adherent_etudes},
|
'Études' : {'text' : "Étude en cours", "callback":self.adherent_etudes},
|
||||||
'Chambre' : {'text' : 'Déménagement', "callback":self.adherent_chambre},
|
'Chambre' : {'text' : 'Déménagement', "callback":self.adherent_chambre},
|
||||||
'Compte' : {'text' : "Gestion du compte crans", "adherent":"proprio", "callback":self.proprio_compte, 'help':"Création/Suppression/Activation/Désactivation du compte, gestion des alias mails crans du compte"},
|
'Compte' : {'text' : "Gestion du compte crans", "adherent":"proprio", "callback":self.proprio_compte, 'help':"Création/Suppression/Activation/Désactivation du compte, gestion des alias mails crans du compte"},
|
||||||
'GPGFingerprint' : {'text':'Ajouter ou supprimer une empeinte GPG', 'attribut':attributs.gpgFingerprint},
|
'GPGFingerprint' : {'text':'Ajouter ou supprimer une empeinte GPG', 'attribut':attributs.gpgFingerprint},
|
||||||
|
@ -370,11 +370,6 @@ class Dialog(proprio.Dialog):
|
||||||
codes_todo=[([self.dialog.DIALOG_OK], todo, [to_display, non_empty, tags, adherent, separateur, make_compte_crans, force_create, retry_cont, cont])]
|
codes_todo=[([self.dialog.DIALOG_OK], todo, [to_display, non_empty, tags, adherent, separateur, make_compte_crans, force_create, retry_cont, cont])]
|
||||||
)
|
)
|
||||||
|
|
||||||
def adherent_etudes(self, adherent, cont, cancel_cont=None):
|
|
||||||
"""Gestion des études de l'adhérent"""
|
|
||||||
self.dialog.msgbox("todo", width=0, height=0)
|
|
||||||
return cont
|
|
||||||
|
|
||||||
@tailcaller
|
@tailcaller
|
||||||
def adherent_chambre_campus(self, success_cont, cont, adherent, create=False):
|
def adherent_chambre_campus(self, success_cont, cont, adherent, create=False):
|
||||||
"""Permet de faire déménager d'adhérent sur le campus"""
|
"""Permet de faire déménager d'adhérent sur le campus"""
|
||||||
|
@ -660,3 +655,220 @@ class Dialog(proprio.Dialog):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def adherent_etudes(self, adherent, cont, default_item=None, etablissement=None, annee=None, section=None):
|
||||||
|
"""Gestion des études de l'adhérent. etudes est un triplet (établissement, année, section)"""
|
||||||
|
choices_etablissement = [
|
||||||
|
('Autre', ''),
|
||||||
|
('ENS', 'École Normale Supérieure'),
|
||||||
|
('IUT Cachan', ''),
|
||||||
|
('Maximilien Sorre', ''),
|
||||||
|
('Gustave Eiffel', ''),
|
||||||
|
('EFREI', ''),
|
||||||
|
('ESTP', ''),
|
||||||
|
('P1', 'Université Panthéon Sorbonne'),
|
||||||
|
('P2', 'Université Panthéon Assas'),
|
||||||
|
('P3', 'Université de la Sorbonne Nouvelle'),
|
||||||
|
('P4', 'Université Paris Sorbonne'),
|
||||||
|
('P5', 'Université René Descartes'),
|
||||||
|
('P6', 'Université Pierre et Marie Curie'),
|
||||||
|
('P7', 'Université Paris Diderot'),
|
||||||
|
('P8', 'Université Vincennes Saint Denis'),
|
||||||
|
('P9', 'Université Paris Dauphine'),
|
||||||
|
('P10', 'Université de Nanterre'),
|
||||||
|
('P11', 'Université de Paris Sud (Orsay)'),
|
||||||
|
('P12', 'Université Val de Marne (Créteil)'),
|
||||||
|
('P13', 'Université Paris Nord'),
|
||||||
|
('IUFM', ''),
|
||||||
|
('Personnel ENS', "appartement ENS ou personnel CROUS"),
|
||||||
|
]
|
||||||
|
LMD = ['P1', 'P2', 'P3', 'P4', 'P5', 'P6', 'P7', 'P8', 'P9', 'P10', 'P11', 'P12', 'P13']
|
||||||
|
LM = ['EFREI']
|
||||||
|
LYCEE = ['Maximilien Sorre', 'Gustave Eiffel']
|
||||||
|
ANNEE = ['IUT Cachan', 'ESTP']
|
||||||
|
|
||||||
|
def choices(max_annee):
|
||||||
|
c = []
|
||||||
|
if max_annee>=1:
|
||||||
|
c.append(('1', '1ère année'))
|
||||||
|
for i in range(2, max_annee+1):
|
||||||
|
c.append((str(i), "%sème année" % i))
|
||||||
|
return c
|
||||||
|
choices_LMD = [
|
||||||
|
('L1', 'Licence 1ère année'),
|
||||||
|
('L2', 'Licence 2ième année'),
|
||||||
|
('L3', 'Licence 3ième année'),
|
||||||
|
('M1', 'Master 1ère année'),
|
||||||
|
('M2', 'Master 2ième année'),
|
||||||
|
('D1', '1ère année de thèse'),
|
||||||
|
('D2', '2ième année de thèse'),
|
||||||
|
('D3', '3ième année de thèse'),
|
||||||
|
('Autre', ''),
|
||||||
|
]
|
||||||
|
choices_LM = choices_LMD[:5] + choices_LMD[-1:]
|
||||||
|
choices_ENS = [
|
||||||
|
('1', 'Licence'),
|
||||||
|
('2', 'Master 1'),
|
||||||
|
('3', 'Agrégation'),
|
||||||
|
('4', 'Master 2'),
|
||||||
|
('5', '1ère année de thèse'),
|
||||||
|
('6', '2ième année de thèse'),
|
||||||
|
('7', '3ième année de thèse'),
|
||||||
|
('Autre', ''),
|
||||||
|
]
|
||||||
|
section_ENS = [
|
||||||
|
('A0', 'Informatique'),
|
||||||
|
('A1', 'Mathématiques'),
|
||||||
|
('A2', 'Physique fondamentale'),
|
||||||
|
("A'2", 'Physique appliquée'),
|
||||||
|
("A''2", 'Chimie'),
|
||||||
|
('A3', 'Biochimie'),
|
||||||
|
('B1', 'Mécanique'),
|
||||||
|
('B2', 'Génie civil'),
|
||||||
|
('B3', 'Génie mécanique'),
|
||||||
|
('B4', 'Génie électrique'),
|
||||||
|
('C', 'Art et création industrielle'),
|
||||||
|
('D2', 'Economie gestion'),
|
||||||
|
('D3', 'Sciences sociales'),
|
||||||
|
('E', 'Anglais'),
|
||||||
|
('Autre', ''),
|
||||||
|
]
|
||||||
|
choices_LYCEE = [
|
||||||
|
('Seconde',''),
|
||||||
|
('Première',''),
|
||||||
|
('Terminale',''),
|
||||||
|
('1/2', '1ère année de prépa'),
|
||||||
|
('3/2', '2nd année de prépa'),
|
||||||
|
('5/2', '3ième année de prépa'),
|
||||||
|
('Autre',''),
|
||||||
|
]
|
||||||
|
|
||||||
|
def box_etablissement(default_item):
|
||||||
|
if etablissement == 'Autre' or \
|
||||||
|
(etablissement is not None and etablissement not in [i[0] for i in choices_etablissement]) or \
|
||||||
|
(default_item is not None and default_item not in [i[0] for i in choices_etablissement]):
|
||||||
|
return self.dialog.inputbox(
|
||||||
|
text="Choisissez l'établissement :",
|
||||||
|
title="Études de %s %s" % (adherent['prenom'][0], adherent["nom"][0]),
|
||||||
|
timeout=self.timeout,
|
||||||
|
init=str(default_item) if default_item else "")
|
||||||
|
else:
|
||||||
|
return self.dialog.menu(
|
||||||
|
"Choisissez l'établissement :",
|
||||||
|
width=0,
|
||||||
|
height=0,
|
||||||
|
menu_height=0,
|
||||||
|
timeout=self.timeout,
|
||||||
|
item_help=0,
|
||||||
|
default_item=str(default_item) if default_item else 'ENS',
|
||||||
|
title="Études de %s %s" % (adherent['prenom'][0], adherent["nom"][0]),
|
||||||
|
scrollbar=True,
|
||||||
|
cancel_label="Retour",
|
||||||
|
backtitle=u"Vous êtes connecté en tant que %s" % self.conn.current_login,
|
||||||
|
choices=choices_etablissement)
|
||||||
|
|
||||||
|
def box_annee(default_item):
|
||||||
|
if etablissement in LMD:
|
||||||
|
box_choice = choices_LMD
|
||||||
|
elif etablissement in LM:
|
||||||
|
box_choice = choices_LM
|
||||||
|
elif etablissement in LYCEE:
|
||||||
|
box_choice = choices_LYCEE
|
||||||
|
elif etablissement == 'ENS':
|
||||||
|
box_choice = choices_ENS
|
||||||
|
else:
|
||||||
|
box_choice = choices(7)
|
||||||
|
if not box_choice or annee == 'Autre' or \
|
||||||
|
(annee is not None and annee not in [i[0] for i in box_choice]) or \
|
||||||
|
(default_item is not None and default_item not in [i[0] for i in box_choice]):
|
||||||
|
return self.dialog.inputbox(
|
||||||
|
text="Choisissez l'année administrative :",
|
||||||
|
title="Études de %s %s" % (adherent['prenom'][0], adherent["nom"][0]),
|
||||||
|
timeout=self.timeout,
|
||||||
|
init=str(default_item) if default_item else "")
|
||||||
|
else:
|
||||||
|
return self.dialog.menu(
|
||||||
|
"Choisissez l'année administrative :",
|
||||||
|
width=0,
|
||||||
|
height=0,
|
||||||
|
menu_height=0,
|
||||||
|
timeout=self.timeout,
|
||||||
|
item_help=0,
|
||||||
|
default_item=str(default_item),
|
||||||
|
title="Études de %s %s" % (adherent['prenom'][0], adherent["nom"][0]),
|
||||||
|
scrollbar=True,
|
||||||
|
cancel_label="Retour",
|
||||||
|
backtitle=u"Vous êtes connecté en tant que %s" % self.conn.current_login,
|
||||||
|
choices=box_choice)
|
||||||
|
|
||||||
|
def box_section(default_item):
|
||||||
|
if etablissement != 'ENS' or section == 'Autre' or \
|
||||||
|
(section and section not in [i[0] for i in section_ENS]) or \
|
||||||
|
(default_item is not None and default_item not in [i[0] for i in section_ENS]):
|
||||||
|
return self.dialog.inputbox(
|
||||||
|
text="Choisissez la section :",
|
||||||
|
title="Études de %s %s" % (adherent['prenom'][0], adherent["nom"][0]),
|
||||||
|
timeout=self.timeout,
|
||||||
|
init=str(default_item) if default_item else "")
|
||||||
|
else:
|
||||||
|
return self.dialog.menu(
|
||||||
|
"Choisissez la section :",
|
||||||
|
width=0,
|
||||||
|
height=0,
|
||||||
|
menu_height=0,
|
||||||
|
timeout=self.timeout,
|
||||||
|
item_help=0,
|
||||||
|
default_item=str(default_item),
|
||||||
|
title="Études de %s %s" % (adherent['prenom'][0], adherent["nom"][0]),
|
||||||
|
scrollbar=True,
|
||||||
|
cancel_label="Retour",
|
||||||
|
backtitle=u"Vous êtes connecté en tant que %s" % self.conn.current_login,
|
||||||
|
choices=section_ENS)
|
||||||
|
|
||||||
|
self_cont = TailCall(self.adherent_etudes, adherent=adherent, cont=cont, default_item=default_item, etablissement=etablissement, annee=annee, section=section)
|
||||||
|
if etablissement is None or etablissement == 'Autre':
|
||||||
|
if not default_item and adherent["etudes"]:
|
||||||
|
default_item = str(adherent["etudes"][0])
|
||||||
|
cancel_cont = cont
|
||||||
|
(code, etablissement) = self.handle_dialog(cancel_cont, box_etablissement, default_item)
|
||||||
|
output = etablissement
|
||||||
|
self_cont(default_item=etablissement)
|
||||||
|
elif annee is None or annee == 'Autre':
|
||||||
|
if not default_item and adherent["etudes"]:
|
||||||
|
default_item = str(adherent["etudes"][1])
|
||||||
|
print default_item
|
||||||
|
cancel_cont = TailCall(self.adherent_etudes, adherent=adherent, cont=cont, default_item=etablissement, etablissement=None, annee=None, section=None)
|
||||||
|
(code , annee) = self.handle_dialog(cancel_cont, box_annee, default_item)
|
||||||
|
output = annee
|
||||||
|
self_cont(default_item=annee)
|
||||||
|
elif section is None or section == 'Autre':
|
||||||
|
if not default_item and adherent["etudes"]:
|
||||||
|
default_item = str(adherent["etudes"][2])
|
||||||
|
cancel_cont = TailCall(self.adherent_etudes, adherent=adherent, cont=cont, default_item=annee, etablissement=etablissement, annee=None, section=None)
|
||||||
|
(code, section) = self.handle_dialog(cancel_cont, box_section, default_item)
|
||||||
|
output = section
|
||||||
|
self_cont(default_item=section)
|
||||||
|
else:
|
||||||
|
output = ""
|
||||||
|
cancel_cont = TailCall(self.adherent_etudes, adherent=adherent, cont=cont, default_item=section, etablissement=etablissement, annee=annee, section=None)
|
||||||
|
|
||||||
|
def todo(etablissement, annee, section, adherent, self_cont, cont):
|
||||||
|
if etablissement is None or etablissement == 'Autre':
|
||||||
|
raise Continue(self_cont(default_item=None, etablissement=etablissement))
|
||||||
|
elif annee is None or annee == 'Autre':
|
||||||
|
raise Continue(self_cont(default_item=None, etablissement=etablissement, annee=annee))
|
||||||
|
elif section is None or section == 'Autre':
|
||||||
|
raise Continue(self_cont(default_item=None, etablissement=etablissement, annee=annee, section=section))
|
||||||
|
else:
|
||||||
|
if not adherent["etudes"] or adherent["etudes"][0] != etablissement or adherent["etudes"][1] != annee or adherent["etudes"][2] != section:
|
||||||
|
with self.conn.search(dn=adherent.dn, scope=0, mode='rw')[0] as adherent:
|
||||||
|
adherent["etudes"]=[unicode(etablissement), unicode(annee), unicode(section)]
|
||||||
|
adherent.history_gen()
|
||||||
|
adherent.save()
|
||||||
|
raise Continue(cont(adherent=adherent))
|
||||||
|
return self.handle_dialog_result(
|
||||||
|
code=code,
|
||||||
|
output=output,
|
||||||
|
cancel_cont=cancel_cont,
|
||||||
|
error_cont=self_cont,
|
||||||
|
codes_todo=[([self.dialog.DIALOG_OK], todo, [etablissement, annee, section, adherent, self_cont, cont])]
|
||||||
|
)
|
||||||
|
|
|
@ -9,6 +9,7 @@ Licence : GPLv3
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
import ldap
|
import ldap
|
||||||
|
import traceback
|
||||||
if '/usr/scripts' not in sys.path:
|
if '/usr/scripts' not in sys.path:
|
||||||
sys.path.append('/usr/scripts')
|
sys.path.append('/usr/scripts')
|
||||||
from pythondialog import Dialog
|
from pythondialog import Dialog
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue