예제 #1
0
def get_field_account(form, user):
    user.codeUser = form.Code.data
    user.nomUser = FormatString(form.Nom.data).capitalize()
    user.prenomUser = FormatString(form.Prenom.data).capitalize()
    user.cinUser = form.Cin.data
    user.dateUser = form.Date.data
    user.emailUser = form.Email.data
    user.telUser = form.Tel.data
    user.idStation = form.Station.data
    user.etatCompte = str(form.Etat.data)
예제 #2
0
파일: utils.py 프로젝트: AhmedWanneni/PFE
def verifDate(Date):
    import datetime
    try:
        isValid = True
        inputDate = FormatString(Date)
        year, month, day = inputDate.split('-')
        datetime.datetime(int(year), int(month), int(day))
    except ValueError:
        isValid = False

    return isValid
예제 #3
0
파일: form.py 프로젝트: AhmedWanneni/PFE
    def validate_Email(self,field):
        if re.match(r'^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$', field.data) is None:
            raise ValidationError('Email invalide! Veuillez en choisir un autre.')

        Gp = User.query.filter_by(emailUser=FormatString(field.data)).first()
        if Gp:
            raise ValidationError('L\'email existe déjà! Veuillez en choisir un autre.')
예제 #4
0
파일: routes.py 프로젝트: sadekmehri/Agil
def forget():
    if current_user.is_authenticated:
        return redirect(url_for('main.login'))
    form = ForgetForm()
    if form.validate_on_submit():
        cin = FormatString(form.Cin.data)
        user = User.query.filter(User.emailUser == cin).first()
        if user:
            if not days_between(user.expiryCompte) or user.nbrAttempts < 1:
                try:
                    user.etatCompte = 0
                    user.nbrAttempts = 0
                    db.session.commit()
                except SQLAlchemyError:
                    db.session.rollback()
                    flash("Erreur inconnue due au serveur", 'error')
            try:
                token = ts.dumps(FormatString(form.Cin.data),
                                 salt="2Po[=}L=uP9[1Vb-cod2Wo}s#Rp:94Zh^O8")
                user.resetTokenUser = token
                if user.roleUser == 0:
                    if user.nbrAttempts < 1 or user.etatCompte < 1:
                        flash(
                            'Votre compte est verrouillé. Veuillez contacter l\'administrateur!',
                            'error')
                        return redirect(url_for('approot.login'))
                flash(
                    'Vérifiez votre boîte aux lettres pour réinitialiser votre mot de passe',
                    'success')
                db.session.commit()
                send_reset_email(user)
            except SQLAlchemyError:
                flash("Erreur inconnue due au serveur", 'error')
                db.session.rollback()
            else:
                return redirect(url_for('approot.login'))

        else:
            flash("Veuillez vérifier vos informations d'identification",
                  'error')
            return redirect(url_for('approot.forget'))

    return render_template('./main/forget/forget.html',
                           title='Forget Password',
                           form=form)
예제 #5
0
파일: form.py 프로젝트: AhmedWanneni/PFE
 def validate_Code(form, field):
     validation(field.data)
     Gp = Employee.query.filter(or_(Employee.codeEmp == FormatString(field.data), Employee.cinEmp == FormatString(field.data)),Employee.idStation == current_user.idStation).first()
     if not Gp:
         raise ValidationError('L\'employé n\'existe pas! Veuillez saisir un autre code.')
     Ab = Absence.query.join(Employee, Employee.idEmp == Absence.idEmp) \
         .join(Station, Station.idStation == Employee.idStation) \
         .filter(Employee.idStation == current_user.idStation, Absence.idStation == current_user.idStation, Employee.idEmp == Gp.idEmp,Absence.DateAbsence == FormatString(form.Date.data)).first()
     if Ab:
         raise ValidationError("Vous avez ajouté cet employé à la liste.")
예제 #6
0
파일: form.py 프로젝트: AhmedWanneni/PFE
 def validate_Code(form, field):
     validation(field.data)
     Gp = Employee.query.filter(or_(Employee.codeEmp == FormatString(field.data), Employee.cinEmp == FormatString(field.data)),Employee.idStation == current_user.idStation).first()
     if not Gp:
         raise ValidationError('L\'employé n\'existe pas! Veuillez saisir un autre code.')
     Gp = Conge.query.join(Employee, Employee.idEmp == Conge.idEmp) \
         .join(Station, Station.idStation == Employee.idStation) \
         .filter(or_(Employee.codeEmp == FormatString(field.data), Employee.cinEmp == FormatString(field.data)),Employee.idStation == current_user.idStation) \
         .filter(Conge.idStation == current_user.idStation,Conge.DateDebConge >= FormatString(form.DatDeb.data)).all()
     Test = True
     for record in Gp:
         if ((days_calc(record.DateDebConge, FormatString(form.DatDeb.data)) >= 0 and days_calc(FormatString(form.DatFin.data), record.DateFinConge) >= 0 )
             or (not((days_calc(FormatString(form.DatDeb.data),record.DateDebConge) > 0 and days_calc(FormatString(form.DatFin.data),record.DateDebConge) >= 0 )
             or (days_calc(record.DateFinConge,FormatString(form.DatDeb.data)) > 0 and days_calc(record.DateFinConge,FormatString(form.DatFin.data)) > 0 )))) :
             Test = False
         if not Test:
             raise ValidationError('L\'employé est en congé ! Veuillez saisir une autre date.')
예제 #7
0
파일: form.py 프로젝트: AhmedWanneni/PFE
 def validate_Prenom(self, field):
     validation(field.data)
     Gp = Employee.query.filter(Employee.nomEmp == FormatString(self.Nom.data).capitalize(),Employee.prenomEmp == FormatString(field.data).capitalize()).first()
     if Gp:
         raise ValidationError('L\'employé existe déjà! Veuillez en choisir un autre.')
예제 #8
0
파일: form.py 프로젝트: AhmedWanneni/PFE
 def validate_Tel(self, field):
     Gp = Employee.query.filter_by(telEmp=FormatString(field.data)).first()
     if Gp:
         raise ValidationError('Le téléphone existe déjà.')
예제 #9
0
파일: form.py 프로젝트: AhmedWanneni/PFE
 def validate_Cin(self, field):
     Gp = Employee.query.filter_by(cinEmp=FormatString(field.data)).first()
     if Gp:
         raise ValidationError('Cin employé existe déjà.')
예제 #10
0
파일: form.py 프로젝트: AhmedWanneni/PFE
 def validate_Prenom(self, field):
     validation(field.data)
     Gp = User.query.filter(User.nomUser == FormatString(self.Nom.data).capitalize(),User.prenomUser == FormatString(field.data).capitalize()).first()
     if Gp:
         raise ValidationError('L\'utilisateur existe déjà! Veuillez en choisir un autre.')
예제 #11
0
파일: routes.py 프로젝트: sadekmehri/Agil
def login():
    if current_user.is_authenticated:
        if current_user.roleUser == 0:
            return redirect(url_for('chef.index'))
        elif current_user.roleUser == 1:
            return redirect(url_for('admin.index'))

    form = LoginForm()
    if form.validate_on_submit():
        user = User.query.filter_by(emailUser=form.Email.data).filter(
            or_(User.cinUser == FormatString(form.Cin.data),
                User.codeUser == FormatString(form.Cin.data))).first()
        if user:
            day = days_between(user.expiryCompte)
            x = login_details()
            His = LogUser(srcIp=x["Ip"],
                          dateAttempt=x["Date"],
                          descAttempt=x["Description"],
                          idUser=user.idUser)
            if bcrypt.check_password_hash(
                    user.passUser,
                    form.Password.data) and user.nbrAttempts > 0 and int(
                        user.etatCompte) == 1 and day:
                login_user(user, remember=False)
                try:
                    His.statusAttempt = 1
                    db.session.add(His)
                    db.session.commit()
                    send_details_login(user)
                except SQLAlchemyError:
                    flash("Erreur inconnue due au serveur", 'error')
                    db.session.rollback()
                    return redirect(url_for('approot.login'))

                if form.Password.data == "0000":
                    flash("Veuillez réinitialiser votre mot de passe",
                          'success')
                    if user.roleUser == 0:
                        return redirect(url_for('chef.resetLogin'))
                    elif user.roleUser == 1:
                        return redirect(url_for('admin.resetLogin'))

                next_page = request.args.get('next')
                flash('Vous êtes connecté avec succès', 'success')
                if next_page:
                    return redirect(next_page)
                else:
                    if user.roleUser == 0:
                        return redirect(url_for('chef.index'))
                    elif user.roleUser == 1:
                        return redirect(url_for('admin.index'))
            else:
                if day:
                    try:
                        if user.nbrAttempts >= 1:
                            user.nbrAttempts -= 1
                            flash(
                                'Veuillez vérifier vos informations d\'identification',
                                'error')
                            if user.nbrAttempts == 0:
                                user.etatCompte = 0
                        else:
                            if user.roleUser == 0:
                                flash(
                                    'Le compte est verrouillé. Veuillez contacter l\'administrateur',
                                    'error')
                            elif user.roleUser == 1:
                                flash(
                                    'Veuillez réinitialiser votre mot de passe pour déverrouiller le compte',
                                    'error')
                        His.statusAttempt = 0
                        db.session.add(His)
                        db.session.commit()
                    except SQLAlchemyError:
                        db.session.rollback()
                        flash("Erreur inconnue due au serveur", 'error')
                else:
                    try:
                        user.etatCompte = 0
                        user.nbrAttempts = 0
                        His.statusAttempt = 0
                        db.session.add(His)
                        db.session.commit()
                    except SQLAlchemyError:
                        db.session.rollback()
                        flash("Erreur inconnue due au serveur", 'error')
                    else:
                        if user.roleUser == 0:
                            flash(
                                'Le compte est verrouillé. Veuillez contacter l\'administrateur',
                                'error')
                        elif user.roleUser == 1:
                            flash(
                                'Veuillez réinitialiser votre mot de passe pour déverrouiller le compte',
                                'error')

                send_details_login(user)
                return redirect(url_for('approot.login'))
        else:
            flash('Veuillez vérifier vos informations d\'identification',
                  'error')
    return render_template('./main/index.html', form=form)
