Commit d26e8838 authored by Gabriel Detraz's avatar Gabriel Detraz

Le popu ne rempli plus que l'établissement (drop année et filière)

parent 3419ff29
......@@ -578,7 +578,7 @@ class Dialog(proprio.Dialog):
)
def adherent_etudes(self, adherent, cont, cancel_cont=None, default_item=None, etablissement=None, annee=None, section=None):
def adherent_etudes(self, adherent, cont, cancel_cont=None, default_item=None, etablissement=None):
"""Gestion des études de l'adhérent. etudes est un triplet (établissement, année, section)"""
choices_etablissement = [
('Autre', ''),
......@@ -609,63 +609,6 @@ class Dialog(proprio.Dialog):
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))
c.append(('Autre', ''))
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'),
('S', 'Saphire'),
('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 \
......@@ -691,65 +634,7 @@ class Dialog(proprio.Dialog):
backtitle=self._connected_as(),
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=self._connected_as(),
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=self._connected_as(),
choices=section_ENS)
self_cont = TailCall(self.adherent_etudes, adherent=adherent, cont=cont, cancel_cont=cancel_cont, default_item=default_item, etablissement=etablissement, annee=annee, section=section)
self_cont = TailCall(self.adherent_etudes, adherent=adherent, cont=cont, cancel_cont=cancel_cont, default_item=default_item, etablissement=etablissement)
if etablissement is None or etablissement == 'Autre':
if not default_item and adherent["etudes"]:
default_item = str(adherent["etudes"][0])
......@@ -757,36 +642,17 @@ class Dialog(proprio.Dialog):
(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
lcont = TailCall(self.adherent_etudes, adherent=adherent, cont=cont, cancel_cont=cancel_cont, default_item=etablissement, etablissement=None, annee=None, section=None)
(code , annee) = self.handle_dialog(lcont, 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])
lcont = TailCall(self.adherent_etudes, adherent=adherent, cont=cont, cancel_cont=cancel_cont, default_item=annee, etablissement=etablissement, annee=None, section=None)
(code, section) = self.handle_dialog(lcont, box_section, default_item)
output = section
self_cont(default_item=section)
else:
output = ""
lcont = TailCall(self.adherent_etudes, adherent=adherent, cont=cont, cancel_cont=cancel_cont, default_item=section, etablissement=etablissement, annee=annee, section=None)
lcont = TailCall(self.adherent_etudes, adherent=adherent, cont=cont, cancel_cont=cancel_cont, default_item=section, etablissement=etablissement)
def todo(etablissement, annee, section, adherent, self_cont, cont):
def todo(etablissement, 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:
if not adherent["etudes"] or adherent["etudes"][0] != etablissement:
with self.conn.search(dn=adherent.dn, scope=0, mode='rw')[0] as adherent:
adherent["etudes"] = [unicode(etablissement), unicode(annee), unicode(section)]
adherent["etudes"] = unicode(etablissement)
adherent.validate_changes()
adherent.history_gen()
adherent.save()
......@@ -796,5 +662,5 @@ class Dialog(proprio.Dialog):
output=output,
cancel_cont=lcont,
error_cont=self_cont,
codes_todo=[([self.dialog.DIALOG_OK], todo, [etablissement, annee, section, adherent, self_cont, cont])]
codes_todo=[([self.dialog.DIALOG_OK], todo, [etablissement, adherent, self_cont, cont])]
)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment