def RegenererMdp(self, event): if "********" in self.ctrl_mdp.GetValue(): dlg = wx.MessageDialog( self, _(u"Attention, ce mot de passe a déjà été personnalisé par l'usager ! \n\nSouhaitez-vous vraiment modifier ce mot de passe ?" ), _(u"Avertissement"), wx.YES_NO | wx.NO_DEFAULT | wx.CANCEL | wx.ICON_EXCLAMATION) reponse = dlg.ShowModal() dlg.Destroy() if reponse != wx.ID_YES: return False dlg = wx.MessageDialog( self, _(u"Vous êtes vraiment sûr de vouloir générer un nouveau mot de passe ?" ), _(u"Avertissement"), wx.YES_NO | wx.NO_DEFAULT | wx.CANCEL | wx.ICON_EXCLAMATION) reponse = dlg.ShowModal() dlg.Destroy() if reponse != wx.ID_YES: return False taille = UTILS_Parametres.Parametres(mode="get", categorie="comptes_internet", nom="taille_passwords", valeur=8) internet_mdp = UTILS_Internet.CreationMDP(nbreCaract=taille, cryptage=False) self.ctrl_mdp.SetValue(internet_mdp)
def CreateIDfamille(DB, parametres=None): """ Crée la fiche famille dans la base de données afin d'obtenir un IDfamille et un IDcompte_payeur """ from Utils import UTILS_Internet date_creation = str(datetime.date.today()) IDfamille = DB.ReqInsert("familles", [ ("date_creation", date_creation), ]) # Création du compte payeur IDcompte_payeur = DB.ReqInsert("comptes_payeurs", [ ("IDfamille", IDfamille), ]) # Création des codes internet try: internet_identifiant = parametres['identifiant'] except: internet_identifiant = UTILS_Internet.CreationIdentifiant( IDfamille=IDfamille) try: internet_mdp = parametres['password1'] except: taille = UTILS_Parametres.Parametres(mode="get", categorie="comptes_internet", nom="taille_passwords", valeur=8) internet_mdp = UTILS_Internet.CreationMDP(nbreCaract=taille) # Sauvegarde des données listeDonnees = [ ("IDcompte_payeur", IDcompte_payeur), ("internet_actif", 1), ("internet_identifiant", internet_identifiant), ("internet_mdp", internet_mdp), ] print listeDonnees DB.ReqMAJ("familles", listeDonnees, "IDfamille", IDfamille) return IDfamille
def ReinitPasswords(self, event=None): """ Régénération des mots de passe """ listeCoches = self.GetTracksCoches() if len(listeCoches) == 0 : dlg = wx.MessageDialog(self, _(u"Vous n'avez coché aucun compte internet à réinitialiser !"), _(u"Erreur"), wx.OK | wx.ICON_EXCLAMATION) dlg.ShowModal() dlg.Destroy() return # Demandes de confirmation dlg = wx.MessageDialog(self, _(u"Souhaitez-vous vraiment réinitialiser les mots de passe des %d comptes sélectionnés ?") % len(listeCoches), _(u"Modification"), wx.YES_NO|wx.NO_DEFAULT|wx.CANCEL|wx.ICON_QUESTION) reponse = dlg.ShowModal() dlg.Destroy() if reponse != wx.ID_YES : return dlg = wx.MessageDialog(self, _(u"ATTENTION, TOUS LES MOTS DE PASSE SERONT REINITIALISES !\n\nSouhaitez-vous vraiment regénérer les mots de passe des %d comptes sélectionnés ?") % len(listeCoches), _(u"Avertissement"), wx.YES_NO|wx.NO_DEFAULT|wx.CANCEL|wx.ICON_EXCLAMATION) reponse = dlg.ShowModal() dlg.Destroy() if reponse != wx.ID_YES : return # Récupère la taille des mots de passe taille = UTILS_Parametres.Parametres(mode="get", categorie="comptes_internet", nom="taille_passwords", valeur=8) dlg = wx.MessageDialog(self, _(u"Les mots de passe comporteront %d caractères.\n\nSi cela vous convient, cliquez sur Oui, sinon annulez et allez dans Menu Paramétrage > Préférences pour modifier la taille des mots de passe des comptes internet.") % taille, _(u"Avertissement"), wx.YES_NO|wx.NO_DEFAULT|wx.CANCEL|wx.ICON_QUESTION) reponse = dlg.ShowModal() dlg.Destroy() if reponse != wx.ID_YES : return dlg = wx.MessageDialog(self, _(u"DERNIER AVERTISSEMENT !\n\nConfirmez-vous la réinitialisation des mots de passe ? Vous ne pourrez pas revenir en arrière..."), _(u"Avertissement"), wx.YES_NO|wx.NO_DEFAULT|wx.CANCEL|wx.ICON_EXCLAMATION) reponse = dlg.ShowModal() dlg.Destroy() if reponse != wx.ID_YES : return # Regénération des mots de passe listeModifications = [] for track in listeCoches : mdp = UTILS_Internet.CreationMDP(nbreCaract=taille) listeModifications.append((mdp, track.IDfamille)) DB = GestionDB.DB() DB.Executermany("UPDATE familles SET internet_mdp=? WHERE IDfamille=?", listeModifications, commit=False) DB.Commit() DB.Close() self.MAJ()
def OnBoutonMdpRenew(self, event): dlg = wx.MessageDialog( self, _(u"Souhaitez-vous vraiment générer un nouveau mot de passe pour ce compte internet ? \n\nAttention, l'ancien mot de passe sera remplacé." ), _(u"Avertissement"), wx.YES_NO | wx.NO_DEFAULT | wx.CANCEL | wx.ICON_EXCLAMATION) reponse = dlg.ShowModal() dlg.Destroy() if reponse != wx.ID_YES: return from Utils import UTILS_Internet taille = UTILS_Parametres.Parametres(mode="get", categorie="comptes_internet", nom="taille_passwords", valeur=7) self.ctrl_mdp.SetValue(UTILS_Internet.CreationMDP(nbreCaract=taille)) self.MAJaffichage()
def CreateIDfamille(DB): """ Crée la fiche famille dans la base de données afin d'obtenir un IDfamille et un IDcompte_payeur """ from Utils import UTILS_Internet date_creation = str(datetime.date.today()) IDfamille = DB.ReqInsert("familles", [ ("date_creation", date_creation), ]) # Création du compte payeur IDcompte_payeur = DB.ReqInsert("comptes_payeurs", [ ("IDfamille", IDfamille), ]) # Création des codes internet internet_identifiant = UTILS_Internet.CreationIdentifiant( IDfamille=IDfamille) internet_mdp = UTILS_Internet.CreationMDP() # Sauvegarde des données listeDonnees = [ ("IDcompte_payeur", IDcompte_payeur), ("internet_actif", 1), ("internet_identifiant", internet_identifiant), ("internet_mdp", internet_mdp), ] DB.ReqMAJ("familles", listeDonnees, "IDfamille", IDfamille) return IDfamille
def __init__(self, parent, IDutilisateur=None): wx.Dialog.__init__(self, parent, -1, style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER|wx.MAXIMIZE_BOX|wx.MINIMIZE_BOX) self.parent = parent self.IDutilisateur = IDutilisateur self.mdp = None self.mdpcrypt = None if IDutilisateur == None : DB = GestionDB.DB() IDutilisateur = DB.GetProchainID("utilisateurs") DB.Close() # Identité self.staticbox_identite_staticbox = wx.StaticBox(self, -1, _(u"Identité")) self.label_sexe = wx.StaticText(self, -1, _(u"Sexe :")) self.ctrl_sexe = wx.Choice(self, -1, choices=[_(u"Homme"), _(u"Femme")]) self.label_nom = wx.StaticText(self, -1, _(u"Nom :")) self.ctrl_nom = wx.TextCtrl(self, -1, u"") self.label_prenom = wx.StaticText(self, -1, _(u"Prénom :")) self.ctrl_prenom = wx.TextCtrl(self, -1, u"") # Image self.staticbox_image_staticbox = wx.StaticBox(self, -1, _(u"Avatar")) self.ctrl_image = CTRL_Image(self) self.hyper_image = Hyperlien(self, label=_(u"Choisir un avatar"), infobulle=_(u"Cliquez ici pour modifier l'avatar de l'utilisateur"), URL="") # Accès self.staticbox_acces_staticbox = wx.StaticBox(self, -1, _(u"Accès")) self.ctrl_actif = wx.CheckBox(self, -1, u"Utilisateur actif") self.ctrl_actif.SetValue(True) self.bouton_modif_mdp = CTRL_Bouton_image.CTRL(self, texte="", cheminImage="Images/32x32/Cle.png") # Compte internet self.staticbox_internet_staticbox = wx.StaticBox(self, -1, _(u"Compte internet")) self.ctrl_compte_internet = CTRL_Compte_internet.CTRL(self, IDutilisateur=IDutilisateur, couleurFond=wx.WHITE) self.bouton_modifier = wx.BitmapButton(self, -1, wx.Bitmap(Chemins.GetStaticPath(u"Images/16x16/Modifier.png"), wx.BITMAP_TYPE_ANY)) #self.bouton_envoi_mail = wx.BitmapButton(self, -1, wx.Bitmap(Chemins.GetStaticPath(u"Images/16x16/Emails_exp.png"), wx.BITMAP_TYPE_ANY)) self.bouton_envoi_pressepapiers = wx.BitmapButton(self, -1, wx.Bitmap(Chemins.GetStaticPath(u"Images/16x16/Clipboard.png"), wx.BITMAP_TYPE_ANY)) #self.bouton_historique = wx.BitmapButton(self, -1, wx.Bitmap(Chemins.GetStaticPath(u"Images/16x16/Historique.png"), wx.BITMAP_TYPE_ANY)) # Droits self.staticbox_droits_staticbox = wx.StaticBox(self, -1, _(u"Droits")) self.radio_droits_admin = wx.RadioButton(self, -1, _(u"Administrateur"), style=wx.RB_GROUP) self.radio_droits_modele = wx.RadioButton(self, -1, _(u"Le modèle de droits suivant :")) self.ctrl_modele_droits = CTRL_Modeles_droits(self) self.radio_droits_perso = wx.RadioButton(self, -1, _(u"Les droits personnalisés suivants :")) self.ctrl_droits = CTRL_Droits.CTRL(self, IDutilisateur=self.IDutilisateur) self.ctrl_droits.MAJ() # Commandes self.bouton_aide = CTRL_Bouton_image.CTRL(self, texte=_(u"Aide"), cheminImage="Images/32x32/Aide.png") self.bouton_ok = CTRL_Bouton_image.CTRL(self, texte=_(u"Ok"), cheminImage="Images/32x32/Valider.png") self.bouton_annuler = CTRL_Bouton_image.CTRL(self, id=wx.ID_CANCEL, texte=_(u"Annuler"), cheminImage="Images/32x32/Annuler.png") self.__set_properties() self.__do_layout() self.Bind(wx.EVT_BUTTON, self.OnBoutonModifMdp, self.bouton_modif_mdp) self.Bind(wx.EVT_BUTTON, self.OnBoutonAide, self.bouton_aide) self.Bind(wx.EVT_BUTTON, self.OnBoutonOk, self.bouton_ok) self.Bind(wx.EVT_RADIOBUTTON, self.OnRadioDroits, self.radio_droits_admin) self.Bind(wx.EVT_RADIOBUTTON, self.OnRadioDroits, self.radio_droits_modele) self.Bind(wx.EVT_RADIOBUTTON, self.OnRadioDroits, self.radio_droits_perso) self.Bind(wx.EVT_BUTTON, self.ctrl_compte_internet.Modifier, self.bouton_modifier) #self.Bind(wx.EVT_BUTTON, self.Envoyer_email, self.bouton_envoi_mail) self.Bind(wx.EVT_BUTTON, self.ctrl_compte_internet.Envoyer_pressepapiers, self.bouton_envoi_pressepapiers) #self.Bind(wx.EVT_BUTTON, self.Consulter_historique, self.bouton_historique) if self.IDutilisateur == None : self.SetTitle(_(u"Saisie d'un utilisateur")) # Création des codes internet internet_identifiant = UTILS_Internet.CreationIdentifiant(IDutilisateur=IDutilisateur) internet_mdp = UTILS_Internet.CreationMDP(nbreCaract=8) self.ctrl_compte_internet.SetDonnees({"internet_actif": 0, "internet_identifiant": internet_identifiant, "internet_mdp": internet_mdp}) else: self.SetTitle(_(u"Modification d'un utilisateur")) self.Importation() self.OnRadioDroits(None) self.MAJboutonMdp()