Example #1
0
def unique_code_validator(form, field):
    code_unique = Produit.query(
        Produit.name == field.data
    ).count()
    if code_unique:
        if not form.id.data:
            raise wtf.ValidationError('Ce nom est deja utilise.')
        else:
            code = Produit.get_by_id(int(form.id.data))
            if code.name != field.data:
                raise wtf.ValidationError('Ce nom est deja utilise.')
Example #2
0
def unique_email_validator(form, field):
    """ email must be unique"""
    user_manager = Users.query(Users.email == field.data).count()
    if user_manager >= 1 and field.data:
        if not form.id.data:
            raise wtf.ValidationError('Cette adresse email est deja utilise.')
        else:
            code = Users.get_by_id(int(form.id.data))
            if code.email != field.data:
                raise wtf.ValidationError(
                    'Cette adresse email est deja utilise.')
Example #3
0
def unique_code_validator_config(form, field):
    code_unique = Param.query(
        Param.name == field.data,
        Param.type_data == form.type_data.data
    ).count()
    if code_unique:
        if not form.id.data:
            raise wtf.ValidationError('Ce nom est deja utilise.')
        else:
            code = Param.get_by_id(int(form.id.data))
            if code.name != field.data:
                raise wtf.ValidationError('Ce nom est deja utilise.')
Example #4
0
def current_time(form, field):
    time = function.time_convert(field.data)
    if function.date_convert(form.date_livre.data) == datetime.date.today():
        if function.datetime_convert(date_auto_nows).time() > time:
            raise wtf.ValidationError(
                'l\'heure de livraison doit etre superieur a l\'heure en cours'
            )
Example #5
0
def compare_part_interval(form, field):

    code_send = Param.get_by_id(int(field.data))
    code_unique = PrixGateaux.query(
        PrixGateaux.categorie_id == code_send.key
    )
    if code_unique:
        same_param = PrixGateaux.query(
            PrixGateaux.interval == form.interval.data,
            PrixGateaux.categorie_id == code_send.key
        ).get()
        if not form.id.data:
            if same_param:
                raise wtf.ValidationError('Cette categorie avec cet interval de part existe deja.')
        else:
            code = PrixGateaux.get_by_id(int(form.id.data))
            if same_param != code:
                raise wtf.ValidationError('Cette categorie avec cet interval de part existe deja.')
Example #6
0
def password_validator(form, field):
    """ Password must have one lowercase letter, one uppercase letter and one digit."""
    # Convert string to list of characters
    password = list(field.data)
    password_length = len(password)

    # Count lowercase, uppercase and numbers
    lowers = uppers = digits = 0
    for ch in password:
        if ch.islower():
            lowers += 1
        if ch.isupper():
            uppers += 1
        if ch.isdigit():
            digits += 1

    # Password must have one lowercase letter, one uppercase letter and one digit
    is_valid = password_length >= 6 and lowers and uppers and digits
    if not is_valid:
        raise wtf.ValidationError(
            'Le mot de passe doit avoir au moin 6 caracteres avec une lettre minuscule, une lettre majuscule et un chiffre'
        )
Example #7
0
def client_id_required(form, field):
    if not form.client.data:
        if not field.data:
            raise wtf.ValidationError('Selection du profil obligatoire.')
Example #8
0
def execpt_login(form, field):
    if not form.client.data and not field.data:
        raise wtf.ValidationError('Information obligatoire')
Example #9
0
def password_convert(form, field):
    try:
        password = hashlib.sha224(field.data).hexdigest()
    except UnicodeEncodeError:
        raise wtf.ValidationError(
            'les informations du mode passe ne sont pas correct.')
Example #10
0
def date_anniv_existe(form, field):
    if form.exixt_at_date.data != '0':
        if not field.data:
            raise wtf.ValidationError('Information Obligatoire')
Example #11
0
def current_date(form, field):
    date = function.date_convert(field.data)
    if datetime.date.today() > date and not form.update.data:
        raise wtf.ValidationError(
            'La date de livraison doit etre superieur ou egale a la date d\'aujourd\'huit.'
        )