From 84f99bf6ea2c0dbef155e1049555f9b212ef95c5 Mon Sep 17 00:00:00 2001 From: Jeremie Dimino Date: Mon, 8 Sep 2008 23:58:27 +0200 Subject: [PATCH] modif de gest_crans pour les inscriptions gratuites darcs-hash:20080908215827-af139-d647a87d700c60ffb04463f1abf588176479fe3b.gz --- gestion/gest_crans.py | 110 +++++++++++++++++++++++++++--------------- 1 file changed, 71 insertions(+), 39 deletions(-) diff --git a/gestion/gest_crans.py b/gestion/gest_crans.py index 5dc61c35..0929073c 100755 --- a/gestion/gest_crans.py +++ b/gestion/gest_crans.py @@ -22,6 +22,7 @@ Retournent None si pas d'objet trouv To = ['fred@crans.org', 'glondu@crans.org', 'bos@crans.org', 'dimino@crans.org', 'salles@crans.org', 'cohen@crans.org'] import string, os, sys +import dialog from whos import aff import signal, getopt from time import strftime, strptime, localtime, mktime @@ -37,6 +38,8 @@ import user_tests isadm = user_tests.isadm() isdeconnecteur = user_tests.isdeconnecteur() +dlg = dialog.Dialog() + def dialog(arg): return affich_tools.dialog(u'Gestion des adhérents et machines du Crans', arg) @@ -357,6 +360,10 @@ def set_mail(adher): dialog(arg) return + if not isinstance(adher, Club) and not adher.adherentPayant(): + set_mail_ext(adher) + return + while 1: arg = u'--title "Adresse mail de %s" ' % adher.Nom() arg += u'--menu "Adresse mail de l\'adhérent :" 0 0 0 ' @@ -935,6 +942,18 @@ def on_off(condition): else: return 'off' +def set_type_de_connexion(adherent): + """ + Définition du type de connexion: gratuite limité ou normale. + """ + if isinstance(adherent, Club): return + + annul, result = dlg.menu(u"Type de connexion", + choices=[("1", u"Connexion normale"), + ("2", u"Connexion gratuite")]) + if annul: return 1 + adherent.adherentPayant(result == "1") + def set_admin(proprio): """ Définition de l'état administratif : carte d'étudiant, paiement @@ -962,12 +981,15 @@ def set_admin(proprio): (ann_scol, ann_scol+1, carte)) else: texte.append(u'Carte vérifiée') - - if paiement_ok == 'off' or iscontroleur: - checklist.append(u'"2" "Cotisation %d/%d réglée et charte signée" "%s"' % - (ann_scol, ann_scol+1, paiement)) + + if isinstance(proprio, Club) or proprio.adherentPayant(): + if paiement_ok == 'off' or iscontroleur: + checklist.append(u'"2" "Cotisation %d/%d réglée et charte signée" "%s"' % + (ann_scol, ann_scol+1, paiement)) + else: + texte.append(u'Cotisation/charte vérifiées') else: - texte.append(u'Cotisation/charte vérifiées') + texte.append(u'Adhérent non payant') # TODO: controle pour le précâblage if config.precab: @@ -1422,26 +1444,22 @@ def new_adher(adher): * set_rque Retourne 1 si annulation. """ - step = 1 - while 1: - if step == 1: - if set_bases(adher): return 1 + + while True: + if set_bases(adher): return 1 + + steps = [set_etudes, + set_type_de_connexion, + set_admin, + set_mail, + set_rque] + + step = 0 + while step < len(steps): + if steps[step](adher): step -= 1 else: step += 1 - if step == 2: - if set_etudes(adher): step -= 1 - else: step += 1 - if step == 3: - if set_admin(adher): step -= 1 - else: step += 1 - if step == 4: - if set_mail(adher): step -= 1 - else: step += 1 - if step == 5: - if set_rque(adher): step -= 1 - else: step += 1 - if step == 6: - if confirm(adher): step = 1 - else: break + + if not confirm(adher): break arg = u'--title "Inscription Mailing liste de communication ENS" --yesno "\nInscrire l\'adhérent à la mailing liste de communication de l\'ENS ?\n\n\n" 0 0' no, res = dialog(arg) @@ -1462,9 +1480,13 @@ def modif_adher(adher): arg += u'--msgbox "ERREUR : la chambre de cet adhérent est inconnue !\n\n\n" 0 0' dialog(arg) else: + payant = not isinstance(adher, Club) and not adher.adherentPayant() + arg = u'--title "Modification de %s" ' % adher.Nom() arg += u'--menu "Que souhaitez vous modifier ?" 0 0 0 ' arg += u'"Administratif" "Précâblage, carte d\'étudiant, études" ' + if not payant: + arg += u'"Connexion" "Changer de type de connexion(gratuit->payant)" ' if adher.compte(): changement_compte = u", compte sur zamok" else: changement_compte = u"" arg += u'"État-civil" "Nom, prénom%s" ' % changement_compte @@ -1474,20 +1496,21 @@ def modif_adher(adher): arg += u'"Chambre" "Déménagement" ' arg += u'"Etudes" "Changement d\'année ou de filière" ' arg += u'"Téléphone" "Changement de numéro de téléphone" ' - arg += u'"Mail" "Créer un compte ou changer l\'adresse mail de contact" ' - arg += u'"Alias" "Créer ou supprimer un alias mail" ' - arg += u'"Remarque" "Ajouter ou modifer un commentaire" ' - if isadm: - if 'cransAccount' in adher._data['objectClass']: + if payant: + arg += u'"Mail" "Créer un compte ou changer l\'adresse mail de contact" ' + arg += u'"Alias" "Créer ou supprimer un alias mail" ' + arg += u'"Remarque" "Ajouter ou modifer un commentaire" ' + if isadm: + if 'cransAccount' in adher._data['objectClass']: + arg += u'"Droits" "Modifier les droits alloués à cet adhérent" ' + if 'posixAccount' in adher._data['objectClass']: + arg += u'"Shell" "Changer le shell de cet utilisateur" ' + if isbureau and 'Nounou' not in adher.droits(): arg += u'"Droits" "Modifier les droits alloués à cet adhérent" ' - if 'posixAccount' in adher._data['objectClass']: - arg += u'"Shell" "Changer le shell de cet utilisateur" ' - if isbureau and 'Nounou' not in adher.droits(): - arg += u'"Droits" "Modifier les droits alloués à cet adhérent" ' - if isdeconnecteur: - arg += u'"Blackliste" "Modifier la blackliste de cet adhérent" ' - if isimprimeur: - arg += u'"Solde" "Effectuer un débit/crédit pour cet adhérent" ' + if isdeconnecteur: + arg += u'"Blackliste" "Modifier la blackliste de cet adhérent" ' + if isimprimeur: + arg += u'"Solde" "Effectuer un débit/crédit pour cet adhérent" ' annul, res = dialog(arg) @@ -1510,6 +1533,8 @@ def modif_adher(adher): set_blackliste(adher) elif res[0] == 'Charte des MA' : set_charte_MA(adher) + elif res[0] == 'Connexion': + adher.adherentPayant(dlg.yesno(u"Passer à un compte payant ?") == 0) elif res[0] == 'Adresse' or res[0] == 'Chambre': arg = u'--title "Déménagement de %s" ' % adher.Nom() arg += u'--menu "Question :" 0 0 0 ' @@ -1982,8 +2007,15 @@ def menu_principal(): # déjà une machine fixe, sauf si on est membre actif # (expérimental) - # On récupère la liste des machines fixes - if proprio.__class__ == Club or not proprio.machines_fixes() or proprio.droits(): + if not isinstance(proprio, Club) and not proprio.adherentPayant(): + # Les gens qui ne paient pas n'ont le droit qu'à une + # seule machine fixe + if proprio.machines_fixes(): + dlg.msgbox(u"Le type de compte de cet adhérent ne lui permet pas d'avoir de machine suplémentaire") + continue + else: + choix = "Fixe" + elif isinstance(proprio, Club) or not proprio.machines_fixes() or proprio.droits(): arg = u'--title "Nouvelle machine" ' arg += u'--menu "Type de machine ?" 0 0 0 ' arg += u'"Fixe" "Machine fixe" '