[docs]defis_uuid(uuid_string):try:# Si uuid_string est un code hex valide mais pas un uuid valid,# UUID() va quand même le convertir en uuid valide. Pour se prémunir# de ce problème, on check la version original (sans les tirets) avec# le code hex généré qui doivent être les mêmes.uid=uuid.UUID(uuid_string)returnuid.hex==uuid_string.replace("-","")exceptValueError:returnFalse
[docs]defget_hist(uuid_attached_row):# Test if uuid_attached_row is uuidifnotis_uuid(uuid_attached_row):raiseBadRequest("Value error uuid_attached_row is not valid")""" Here we use execute() instead of scalars() because we need a list of sqlalchemy.engine.Row objects """data=DB.session.execute(select(TValidations.id_nomenclature_valid_status,TValidations.validation_date,TValidations.validation_comment,User.nom_role+" "+User.prenom_role,TValidations.validation_auto,TNomenclatures.label_default,TNomenclatures.cd_nomenclature,).join(TNomenclatures,TNomenclatures.id_nomenclature==TValidations.id_nomenclature_valid_status,).join(User,User.id_role==TValidations.id_validator).where(TValidations.uuid_attached_row==uuid_attached_row).order_by(TValidations.validation_date)).all()history=[]forrowindata:line={}line.update({"id_status":str(row[0]),"date":str(row[1]),"comment":str(row[2]),"validator":str(row[3]),"typeValidation":str(row[4]),"label_default":str(row[5]),"cd_nomenclature":str(row[6]),})history.append(line)returnhistory