예제 #12
0
파일: form.py 프로젝트: AhmedWanneni/PFE
 def validate_Cin(self, field):
     Gp = User.query.filter_by(cinUser=FormatString(field.data)).first()
     if Gp:
         raise ValidationError('Cin existe déjà.')
예제 #13
0
파일: utils.py 프로젝트: AhmedWanneni/PFE
def get_field_account_settings(form, user):
    user.nomUser = FormatString(form.Nom.data).capitalize()
    user.prenomUser = FormatString(form.Prenom.data).capitalize()
    user.dateUser = form.Date.data
    user.telUser = form.Tel.data
예제 #14
0
파일: utils.py 프로젝트: AhmedWanneni/PFE
def get_field_conge(form, Abc):
    Abc.DateDebConge = FormatString(form.DatDeb.data)
    Abc.DateFinConge = FormatString(form.DatFin.data)
    Abc.DescConge = FormatString(form.Desc.data)
    Abc.idTypeConge = form.Type.data
예제 #15
0
파일: utils.py 프로젝트: AhmedWanneni/PFE
def get_field_absence(form, Abc):
    Abc.DateAbsence = FormatString(form.Date.data)
    Abc.DescAbsence = FormatString(form.Desc.data)
예제 #16
0
파일: utils.py 프로젝트: AhmedWanneni/PFE
def get_field_expenses(form, Exp):
    Exp.dateExpenses = form.Date.data
    Exp.catExpenses = FormatString(form.Cat.data)
    Exp.amExpenses = form.Mont.data
    Exp.descExpenses = FormatString(form.Desc.data)
예제 #17
0
파일: form.py 프로젝트: AhmedWanneni/PFE
 def validate_Code(form, field):
     validation(field.data)
     Gp = Employee.query.filter(or_(Employee.codeEmp == FormatString(field.data), Employee.cinEmp == FormatString(field.data)),Employee.idStation == current_user.idStation).first()
     if not Gp:
         raise ValidationError('L\'employé n\'existe pas! Veuillez saisir un autre code.')
예제 #18
0
파일: form.py 프로젝트: AhmedWanneni/PFE
 def validate_Tel(self, field):
     Gp = User.query.filter_by(telUser=FormatString(field.data)).first()
     if Gp:
         raise ValidationError('Le téléphone existe déjà! Veuillez en choisir un autre.')
예제 #19
0
def get_field_carburant(form, Carburant):
    Carburant.NomCarburant = FormatString(form.Type.data).capitalize()
    Carburant.PrixCarburant = form.Prix.data
예제 #20
0
파일: form.py 프로젝트: AhmedWanneni/PFE
 def validate_Code(self, field):
     validation(field.data)
     Gp = User.query.filter_by(codeUser=FormatString(field.data)).first()
     if Gp:
         raise ValidationError('Le code existe déjà! Veuillez en choisir un autre.')