20/02/23 - 11h
parent
4b540cade6
commit
4bc04a0fd5
|
@ -1,11 +1,21 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="1122d9e2-679f-46d6-8c4f-97e9ae4041b5" name="Changes" comment="16/02/23 - 22h">
|
||||
<list default="true" id="1122d9e2-679f-46d6-8c4f-97e9ae4041b5" name="Changes" comment="17/02/23 - 14h">
|
||||
<change afterPath="$PROJECT_DIR$/business_prices.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Ela_Spacy.py" beforeDir="false" afterPath="$PROJECT_DIR$/Ela_Spacy.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/GlobalVariable.py" beforeDir="false" afterPath="$PROJECT_DIR$/GlobalVariable.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Inscription_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/Inscription_mgt.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Log/log_file.log" beforeDir="false" afterPath="$PROJECT_DIR$/Log/log_file.log" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/emargement.py" beforeDir="false" afterPath="$PROJECT_DIR$/emargement.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Template/Mysy_attestion_modele2_tpl.html" beforeDir="false" afterPath="$PROJECT_DIR$/Template/Mysy_attestion_modele2_tpl.html" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/data_indexees.csv" beforeDir="false" afterPath="$PROJECT_DIR$/data_indexees.csv" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/ela_index_bdd_classes.py" beforeDir="false" afterPath="$PROJECT_DIR$/ela_index_bdd_classes.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/ela_output_test_file_pandas_2.txt" beforeDir="false" afterPath="$PROJECT_DIR$/ela_output_test_file_pandas_2.txt" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/email_inscription_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/email_inscription_mgt.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/prj_common.py" beforeDir="false" afterPath="$PROJECT_DIR$/prj_common.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/tools_cherif/tools_cherif.py" beforeDir="false" afterPath="$PROJECT_DIR$/tools_cherif/tools_cherif.py" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
|
@ -302,7 +312,14 @@
|
|||
<option name="project" value="LOCAL" />
|
||||
<updated>1676581225101</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="34" />
|
||||
<task id="LOCAL-00034" summary="17/02/23 - 14h">
|
||||
<created>1676639333755</created>
|
||||
<option name="number" value="00034" />
|
||||
<option name="presentableId" value="LOCAL-00034" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1676639333755</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="35" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="Vcs.Log.Tabs.Properties">
|
||||
|
@ -317,7 +334,6 @@
|
|||
</option>
|
||||
</component>
|
||||
<component name="VcsManagerConfiguration">
|
||||
<MESSAGE value="15/12/2022 - 22h00" />
|
||||
<MESSAGE value="16/12/2022 - 22h00" />
|
||||
<MESSAGE value="20/12/22 - 11h30" />
|
||||
<MESSAGE value="20/12/22 - 15h30" />
|
||||
|
@ -342,7 +358,8 @@
|
|||
<MESSAGE value="10/02/23 - 12h" />
|
||||
<MESSAGE value="14/02/23 - 21h" />
|
||||
<MESSAGE value="16/02/23 - 22h" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="16/02/23 - 22h" />
|
||||
<MESSAGE value="17/02/23 - 14h" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="17/02/23 - 14h" />
|
||||
</component>
|
||||
<component name="XDebuggerManager">
|
||||
<breakpoint-manager>
|
||||
|
|
|
@ -307,7 +307,7 @@ def Ela_stemmize(tab_tokens):
|
|||
|
||||
try:
|
||||
tab_ret_val = []
|
||||
#print(" VERIFICATION SI LE MOT EST FR : " + str(tab_tokens))
|
||||
print(" VERIFICATION SI LE MOT EST FR : " + str(tab_tokens))
|
||||
for mot in tab_tokens:
|
||||
if( mycommon.check_word_in_fr_dict(str(mot)) ):
|
||||
|
||||
|
@ -375,7 +375,7 @@ Aussi, on fait le choix de liberé de ne pas stémiser certain mots'''
|
|||
def Ela_stemmize_search(tab_tokens):
|
||||
try:
|
||||
tab_ret_val = []
|
||||
#print(" VERIFICATION SI LE MOT DOIT ETRE STEMISE: " + str(tab_tokens))
|
||||
#print(" VERIFICATION SI LE MOT DOIT ETRE STEMISE - Ela_stemmize_search- : " + str(tab_tokens))
|
||||
for mot in tab_tokens:
|
||||
if (mycommon.Word_Not_Stemmize(str(mot))):
|
||||
tab_ret_val.append(unidecode(mot))
|
||||
|
|
|
@ -294,7 +294,7 @@ Limite des zones de texte des formation
|
|||
- objectif
|
||||
- description
|
||||
"""
|
||||
CLASS_ZONE_PROGRAM_LIMIT = 1000
|
||||
CLASS_ZONE_PROGRAM_LIMIT = 1300
|
||||
CLASS_ZONE_DESCRIP_LIMIT = 1000
|
||||
CLASS_ZONE_OBJECTIF_LIMIT = 1000
|
||||
|
||||
|
|
|
@ -1928,7 +1928,7 @@ Cette fonction envoie le certificat d'un stagiaire
|
|||
def SendAttendeeCertification(diction):
|
||||
try:
|
||||
|
||||
field_list_obligatoire = ['session_id', 'token', 'attendee_email']
|
||||
field_list_obligatoire = ['session_id', 'token', 'attendee_email', 'class_internal_url']
|
||||
|
||||
for val in field_list_obligatoire:
|
||||
if val not in diction:
|
||||
|
@ -1951,6 +1951,7 @@ def SendAttendeeCertification(diction):
|
|||
# Verifier qui la formation n'a pas deja été evaluée
|
||||
tmp_count = MYSY_GV.dbname['inscription'].count_documents({'session_id': str(diction['session_id']),
|
||||
'email': str(diction['attendee_email']),
|
||||
'class_internal_url': str(diction['class_internal_url']),
|
||||
"certification_send_date": {"$exists": True}})
|
||||
|
||||
if (tmp_count > 0):
|
||||
|
@ -2001,6 +2002,8 @@ def SendAttendeeCertification(diction):
|
|||
|
||||
# Recuperation des info de l'inscrit
|
||||
local_Insc_retval = MYSY_GV.dbname['inscription'].find_one({'session_id': str(diction['session_id']),
|
||||
'class_internal_url': str(
|
||||
diction['class_internal_url']),
|
||||
'email': str(diction['attendee_email'])})
|
||||
|
||||
if (local_Insc_retval is None):
|
||||
|
@ -2198,7 +2201,7 @@ def PrintAttendeeCertification(diction):
|
|||
|
||||
contenu_ftion = ""
|
||||
if ("contenu_ftion" in session_formation.keys()):
|
||||
contenu_ftion = session_formation['contenu_ftion']
|
||||
contenu_ftion = str(session_formation['contenu_ftion']).replace('<p>', '').replace('</p>', '').replace("\r\n", '<br/>')
|
||||
my_retrun_dict['contenu_ftion'] = contenu_ftion
|
||||
|
||||
|
||||
|
@ -2245,10 +2248,6 @@ def PrintAttendeeCertification(diction):
|
|||
class_internal_url = local_Insc_retval['class_internal_url']
|
||||
my_retrun_dict['internal_url'] = class_internal_url
|
||||
|
||||
formateur = ""
|
||||
if ("formateur" in local_Insc_retval.keys()):
|
||||
formateur = local_Insc_retval['formateur']
|
||||
my_retrun_dict['formateur'] = formateur
|
||||
|
||||
adresse = ""
|
||||
if ("adresse" in local_Insc_retval.keys()):
|
||||
|
@ -2315,7 +2314,9 @@ def PrintAttendeeCertification(diction):
|
|||
print(" ### body = " + str(body))
|
||||
|
||||
sourceHtml = template.render(json_data=body["data"])
|
||||
orig_file_name = "Attestation_.pdf"
|
||||
mycode = str(datetime.now().timestamp()).replace(".", '').replace(',', '')
|
||||
orig_file_name = "Attestation_" + str(mycode)[:-3] + "pdf"
|
||||
|
||||
outputFilename = str(MYSY_GV.TEMPORARY_DIRECTORY) + str(orig_file_name)
|
||||
|
||||
# open output file for writing (truncated binary)
|
||||
|
|
3713
Log/log_file.log
3713
Log/log_file.log
File diff suppressed because it is too large
Load Diff
|
@ -76,9 +76,8 @@ border: 2px solid; ">
|
|||
|
||||
<div style="width: 100%; margin-bottom: 2rem;">
|
||||
Contenu de la formation : <br />
|
||||
<p style=" width: 80%; margin-left: 1rem;font-size: 12px;">
|
||||
{{json_data.contenu_ftion}}
|
||||
</p>
|
||||
<nav style="margin-left: 3rem; padding-left: 3rem;"> {{json_data.contenu_ftion}} </nav>
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -91,7 +90,7 @@ border: 2px solid; ">
|
|||
|
||||
{% if json_data.cachet_signature %}
|
||||
|
||||
<img src={{ json_data.cachet_signature }} width="100px" />
|
||||
<img src={{ json_data.cachet_signature }} width="280px" />
|
||||
|
||||
{% endif %}
|
||||
|
||||
|
@ -110,8 +109,7 @@ border: 2px solid; ">
|
|||
</div>
|
||||
|
||||
</div>
|
||||
<hr />
|
||||
<div style="text-align: right;border: none;"> Date impression : {{json_data.date_impression}} </div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
|
|
@ -0,0 +1,338 @@
|
|||
"""
|
||||
Ce fichier/class gerer tout ce qui est relatif aux prix des formation
|
||||
- aux discounts accordés par client/famille.
|
||||
Concrètement, il répond aux questions suivantes :
|
||||
• Comment un éditeur de formation va proposer des prix spécifiques à un client / une famille / une entreprise.
|
||||
• Comment un client peut voir la liste des prix spécifiques qui sont accordées.
|
||||
|
||||
"""
|
||||
import pymongo
|
||||
from pymongo import MongoClient
|
||||
import json
|
||||
from bson import ObjectId
|
||||
import re
|
||||
from datetime import datetime
|
||||
import prj_common as mycommon
|
||||
import secrets
|
||||
import inspect
|
||||
import sys, os
|
||||
import csv
|
||||
import pandas as pd
|
||||
from pymongo import ReturnDocument
|
||||
import GlobalVariable as MYSY_GV
|
||||
from math import isnan
|
||||
import GlobalVariable as MYSY_GV
|
||||
import ela_index_bdd_classes as eibdd
|
||||
import email_mgt as email
|
||||
|
||||
def add_business_price(diction):
|
||||
try:
|
||||
|
||||
'''
|
||||
# Verification que les champs reçus dans l'API sont bien dans la liste des champs autorisés
|
||||
# Cela evite le cas ou une entité tierce ajouter les valeurs inconnu dans l'API
|
||||
# Ici on doit mettre tous les champs possible (obligatoire ou non) de la BDD dans la liste
|
||||
# field_list.
|
||||
'''
|
||||
field_list = ['token', 'client_recid', 'discount', 'date_du', 'date_au']
|
||||
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
if val not in field_list:
|
||||
mycommon.myprint(str(inspect.stack()[0][
|
||||
3]) + " - Le champ '" + val + "' n'est pas autorisé")
|
||||
return False, " Le champ '" + val + "' n'est pas autorisé "
|
||||
|
||||
'''
|
||||
Une fois qu'on a controlé que toutes les clés mise dans l'API sont correcte. etape precedente,
|
||||
On controle que les champs obligatoires sont presents dans la liste
|
||||
'''
|
||||
field_list_obligatoire = ['token', 'client_recid', 'discount', 'date_du', 'date_au']
|
||||
|
||||
for val in field_list_obligatoire:
|
||||
if val not in diction:
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " - La valeur '" + val + "' n'est pas presente dans liste ")
|
||||
return False, " La valeur '" + val + "' n'est pas presente dans liste"
|
||||
|
||||
# Recuperation du recid du partner
|
||||
mydata = {}
|
||||
mytoken = ""
|
||||
if ("token" in diction.keys()):
|
||||
if diction['token']:
|
||||
mytoken = diction['token']
|
||||
|
||||
partner_recid = mycommon.get_parnter_recid_from_token(mytoken)
|
||||
if (partner_recid is False):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " - Impossible de recuperer les donnees du partnaire ")
|
||||
return False, "Impossible de recuperer les donnees du partnaire "
|
||||
|
||||
mydata['partner_recid'] = partner_recid
|
||||
|
||||
discount = str(diction['discount']).strip()
|
||||
if (mycommon.IsFloat(discount) is False):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " Le montant de la reduction est incorrecte ")
|
||||
return False, " Le montant de la reduction est incorrecte "
|
||||
|
||||
mydata['discount'] = discount
|
||||
|
||||
date_du = str(diction['date_du']).strip()[0:10]
|
||||
date_au = str(diction['date_au']).strip()[0:10]
|
||||
|
||||
is_date_du = mycommon.CheckisDate(date_du)
|
||||
is_date_au = mycommon.CheckisDate(date_au)
|
||||
|
||||
if (is_date_du is False or is_date_au is False):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " - Impossible de créer le prix, Les dates sont incorrectes ")
|
||||
return False, " Impossible de créer le prix, Les dates sont incorrectes"
|
||||
|
||||
mydata['date_du'] = date_du
|
||||
mydata['date_au'] = date_au
|
||||
|
||||
|
||||
client_recid = str(diction['client_recid']).strip()
|
||||
local_status = mycommon.get_user_data_from_recid(client_recid)
|
||||
if(local_status is False ):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " - Impossible de créer le prix, Le client n'est pas valide ")
|
||||
return False, " Impossible de créer le prix, Le client n'est pas valide "
|
||||
|
||||
mydata['client_recid'] = client_recid
|
||||
mydata['valide'] = "1"
|
||||
mydata['date_update'] = datetime.now().strftime("%d/%m/%Y")
|
||||
|
||||
ret_val = MYSY_GV.dbname['business_prices'].insert_one(mydata)
|
||||
if (ret_val.acknowledged is None):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " - Impossible de créer le prix, ")
|
||||
return False, " Impossible de créer le prix, "
|
||||
|
||||
|
||||
|
||||
return True, " Le prix a été correctement inséré"
|
||||
|
||||
|
||||
except Exception as e:
|
||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
|
||||
return False, " Impossible d'ajouter un prix "
|
||||
|
||||
|
||||
def update_business_price(diction):
|
||||
try:
|
||||
'''
|
||||
# Verification que les champs reçus dans l'API sont bien dans la liste des champs autorisés
|
||||
# Cela evite le cas ou une entité tierce ajouter les valeurs inconnu dans l'API
|
||||
# Ici on doit mettre tous les champs possible (obligatoire ou non) de la BDD dans la liste
|
||||
# field_list.
|
||||
'''
|
||||
field_list = ['token', 'price_id', 'discount', 'date_du', 'date_au']
|
||||
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
if val not in field_list:
|
||||
mycommon.myprint(str(inspect.stack()[0][
|
||||
3]) + " - Le champ '" + val + "' n'est pas autorisé")
|
||||
return False, " Le champ '" + val + "' n'est pas autorisé "
|
||||
|
||||
'''
|
||||
Une fois qu'on a controlé que toutes les clés mise dans l'API sont correcte. etape precedente,
|
||||
On controle que les champs obligatoires sont presents dans la liste
|
||||
'''
|
||||
field_list_obligatoire = ['token', 'price_id']
|
||||
|
||||
for val in field_list_obligatoire:
|
||||
if val not in diction:
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " - La valeur '" + val + "' n'est pas presente dans liste ")
|
||||
return False, " La valeur '" + val + "' n'est pas presente dans liste"
|
||||
|
||||
# Recuperation du recid du partner
|
||||
mydata = {}
|
||||
mytoken = ""
|
||||
if ("token" in diction.keys()):
|
||||
if diction['token']:
|
||||
mytoken = diction['token']
|
||||
|
||||
partner_recid = mycommon.get_parnter_recid_from_token(mytoken)
|
||||
if (partner_recid is False):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " - Impossible de recuperer les donnees du partnaire ")
|
||||
return False, "Impossible de recuperer les donnees du partnaire "
|
||||
|
||||
discount = str(diction['discount']).strip()
|
||||
if (mycommon.IsFloat(discount) is False):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " Le montant de la reduction est incorrecte ")
|
||||
return False, " Le montant de la reduction est incorrecte "
|
||||
|
||||
mydata['discount'] = discount
|
||||
|
||||
date_du = str(diction['date_du']).strip()[0:10]
|
||||
date_au = str(diction['date_au']).strip()[0:10]
|
||||
|
||||
is_date_du = mycommon.CheckisDate(date_du)
|
||||
is_date_au = mycommon.CheckisDate(date_au)
|
||||
|
||||
if (is_date_du is False or is_date_au is False):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " - Impossible de créer le prix, Les dates sont incorrectes ")
|
||||
return False, " Impossible de créer le prix, Les dates sont incorrectes"
|
||||
|
||||
mydata['date_du'] = date_du
|
||||
mydata['date_au'] = date_au
|
||||
mydata['date_update'] = datetime.now().strftime("%d/%m/%Y")
|
||||
|
||||
ret_val = MYSY_GV.dbname['business_prices'].find_one_and_update(
|
||||
{'_id': ObjectId(str(str(diction['price_id']).strip())), },
|
||||
{"$set": mydata},
|
||||
upsert=False,
|
||||
return_document=ReturnDocument.AFTER
|
||||
)
|
||||
|
||||
if ret_val is None or ret_val['_id'] is None:
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " Impossible de modifier le prix ")
|
||||
return False, " Impossible de modifier le prix "
|
||||
|
||||
|
||||
return True, "Le prix a été bien mis à jour"
|
||||
|
||||
|
||||
except Exception as e:
|
||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
|
||||
return False, " Impossible de mettre à jour un prix "
|
||||
|
||||
|
||||
def delete_business_price(diction):
|
||||
try:
|
||||
'''
|
||||
# Verification que les champs reçus dans l'API sont bien dans la liste des champs autorisés
|
||||
# Cela evite le cas ou une entité tierce ajouter les valeurs inconnu dans l'API
|
||||
# Ici on doit mettre tous les champs possible (obligatoire ou non) de la BDD dans la liste
|
||||
# field_list.
|
||||
'''
|
||||
field_list = ['token', 'price_id', 'discount', 'date_du', 'date_au']
|
||||
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
if val not in field_list:
|
||||
mycommon.myprint(str(inspect.stack()[0][
|
||||
3]) + " - Le champ '" + val + "' n'est pas autorisé")
|
||||
return False, " Le champ '" + val + "' n'est pas autorisé "
|
||||
|
||||
'''
|
||||
Une fois qu'on a controlé que toutes les clés mise dans l'API sont correcte. etape precedente,
|
||||
On controle que les champs obligatoires sont presents dans la liste
|
||||
'''
|
||||
field_list_obligatoire = ['token', 'price_id']
|
||||
|
||||
for val in field_list_obligatoire:
|
||||
if val not in diction:
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " - La valeur '" + val + "' n'est pas presente dans liste ")
|
||||
return False, " La valeur '" + val + "' n'est pas presente dans liste"
|
||||
|
||||
# Recuperation du recid du partner
|
||||
mydata = {}
|
||||
mytoken = ""
|
||||
if ("token" in diction.keys()):
|
||||
if diction['token']:
|
||||
mytoken = diction['token']
|
||||
|
||||
partner_recid = mycommon.get_parnter_recid_from_token(mytoken)
|
||||
if (partner_recid is False):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " - Impossible de recuperer les donnees du partnaire ")
|
||||
return False, "Impossible de recuperer les donnees du partnaire "
|
||||
|
||||
mydata['date_update'] = datetime.now().strftime("%d/%m/%Y")
|
||||
mydata['valide'] = "0"
|
||||
|
||||
ret_val = MYSY_GV.dbname['business_prices'].find_one_and_update(
|
||||
{'_id': ObjectId(str(str(diction['price_id']).strip())), },
|
||||
{"$set": mydata},
|
||||
upsert=False,
|
||||
return_document=ReturnDocument.AFTER
|
||||
)
|
||||
|
||||
if ret_val is None or ret_val['_id'] is None:
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " Impossible de supprimer le prix ")
|
||||
return False, " Impossible de supprimer le prix "
|
||||
|
||||
|
||||
return True, "Le prix a été bien supprimer"
|
||||
|
||||
except Exception as e:
|
||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
|
||||
return False, " Impossible de supprimer un prix "
|
||||
|
||||
|
||||
|
||||
def recherche_business_price(diction):
|
||||
try:
|
||||
'''
|
||||
# Verification que les champs reçus dans l'API sont bien dans la liste des champs autorisés
|
||||
# Cela evite le cas ou une entité tierce ajouter les valeurs inconnu dans l'API
|
||||
# Ici on doit mettre tous les champs possible (obligatoire ou non) de la BDD dans la liste
|
||||
# field_list.
|
||||
'''
|
||||
field_list = ['token', 'client_recid', 'discount', 'date_du', 'date_au']
|
||||
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
if val not in field_list:
|
||||
mycommon.myprint(str(inspect.stack()[0][
|
||||
3]) + " - Le champ '" + val + "' n'est pas autorisé")
|
||||
return False, " Le champ '" + val + "' n'est pas autorisé "
|
||||
|
||||
'''
|
||||
Une fois qu'on a controlé que toutes les clés mise dans l'API sont correcte. etape precedente,
|
||||
On controle que les champs obligatoires sont presents dans la liste
|
||||
'''
|
||||
field_list_obligatoire = ['token', 'client_recid']
|
||||
|
||||
for val in field_list_obligatoire:
|
||||
if val not in diction:
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " - La valeur '" + val + "' n'est pas presente dans liste ")
|
||||
return False, " La valeur '" + val + "' n'est pas presente dans liste"
|
||||
|
||||
# Recuperation du recid du partner
|
||||
mydata = {}
|
||||
mytoken = ""
|
||||
if ("token" in diction.keys()):
|
||||
if diction['token']:
|
||||
mytoken = diction['token']
|
||||
|
||||
partner_recid = mycommon.get_parnter_recid_from_token(mytoken)
|
||||
if (partner_recid is False):
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - Impossible de recuperer les donnees du partnaire ")
|
||||
return False, "Impossible de recuperer les donnees du partnaire "
|
||||
|
||||
client_recid = str(diction['client_recid']).strip()
|
||||
local_status = mycommon.get_user_data_from_recid(client_recid)
|
||||
if (local_status is False):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " - Impossible de créer le prix, Le client n'est pas valide ")
|
||||
return False, " Impossible de créer le prix, Le client n'est pas valide "
|
||||
|
||||
|
||||
return True, "ok"
|
||||
|
||||
|
||||
except Exception as e:
|
||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
|
||||
return False, " Impossible de supprimer un prix "
|
|
@ -1,4 +1,4 @@
|
|||
,index,mots,occurence,moyenne,id_formation,source_field
|
||||
0,0,integrative,1,0.33,MYSY_0004,title
|
||||
1,1,aromatherapie,1,0.33,MYSY_0004,title
|
||||
2,2,praticien,1,0.33,MYSY_0004,title
|
||||
0,0,aromatherapie,1,0.33,AR,title
|
||||
1,1,integrative,1,0.33,AR,title
|
||||
2,2,praticien,1,0.33,AR,title
|
||||
|
|
|
|
@ -212,9 +212,9 @@ def ela_index_class_key_word(external_code="", source_field = ""):
|
|||
return False
|
||||
|
||||
# Recuperation de la liste des mots clée
|
||||
print(" ### external_code = ", external_code)
|
||||
#print(" ### external_code = ", external_code)
|
||||
local_class = MYSY_GV.dbname['myclass'].find_one({"external_code": external_code, 'valide':'1', 'locked':'0'})
|
||||
print(" ## local_class = ", local_class)
|
||||
#print(" ## local_class = ", local_class)
|
||||
if( local_class is None ):
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " Aucune formation à indexer (1) pour "+str(external_code))
|
||||
return False
|
||||
|
@ -243,12 +243,12 @@ def ela_index_class_key_word(external_code="", source_field = ""):
|
|||
if(len(str(val).strip()) > 0 ):
|
||||
cpt = cpt + 1
|
||||
# Ajout dant not_stem
|
||||
MYSY_GV.dbname['word_not_stem'].insert_one({'mot':str(val).strip(), 'date_update':str(now), 'id_formation':str(local_class['external_code'])})
|
||||
MYSY_GV.dbname['word_not_stem'].insert_one({'mot':str(val).strip().lower(), 'date_update':str(now), 'id_formation':str(local_class['external_code'])})
|
||||
|
||||
|
||||
|
||||
# Ajouter les mot dans la collection "elaindex" avec une occurrence par defaut de 1000, source_field = 'keyword', moyanne = "1"
|
||||
MYSY_GV.dbname['elaindex'].insert_one({'mots': str(val).strip(), 'occurence': 1000,
|
||||
MYSY_GV.dbname['elaindex'].insert_one({'mots': str(val).strip().lower(), 'occurence': 1000,
|
||||
'source_field':'keyword', 'moyenne':"1",
|
||||
'id_formation':str(local_class['external_code'])})
|
||||
|
||||
|
@ -793,13 +793,13 @@ def ela_recherche_tokens(sentence):
|
|||
De manière plus globale, il faudrait exclure certains mot de la racinisation.
|
||||
|
||||
'''
|
||||
#print(" VERIF : "+str(tab_tokens3))
|
||||
print(" VERIF ICI : "+str(tab_tokens3))
|
||||
|
||||
status, tab_tokens4 = ls.Ela_stemmize_search(tab_tokens3)
|
||||
if( status is False):
|
||||
return False
|
||||
|
||||
print(" VERIF APRES STEMISATION : " + str(tab_tokens4))
|
||||
print(" VERIF APRES STEMISATION AA: " + str(tab_tokens4))
|
||||
|
||||
tab_tokens4.sort()
|
||||
|
||||
|
@ -1135,7 +1135,7 @@ def ela_recherche_article_avis_tokens(sentence):
|
|||
if( status is False):
|
||||
return False
|
||||
|
||||
print(" VERIF APRES STEMISATION : " + str(tab_tokens4))
|
||||
print(" VERIF APRES STEMISATION BB: " + str(tab_tokens4))
|
||||
|
||||
tab_tokens4.sort()
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
mots occurence moyenne id_formation source_field
|
||||
0 integrative 1 0.33 MYSY_0004 title
|
||||
1 aromatherapie 1 0.33 MYSY_0004 title
|
||||
2 praticien 1 0.33 MYSY_0004 title
|
||||
0 aromatherapie 1 0.33 AR title
|
||||
1 integrative 1 0.33 AR title
|
||||
2 praticien 1 0.33 AR title
|
|
@ -677,7 +677,7 @@ def SendAttestion_to_attendee_by_email(diction):
|
|||
|
||||
contenu_ftion = ""
|
||||
if ("contenu_ftion" in local_session.keys()):
|
||||
contenu_ftion = str(local_session['contenu_ftion']).replace('<p>', '').replace('</p>', '')
|
||||
contenu_ftion = str(local_session['contenu_ftion']).replace('<p>', '').replace('</p>', '').replace("\r\n", '<br/>')
|
||||
|
||||
|
||||
msg['From'] = MYSY_GV.O365_SMTP_COUNT_From_User
|
||||
|
@ -721,6 +721,7 @@ def SendAttestion_to_attendee_by_email(diction):
|
|||
}}
|
||||
|
||||
|
||||
print("### body 22 ", body)
|
||||
|
||||
sourceHtml = template.render(json_data=body["params"])
|
||||
|
||||
|
|
54
main.py
54
main.py
|
@ -37,6 +37,7 @@ import email_inscription_mgt as emails_support
|
|||
import opco as opco
|
||||
import Attestation_Certificat as Att_Cert
|
||||
import tools_cherif.tools_cherif as tools_cherif
|
||||
import business_prices as business_prices
|
||||
|
||||
app = Flask(__name__)
|
||||
cors = CORS(app, resources={r"/foo": {"origins": "*"}})
|
||||
|
@ -2459,6 +2460,59 @@ def CheckSalesOrder():
|
|||
localStatus, message = mycommon.CheckSalesOrder(payload)
|
||||
return jsonify(status=localStatus, message=message )
|
||||
|
||||
|
||||
"""
|
||||
Cette API ajoute un business price
|
||||
"""
|
||||
@app.route('/myclass/api/add_business_price/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def add_business_price():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = request.form.to_dict()
|
||||
print(" ### add_business_price : payload = ",payload)
|
||||
localStatus, message = business_prices.add_business_price(payload)
|
||||
return jsonify(status=localStatus, message=message )
|
||||
|
||||
|
||||
"""
|
||||
Cette API modifie un business price
|
||||
"""
|
||||
@app.route('/myclass/api/update_business_price/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def update_business_price():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = request.form.to_dict()
|
||||
print(" ### update_business_price : payload = ",payload)
|
||||
localStatus, message = business_prices.update_business_price(payload)
|
||||
return jsonify(status=localStatus, message=message )
|
||||
|
||||
"""
|
||||
Cette API supprime un business price
|
||||
"""
|
||||
@app.route('/myclass/api/delete_business_price/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def delete_business_price():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = request.form.to_dict()
|
||||
print(" ### delete_business_price : payload = ",payload)
|
||||
localStatus, message = business_prices.delete_business_price(payload)
|
||||
return jsonify(status=localStatus, message=message )
|
||||
|
||||
|
||||
"""
|
||||
Cette API recherche un business price
|
||||
"""
|
||||
@app.route('/myclass/api/recherche_business_price/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def recherche_business_price():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = request.form.to_dict()
|
||||
print(" ### recherche_business_price : payload = ",payload)
|
||||
localStatus, message = business_prices.recherche_business_price(payload)
|
||||
return jsonify(status=localStatus, message=message )
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
print(" debut api")
|
||||
context = SSL.Context(SSL.SSLv23_METHOD)
|
||||
|
|
|
@ -296,6 +296,32 @@ def get_user_recid_from_token(token = ""):
|
|||
myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
|
||||
return False
|
||||
|
||||
"""
|
||||
Cette fonction retourn les données d'un user en partant du recid.
|
||||
return false si le recid est faux ou que le compte utilisateur n'est pas actif
|
||||
"""
|
||||
def get_user_data_from_recid(user_recid = ""):
|
||||
try :
|
||||
if len(str(user_recid)) <= 0 :
|
||||
myprint(" Le user_recid est vide")
|
||||
return False
|
||||
|
||||
coll_token = MYSY_GV.dbname['user_account']
|
||||
# print(" myquery pr demo_account = " + str(myquery))
|
||||
tmp_count = coll_token.count_documents({'recid': str(user_recid), 'active': '1'})
|
||||
if (tmp_count <= 0):
|
||||
return False
|
||||
|
||||
tmp_val = coll_token.find_one({'recid': str(user_recid), 'active': '1'})
|
||||
|
||||
return tmp_val
|
||||
|
||||
except Exception as e:
|
||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||
myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
|
||||
return False
|
||||
|
||||
|
||||
'''
|
||||
recuperation d'email du user from token
|
||||
'''
|
||||
|
@ -515,6 +541,8 @@ stemisable à traver la tabla "word_not_stem
|
|||
def Word_Not_Stemmize(word = None):
|
||||
try:
|
||||
coll_not_stem = MYSY_GV.dbname["word_not_stem"]
|
||||
|
||||
#print(' ### Word_Not_Stemmize mot = ', word)
|
||||
val_tmp = coll_not_stem.count_documents({'mot': str(word)})
|
||||
|
||||
|
||||
|
|
|
@ -266,9 +266,62 @@ def email_validation_list_pos_bio():
|
|||
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - Line : " + str(exc_tb.tb_lineno))
|
||||
return False, " Impossible de recuperer la formation"
|
||||
|
||||
|
||||
import socket
|
||||
import smtplib
|
||||
import re
|
||||
import dns.resolver
|
||||
def test_tab_mail(tab_mail):
|
||||
try:
|
||||
|
||||
email_address = 'emildqsdssdqdsdie.dacossqqazta@3ds.com'
|
||||
|
||||
# Step 1: Check email
|
||||
# Check using Regex that an email meets minimum requirements, throw an error if not
|
||||
addressToVerify = email_address
|
||||
match = re.match('^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$', addressToVerify)
|
||||
|
||||
if match == None:
|
||||
print('Bad Syntax in ' + addressToVerify)
|
||||
raise ValueError('Bad Syntax')
|
||||
|
||||
# Step 2: Getting MX record
|
||||
# Pull domain name from email address
|
||||
domain_name = email_address.split('@')[1]
|
||||
|
||||
# get the MX record for the domain
|
||||
my_resolver = dns.resolver.Resolver()
|
||||
records = my_resolver.resolve(domain_name, 'MX')
|
||||
mxRecord = records[0].exchange
|
||||
mxRecord = str(mxRecord)
|
||||
print(mxRecord)
|
||||
|
||||
# Step 3: ping email server
|
||||
# check if the email address exists
|
||||
|
||||
# Get local server hostname
|
||||
host = socket.gethostname()
|
||||
|
||||
# SMTP lib setup (use debug level for full output)
|
||||
server = smtplib.SMTP()
|
||||
server.set_debuglevel(0)
|
||||
|
||||
# SMTP Conversation
|
||||
server.connect(mxRecord)
|
||||
server.helo(host)
|
||||
server.mail('cbalde@mysy-training.com')
|
||||
code, message = server.rcpt(str(addressToVerify))
|
||||
server.quit()
|
||||
|
||||
# Assume 250 as Success
|
||||
if code == 250:
|
||||
print('Yes')
|
||||
return True, "OK"
|
||||
else:
|
||||
print('N')
|
||||
return False, "KO"
|
||||
return
|
||||
|
||||
list_mail = ""
|
||||
if ("list_mail" in tab_mail.keys()):
|
||||
list_mail = str(tab_mail['list_mail'])
|
||||
|
|
Loading…
Reference in New Issue