parent
b5cbe1b90d
commit
aa7b1f1f85
|
@ -6,14 +6,21 @@
|
|||
<component name="ChangeListManager">
|
||||
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="12/07/2025 - 12h">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" 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$/Job_Cron.py" beforeDir="false" afterPath="$PROJECT_DIR$/Job_Cron.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Job_Cron_Common.py" beforeDir="false" afterPath="$PROJECT_DIR$/Job_Cron_Common.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$/attached_file_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/attached_file_mgt.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Session_Formation.py" beforeDir="false" afterPath="$PROJECT_DIR$/Session_Formation.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/apprenant_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/apprenant_mgt.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/class_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/class_mgt.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/data_indexees.csv" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/ela_output_test_file_pandas_2.txt" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/email_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/email_mgt.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/email_queu/email_queu_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/email_queu/email_queu_mgt.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/note_evaluation_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/note_evaluation_mgt.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/partner_client.py" beforeDir="false" afterPath="$PROJECT_DIR$/partner_client.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/partner_invoice.py" beforeDir="false" afterPath="$PROJECT_DIR$/partner_invoice.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/prj_common.py" beforeDir="false" afterPath="$PROJECT_DIR$/prj_common.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/survey_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/survey_mgt.py" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
|
@ -526,15 +533,4 @@
|
|||
<MESSAGE value="12/07/2025 - 12h" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="12/07/2025 - 12h" />
|
||||
</component>
|
||||
<component name="XDebuggerManager">
|
||||
<breakpoint-manager>
|
||||
<breakpoints>
|
||||
<line-breakpoint enabled="true" suspend="THREAD" type="python-line">
|
||||
<url>file://$PROJECT_DIR$/partner_client.py</url>
|
||||
<line>526</line>
|
||||
<option name="timeStamp" value="1" />
|
||||
</line-breakpoint>
|
||||
</breakpoints>
|
||||
</breakpoint-manager>
|
||||
</component>
|
||||
</project>
|
|
@ -357,12 +357,12 @@ TEMPORARY_DIRECTORY = "./temp_direct"
|
|||
"""
|
||||
Nombre maximum de participants importable par csv
|
||||
"""
|
||||
MAX_PARTICIPANT_BY_CSV = 50
|
||||
MAX_PARTICIPANT_BY_CSV = 200
|
||||
|
||||
"""
|
||||
Nombre maximum de clients de partner importable par csv
|
||||
"""
|
||||
MAX_PARTNER_CLIENT_BY_CSV = 100
|
||||
MAX_PARTNER_CLIENT_BY_CSV = 2000
|
||||
|
||||
"""
|
||||
Nombre maximum de lignes dans un fichier de planification d'une UE
|
||||
|
|
|
@ -306,21 +306,18 @@ def AddStagiairetoClass(diction):
|
|||
|
||||
|
||||
prenom = ""
|
||||
if ("prenom" in diction.keys()):
|
||||
if diction['prenom']:
|
||||
prenom = str(diction['prenom']).strip()
|
||||
if ("prenom" in diction.keys() and diction['prenom']):
|
||||
prenom = str(diction['prenom']).strip()
|
||||
mydata['prenom'] = prenom
|
||||
|
||||
employeur = ""
|
||||
if ("employeur" in diction.keys()):
|
||||
if diction['employeur']:
|
||||
employeur = str(diction['employeur']).strip()
|
||||
if ("employeur" in diction.keys() and diction['employeur']):
|
||||
employeur = str(diction['employeur']).strip()
|
||||
mydata['employeur'] = employeur
|
||||
|
||||
telephone = ""
|
||||
if ("telephone" in diction.keys()):
|
||||
if diction['telephone']:
|
||||
telephone = str(diction['telephone']).strip()
|
||||
if ("telephone" in diction.keys() and diction['telephone']):
|
||||
telephone = str(diction['telephone']).strip()
|
||||
mydata['telephone'] = telephone
|
||||
|
||||
if ("client_rattachement_id" in diction.keys() and diction['client_rattachement_id']):
|
||||
|
@ -405,35 +402,30 @@ def AddStagiairetoClass(diction):
|
|||
mydata['tuteur2_civilite'] = "neutre"
|
||||
|
||||
|
||||
if ("ville" in diction.keys()):
|
||||
if diction['ville']:
|
||||
mydata['ville'] = diction['ville']
|
||||
if ("ville" in diction.keys() and diction['ville']):
|
||||
mydata['ville'] = diction['ville']
|
||||
else:
|
||||
mydata['ville'] = ""
|
||||
|
||||
if ("code_postal" in diction.keys()):
|
||||
if diction['code_postal']:
|
||||
mydata['code_postal'] = diction['code_postal']
|
||||
if ("code_postal" in diction.keys() and diction['code_postal']):
|
||||
mydata['code_postal'] = diction['code_postal']
|
||||
else:
|
||||
mydata['code_postal'] = ""
|
||||
|
||||
if ("adresse" in diction.keys()):
|
||||
if diction['adresse']:
|
||||
mydata['adresse'] = diction['adresse']
|
||||
if ("adresse" in diction.keys() and diction['adresse']):
|
||||
mydata['adresse'] = diction['adresse']
|
||||
else:
|
||||
mydata['adresse'] = ""
|
||||
|
||||
|
||||
if ("pays" in diction.keys()):
|
||||
if diction['pays']:
|
||||
mydata['pays'] = diction['pays']
|
||||
if ("pays" in diction.keys() and diction['pays']):
|
||||
mydata['pays'] = diction['pays']
|
||||
else:
|
||||
mydata['pays'] = ""
|
||||
|
||||
|
||||
if ("inscription_validation_date" in diction.keys()):
|
||||
if diction['inscription_validation_date']:
|
||||
mydata['inscription_validation_date'] = str(diction['inscription_validation_date']).strip()
|
||||
if ("inscription_validation_date" in diction.keys() and diction['inscription_validation_date']):
|
||||
mydata['inscription_validation_date'] = str(diction['inscription_validation_date']).strip()
|
||||
else:
|
||||
mydata['inscription_validation_date'] = ""
|
||||
|
||||
|
@ -447,15 +439,13 @@ def AddStagiairetoClass(diction):
|
|||
return False, " l'adresse email -"+str(diction['email']).strip() +"- est invalide"
|
||||
|
||||
|
||||
if ("modefinancement" in diction.keys()):
|
||||
if diction['modefinancement']:
|
||||
mydata['modefinancement'] = str(diction['modefinancement']).strip()
|
||||
if ("modefinancement" in diction.keys() and diction['modefinancement']):
|
||||
mydata['modefinancement'] = str(diction['modefinancement']).strip()
|
||||
else:
|
||||
mydata['modefinancement'] = ""
|
||||
|
||||
if ("opco" in diction.keys()):
|
||||
if diction['opco']:
|
||||
mydata['opco'] = str(diction['opco']).strip()
|
||||
if ("opco" in diction.keys() and diction['opco']):
|
||||
mydata['opco'] = str(diction['opco']).strip()
|
||||
else:
|
||||
mydata['opco'] = ""
|
||||
|
||||
|
@ -482,10 +472,10 @@ def AddStagiairetoClass(diction):
|
|||
|
||||
|
||||
# Si un prix est fourni dans le diction, j'ecrase le prise qui est venu de la session
|
||||
if ("price" in diction.keys()):
|
||||
if diction['price']:
|
||||
new_price = str(diction['price']).strip()
|
||||
mydata['price'] = str(diction['price']).strip()
|
||||
if ("price" in diction.keys() and diction['price']):
|
||||
new_price = str(diction['price']).strip()
|
||||
mydata['price'] = str(diction['price']).strip()
|
||||
|
||||
|
||||
|
||||
# Verification des prix. si new_price = "-1" cela veut dire qu'il n'a pas de prix dans le diction ni sur la session
|
||||
|
@ -7882,7 +7872,7 @@ def Get_Statgaire_List_Partner_with_filter(diction):
|
|||
try:
|
||||
field_list = ['token', 'class_internal_url', 'code_session', 'status', 'email', 'nom',
|
||||
'class_title', 'code_session','client_nom', 'client_rattachement_id',
|
||||
'session_id']
|
||||
'session_id', 'archive']
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
if val not in field_list and val.startswith('my_') is False:
|
||||
|
@ -7977,6 +7967,16 @@ def Get_Statgaire_List_Partner_with_filter(diction):
|
|||
#print(" ### liste des Id des sessions eligible list_session_id = ", list_session_id)
|
||||
filt_session_id = {'session_id': {'$in': list_session_id, }}
|
||||
|
||||
filt_archive = {}
|
||||
if ("archive" in diction.keys() and (diction["archive"] == "0" or diction["archive"] == "")):
|
||||
filt_archive = {'archive': {'$ne': '1'}}
|
||||
|
||||
elif ("archive" in diction.keys() and diction["archive"] == "1"):
|
||||
filt_archive = {'archive': '1'}
|
||||
|
||||
elif ("archive" not in diction.keys()):
|
||||
filt_archive = {'archive': {'$ne': '1'}}
|
||||
|
||||
|
||||
filt_class_title = {}
|
||||
if ("class_title" in diction.keys()):
|
||||
|
@ -8026,8 +8026,8 @@ def Get_Statgaire_List_Partner_with_filter(diction):
|
|||
#----
|
||||
|
||||
|
||||
query = [{'$match':{ '$and' : [ filt_class_internal_url, filt_session_id, filt_email, filt_nom, filt_client_nom, filt_client_rattachement_id,
|
||||
filt_session_id, {'partner_owner_recid':str(partner_recid)}] } },
|
||||
query = [{'$match':{ '$and' : [ filt_archive, filt_class_internal_url, filt_session_id, filt_email, filt_nom, filt_client_nom, filt_client_rattachement_id,
|
||||
filt_session_id, {'partner_owner_recid':str(partner_recid), 'valide':'1'}] } },
|
||||
{'$sort': {'_id': -1}},
|
||||
{'$lookup':
|
||||
{
|
||||
|
@ -8067,7 +8067,28 @@ def Get_Statgaire_List_Partner_with_filter(diction):
|
|||
cpt = 0
|
||||
for retVal in MYSY_GV.dbname['inscription'].aggregate(query):
|
||||
val = {}
|
||||
if ('myclass_collection' in retVal.keys() and len(retVal['myclass_collection']) > 0):
|
||||
# Verifier si le client est valide
|
||||
client_valide = "1"
|
||||
if( "client_rattachement_id" in retVal.keys() and retVal['client_rattachement_id']):
|
||||
client_rattachement_id_count = MYSY_GV.dbname['partner_client'].count_documents({'_id':ObjectId(retVal['client_rattachement_id']),
|
||||
'valide':'1',
|
||||
'locked':'0',
|
||||
'partner_owner_recid':str(my_partner['recid'])})
|
||||
if( client_rattachement_id_count <= 0 ):
|
||||
client_valide = "0"
|
||||
|
||||
# Verifier si le client de facturation est valide
|
||||
client_facturation_valide = "1"
|
||||
if ("facture_client_rattachement_id" in retVal.keys() and retVal['facture_client_rattachement_id']):
|
||||
facture_client_rattachement_id_id_count = MYSY_GV.dbname['partner_client'].count_documents(
|
||||
{'_id': ObjectId(retVal['facture_client_rattachement_id']),
|
||||
'valide': '1',
|
||||
'locked': '0',
|
||||
'partner_owner_recid': str(my_partner['recid'])})
|
||||
if (facture_client_rattachement_id_id_count <= 0):
|
||||
client_facturation_valide = "0"
|
||||
|
||||
if ('myclass_collection' in retVal.keys() and len(retVal['myclass_collection']) > 0 and client_valide == "1" and client_facturation_valide == "1"):
|
||||
|
||||
val['id'] = str(cpt)
|
||||
cpt = cpt + 1
|
||||
|
@ -8091,14 +8112,18 @@ def Get_Statgaire_List_Partner_with_filter(diction):
|
|||
if( str(val['civilite']).strip() == ""):
|
||||
val['civilite'] = "neutre"
|
||||
|
||||
|
||||
|
||||
if( "modefinancement" in retVal.keys()):
|
||||
val['modefinancement'] = retVal['modefinancement']
|
||||
else:
|
||||
val['modefinancement'] = ""
|
||||
|
||||
|
||||
if ("archive" not in retVal.keys()):
|
||||
val['archive'] = "0"
|
||||
|
||||
|
||||
if ("opco" in retVal.keys()):
|
||||
|
||||
val['opco'] = retVal['opco']
|
||||
else:
|
||||
val['opco'] = ""
|
||||
|
@ -8715,6 +8740,11 @@ def GetAttendeeDetail_perSession_from_line_id(diction):
|
|||
local_status = local_Insc_retval['status']
|
||||
my_retrun_dict['status'] = local_status
|
||||
|
||||
|
||||
if ("archive" not in local_Insc_retval.keys()):
|
||||
my_retrun_dict['archive'] = "0"
|
||||
|
||||
|
||||
local_price = ""
|
||||
if ("price" in local_Insc_retval.keys()):
|
||||
local_price = local_Insc_retval['price']
|
||||
|
@ -14655,3 +14685,190 @@ def Update_LMS_Inscrition_End_Date(diction):
|
|||
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - Line : " + str(exc_tb.tb_lineno))
|
||||
return False, " Impossible de mettre à jour la date "
|
||||
|
||||
|
||||
|
||||
"""
|
||||
02/06/2025 : Archivage d'un stagiaire
|
||||
"""
|
||||
def archive_stagiaire(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 = ['tab_stagiaire_ids', 'token']
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
if val not in field_list and val.startswith('my_') is False:
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3])+" - Le champ '" + val + "' n'existe pas")
|
||||
return False, " Le champ '" + val + "' n'existe pas"
|
||||
|
||||
'''
|
||||
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 = ['tab_stagiaire_ids', 'token']
|
||||
|
||||
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 la liste des arguments ")
|
||||
return False, " Impossible de mettre à jour la formation"
|
||||
|
||||
# recuperation des paramettre
|
||||
mydata = {}
|
||||
my_internal_url = ""
|
||||
|
||||
if ("token" in diction.keys()):
|
||||
if diction['token']:
|
||||
mydata['token'] = diction['token']
|
||||
|
||||
# Verification de la validité du token
|
||||
tab_stagiaire_ids = []
|
||||
tab_stagiaire_ids_ObjectId = []
|
||||
if ("tab_stagiaire_ids" in diction.keys()):
|
||||
tab_stagiaire_ids = str(diction['tab_stagiaire_ids']).split(",")
|
||||
|
||||
for tmp in tab_stagiaire_ids:
|
||||
if (tmp):
|
||||
tab_stagiaire_ids_ObjectId.append(ObjectId(tmp))
|
||||
|
||||
# Verification de la validité du token
|
||||
local_status, my_partner = mycommon.Check_Connexion_And_Return_Partner_Data(diction)
|
||||
if (local_status is not True):
|
||||
return local_status, my_partner
|
||||
|
||||
mydata['date_update'] = str(datetime.now())
|
||||
mydata['update_by'] = str(my_partner['_id'])
|
||||
mydata['archive'] = '1'
|
||||
|
||||
|
||||
# seules les formations avec locked = 0 et valide=1 sont modifiables
|
||||
ret_val = MYSY_GV.dbname['inscription'].update_many(
|
||||
{'_id': {'$in': tab_stagiaire_ids_ObjectId}, 'valide': '1',
|
||||
'partner_owner_recid': str(my_partner['recid'])},
|
||||
{"$set": mydata},
|
||||
|
||||
)
|
||||
|
||||
for stagiaire_id in tab_stagiaire_ids:
|
||||
# pour la collection 'myclass'
|
||||
now = str(datetime.now().strftime("%d/%m/%Y %H:%M:%S"))
|
||||
# print(" ####### laaaa diction = ", diction)
|
||||
|
||||
history_event_dict = {}
|
||||
history_event_dict['token'] = str(diction['token'])
|
||||
history_event_dict['related_collection'] = "inscription"
|
||||
history_event_dict['related_collection_recid'] = str(stagiaire_id)
|
||||
history_event_dict['action_date'] = str(now)
|
||||
|
||||
history_event_dict['action_description'] = "Archivage "
|
||||
local_status, local_retval = mycommon.Collection_Historique.Add_Historique_Event(history_event_dict)
|
||||
if (local_status is False):
|
||||
mycommon.myprint(
|
||||
" WARNING : Impossible de logguer l'historique pour l'évènement : " + str(history_event_dict))
|
||||
|
||||
return True, " Stagiaire(s) archivé(s) "
|
||||
|
||||
|
||||
except Exception as e:
|
||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - Line : " + str(exc_tb.tb_lineno))
|
||||
return False, " Impossible d'archiver les inscrits "
|
||||
|
||||
|
||||
"""
|
||||
02/06/2025 : De-Archivage d'un stagiaire
|
||||
"""
|
||||
def unarchive_stagiaire(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 = ['tab_stagiaire_ids', 'token']
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
if val not in field_list and val.startswith('my_') is False:
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3])+" - Le champ '" + val + "' n'existe pas")
|
||||
return False, " Le champ '" + val + "' n'existe pas"
|
||||
|
||||
'''
|
||||
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 = ['tab_stagiaire_ids', 'token']
|
||||
|
||||
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 la liste des arguments ")
|
||||
return False, " Impossible de mettre à jour la formation"
|
||||
|
||||
# recuperation des paramettre
|
||||
mydata = {}
|
||||
my_internal_url = ""
|
||||
|
||||
if ("token" in diction.keys()):
|
||||
if diction['token']:
|
||||
mydata['token'] = diction['token']
|
||||
|
||||
# Verification de la validité du token
|
||||
tab_stagiaire_ids = []
|
||||
tab_stagiaire_ids_ObjectId = []
|
||||
if ("tab_stagiaire_ids" in diction.keys()):
|
||||
tab_stagiaire_ids = str(diction['tab_stagiaire_ids']).split(",")
|
||||
|
||||
for tmp in tab_stagiaire_ids:
|
||||
if (tmp):
|
||||
tab_stagiaire_ids_ObjectId.append(ObjectId(tmp))
|
||||
|
||||
# Verification de la validité du token
|
||||
local_status, my_partner = mycommon.Check_Connexion_And_Return_Partner_Data(diction)
|
||||
if (local_status is not True):
|
||||
return local_status, my_partner
|
||||
|
||||
mydata['date_update'] = str(datetime.now())
|
||||
mydata['update_by'] = str(my_partner['_id'])
|
||||
mydata['archive'] = '0'
|
||||
|
||||
|
||||
# seules les formations avec locked = 0 et valide=1 sont modifiables
|
||||
ret_val = MYSY_GV.dbname['partner_client'].update_many(
|
||||
{'_id': {'$in': tab_stagiaire_ids_ObjectId}, 'valide': '1',
|
||||
'partner_owner_recid': str(my_partner['recid'])},
|
||||
{"$set": mydata},
|
||||
|
||||
)
|
||||
|
||||
for stagiaire_id in tab_stagiaire_ids:
|
||||
# pour la collection 'myclass'
|
||||
now = str(datetime.now().strftime("%d/%m/%Y %H:%M:%S"))
|
||||
# print(" ####### laaaa diction = ", diction)
|
||||
|
||||
history_event_dict = {}
|
||||
history_event_dict['token'] = str(diction['token'])
|
||||
history_event_dict['related_collection'] = "inscription"
|
||||
history_event_dict['related_collection_recid'] = str(stagiaire_id)
|
||||
history_event_dict['action_date'] = str(now)
|
||||
|
||||
history_event_dict['action_description'] = "Desarchivage "
|
||||
local_status, local_retval = mycommon.Collection_Historique.Add_Historique_Event(history_event_dict)
|
||||
if (local_status is False):
|
||||
mycommon.myprint(
|
||||
" WARNING : Impossible de logguer l'historique pour l'évènement : " + str(history_event_dict))
|
||||
|
||||
return True, " Stagiaire(s) desarchivée(s) "
|
||||
|
||||
|
||||
except Exception as e:
|
||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - Line : " + str(exc_tb.tb_lineno))
|
||||
return False, " Impossible desarchiver les inscrits"
|
||||
|
||||
|
|
155
Job_Cron.py
155
Job_Cron.py
|
@ -2,7 +2,13 @@
|
|||
Ce fichier permet de gerer les crons et differents job
|
||||
"""
|
||||
import ast
|
||||
import smtplib
|
||||
from calendar import monthrange
|
||||
from email.message import EmailMessage
|
||||
from email.mime.base import MIMEBase
|
||||
from email.mime.multipart import MIMEMultipart
|
||||
from email.mime.text import MIMEText
|
||||
from email import encoders
|
||||
|
||||
import bson
|
||||
import pymongo
|
||||
|
@ -2035,3 +2041,152 @@ def Cron_Survey_Questionnaires_Relance():
|
|||
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - Line : " + str(exc_tb.tb_lineno))
|
||||
return False, str(inspect.stack()[0][3]) + " -" + str(e) + " - Line : " + str(exc_tb.tb_lineno)
|
||||
|
||||
|
||||
"""
|
||||
Cette fonction permet d'envoyer les emails qui sont dans file d'attente
|
||||
collection : 'email_queue'
|
||||
"""
|
||||
def Cron_Send_Mail_Queue_Message_With_Filter(diction):
|
||||
try:
|
||||
|
||||
field_list_obligatoire = ['tab_partner_owner_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 la liste des arguments ")
|
||||
return False, " La valeur '" + val + "' n'est pas presente dans la liste des arguments"
|
||||
|
||||
tab_partner_owner_recid = []
|
||||
tab_partner_owner_recid_split = str(diction['tab_partner_owner_recid']).split(",")
|
||||
for tmp in tab_partner_owner_recid_split:
|
||||
if( tmp ):
|
||||
tab_partner_owner_recid.append(str(tmp))
|
||||
|
||||
if(len(tab_partner_owner_recid) > 0 ):
|
||||
for local_partner_owner_recid in tab_partner_owner_recid:
|
||||
for email_queue_data in MYSY_GV.dbname['mail_queue'].find({'statut':'0', 'valide':'1', 'locked':'0',
|
||||
'partner_owner_recid':local_partner_owner_recid}):
|
||||
msg = MIMEMultipart("alternative")
|
||||
|
||||
msg['From'] = email_queue_data['from']
|
||||
msg['Cc'] = email_queue_data['cc']
|
||||
msg['Bcc'] = 'contact@mysy-training.com'
|
||||
msg['Subject'] = email_queue_data['subject']
|
||||
msg['to'] = email_queue_data['to']
|
||||
# Traitement de l'eventuel fichier joint
|
||||
tab_files_to_attache_to_mail = []
|
||||
|
||||
html_mime = MIMEText(email_queue_data['message'], 'html')
|
||||
msg.attach(html_mime)
|
||||
|
||||
#print(" ### msg = ", str(msg) )
|
||||
smtpserver = smtplib.SMTP(email_queue_data['smtp_account_smtpsrv'], email_queue_data['smtp_account_port'])
|
||||
|
||||
if( "tab_saved_file_full_path" in email_queue_data.keys() ):
|
||||
for myfile in email_queue_data['tab_saved_file_full_path']:
|
||||
file_to_attache_to_mail = MIMEBase('application', "octet-stream")
|
||||
file_to_attache_to_mail.set_payload(open(myfile, "rb").read())
|
||||
encoders.encode_base64(file_to_attache_to_mail)
|
||||
file_to_attache_to_mail.add_header('Content-Disposition',
|
||||
'attachment; filename="{0}"'.format(os.path.basename(myfile)))
|
||||
|
||||
new_node = {"attached_file": file_to_attache_to_mail}
|
||||
tab_files_to_attache_to_mail.append(new_node)
|
||||
|
||||
# Attacher l'eventuelle pièces jointes
|
||||
for myfile in tab_files_to_attache_to_mail:
|
||||
msg.attach(myfile['attached_file'])
|
||||
|
||||
smtpserver.ehlo()
|
||||
smtpserver.starttls()
|
||||
smtpserver.login(email_queue_data['smtp_account_user'], email_queue_data['smtp_account_password'])
|
||||
|
||||
|
||||
|
||||
val = smtpserver.send_message(msg)
|
||||
smtpserver.close()
|
||||
print(" Email envoyé" + str(val))
|
||||
|
||||
"""
|
||||
On met à jour l'email avec le statut d'envoie de l'email
|
||||
"""
|
||||
new_data = diction
|
||||
new_data['date_update'] = str(datetime.now())
|
||||
new_data['sent'] = str(datetime.now())
|
||||
new_data['statut'] = "1"
|
||||
new_data['sent_message'] = str(val)
|
||||
|
||||
result = MYSY_GV.dbname['mail_queue'].find_one_and_update(
|
||||
{'_id':ObjectId(str(email_queue_data['_id']))},
|
||||
{"$set": new_data},
|
||||
upsert=False,
|
||||
return_document=ReturnDocument.AFTER
|
||||
)
|
||||
|
||||
else:
|
||||
for email_queue_data in MYSY_GV.dbname['mail_queue'].find({'statut': '0', 'valide': '1', 'locked': '0', }):
|
||||
msg = MIMEMultipart("alternative")
|
||||
|
||||
msg['From'] = email_queue_data['from']
|
||||
msg['Cc'] = email_queue_data['cc']
|
||||
msg['Bcc'] = 'contact@mysy-training.com'
|
||||
msg['Subject'] = email_queue_data['subject']
|
||||
msg['to'] = email_queue_data['to']
|
||||
# Traitement de l'eventuel fichier joint
|
||||
tab_files_to_attache_to_mail = []
|
||||
|
||||
html_mime = MIMEText(email_queue_data['message'], 'html')
|
||||
msg.attach(html_mime)
|
||||
|
||||
# print(" ### msg = ", str(msg) )
|
||||
smtpserver = smtplib.SMTP(email_queue_data['smtp_account_smtpsrv'],
|
||||
email_queue_data['smtp_account_port'])
|
||||
|
||||
if ("tab_saved_file_full_path" in email_queue_data.keys()):
|
||||
for myfile in email_queue_data['tab_saved_file_full_path']:
|
||||
file_to_attache_to_mail = MIMEBase('application', "octet-stream")
|
||||
file_to_attache_to_mail.set_payload(open(myfile, "rb").read())
|
||||
encoders.encode_base64(file_to_attache_to_mail)
|
||||
file_to_attache_to_mail.add_header('Content-Disposition',
|
||||
'attachment; filename="{0}"'.format(
|
||||
os.path.basename(myfile)))
|
||||
|
||||
new_node = {"attached_file": file_to_attache_to_mail}
|
||||
tab_files_to_attache_to_mail.append(new_node)
|
||||
|
||||
# Attacher l'eventuelle pièces jointes
|
||||
for myfile in tab_files_to_attache_to_mail:
|
||||
msg.attach(myfile['attached_file'])
|
||||
|
||||
smtpserver.ehlo()
|
||||
smtpserver.starttls()
|
||||
smtpserver.login(email_queue_data['smtp_account_user'], email_queue_data['smtp_account_password'])
|
||||
|
||||
val = smtpserver.send_message(msg)
|
||||
smtpserver.close()
|
||||
print(" Email envoyé" + str(val))
|
||||
|
||||
"""
|
||||
On met à jour l'email avec le statut d'envoie de l'email
|
||||
"""
|
||||
new_data = diction
|
||||
new_data['date_update'] = str(datetime.now())
|
||||
new_data['sent'] = str(datetime.now())
|
||||
new_data['statut'] = "2"
|
||||
new_data['sent_message'] = str(val)
|
||||
|
||||
result = MYSY_GV.dbname['mail_queue'].find_one_and_update(
|
||||
{'_id': ObjectId(str(email_queue_data['_id']))},
|
||||
{"$set": new_data},
|
||||
upsert=False,
|
||||
return_document=ReturnDocument.AFTER
|
||||
)
|
||||
|
||||
|
||||
return True, "L'emails de la file d'attente envoyés "
|
||||
except Exception as e:
|
||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - Line : " + str(exc_tb.tb_lineno))
|
||||
return False, " Impossible d'envoyer les emails "
|
||||
|
|
|
@ -3004,77 +3004,3 @@ def Cron_Send_Emargement_By_Date_By_Email_for_not_sent(Folder, diction):
|
|||
return False, " Impossible d'envoyer les demandes d'émargement ", "0"
|
||||
|
||||
|
||||
"""
|
||||
Cette fonction permet d'envoyer les emails qui sont dans file d'attente
|
||||
collection : 'email_queue'
|
||||
"""
|
||||
def Send_Mail_Queue_Message_With_Filter(diction):
|
||||
try:
|
||||
|
||||
field_list_obligatoire = ['partner_owner_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 la liste des arguments ")
|
||||
return False, " La valeur '" + val + "' n'est pas presente dans la liste des arguments"
|
||||
|
||||
for email_queue_data in MYSY_GV.dbname['mail_queue'].find({'statut':'0', 'valide':'1', 'locked':'0'}):
|
||||
msg = MIMEMultipart("alternative")
|
||||
msg.attach(email_queue_data['message'])
|
||||
msg['From'] = email_queue_data['from']
|
||||
msg['Cc'] = email_queue_data['cc']
|
||||
msg['Bcc'] = 'contact@mysy-training.com'
|
||||
msg['Subject'] = email_queue_data['subject']
|
||||
msg['to'] = email_queue_data['to']
|
||||
# Traitement de l'eventuel fichier joint
|
||||
tab_files_to_attache_to_mail = []
|
||||
|
||||
smtpserver = smtplib.SMTP(email_queue_data['smtp_account_smtpsrv'], email_queue_data['smtp_account_port'])
|
||||
|
||||
for myfile in email_queue_data['attached_files_path']:
|
||||
file_to_attache_to_mail = MIMEBase('application', "octet-stream")
|
||||
file_to_attache_to_mail.set_payload(open(myfile, "rb").read())
|
||||
encoders.encode_base64(file_to_attache_to_mail)
|
||||
file_to_attache_to_mail.add_header('Content-Disposition',
|
||||
'attachment; filename="{0}"'.format(os.path.basename(myfile)))
|
||||
|
||||
new_node = {"attached_file": file_to_attache_to_mail}
|
||||
tab_files_to_attache_to_mail.append(new_node)
|
||||
|
||||
# Attacher l'eventuelle pièces jointes
|
||||
for myfile in tab_files_to_attache_to_mail:
|
||||
msg.attach(myfile['attached_file'])
|
||||
|
||||
smtpserver.ehlo()
|
||||
smtpserver.starttls()
|
||||
smtpserver.login(email_queue_data['smtp_account_user'], email_queue_data['smtp_account_password'])
|
||||
val = smtpserver.send_message(msg)
|
||||
smtpserver.close()
|
||||
print(" Email envoyé" + str(val))
|
||||
|
||||
"""
|
||||
On met à jour l'email avec le statut d'envoie de l'email
|
||||
"""
|
||||
new_data = diction
|
||||
new_data['date_update'] = str(datetime.now())
|
||||
new_data['sent'] = str(datetime.now())
|
||||
new_data['statut'] = "2"
|
||||
new_data['sent_message'] = str(val)
|
||||
|
||||
result = MYSY_GV.dbname['mail_queue'].find_one_and_update(
|
||||
{'_id':ObjectId(str(email_queue_data['_id']))},
|
||||
{"$set": new_data},
|
||||
upsert=False,
|
||||
return_document=ReturnDocument.AFTER
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
return True, "L'emails envoyés "
|
||||
except Exception as e:
|
||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - Line : " + str(exc_tb.tb_lineno))
|
||||
return False, " Impossible d'envoyer les emails "
|
||||
|
|
14558
Log/log_file.log
14558
Log/log_file.log
File diff suppressed because one or more lines are too long
|
@ -156,14 +156,18 @@ def Add_Update_SessionFormation(diction):
|
|||
mydata['code_session'] = diction['code_session']
|
||||
query_key['code_session'] = diction['code_session']
|
||||
|
||||
type_session = ""
|
||||
if( str(diction['type_session']).strip() not in MYSY_GV.TYPE_SESSION):
|
||||
type_session = str(diction['type_session']).strip()
|
||||
if( type_session ):
|
||||
type_session = str(mycommon.tryInt(type_session))
|
||||
|
||||
|
||||
if( type_session not in MYSY_GV.TYPE_SESSION):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " - : La valeur '" + diction['type_session'] + "' est invalide. Les valeurs acceptées sont "+str(MYSY_GV.TYPE_SESSION))
|
||||
return False, "La valeur '" + diction['type_session'] + "' est invalide. Les valeurs acceptées sont "+str(MYSY_GV.TYPE_SESSION)
|
||||
|
||||
mydata['type_session'] = str(diction['type_session']).strip()
|
||||
mydata['type_session'] = type_session
|
||||
|
||||
|
||||
"""
|
||||
|
@ -4172,7 +4176,10 @@ def Add_Update_SessionFormation_mass_for_many_class(file=None, Folder=None, dict
|
|||
return False, "Le champ 'location_type' est incorrect."
|
||||
|
||||
if ("is_bpf" in df.keys()):
|
||||
if (str(df['is_bpf'].values[n]).strip() not in ['0', '1']):
|
||||
is_bpf = str(df['is_bpf'].values[n]).strip()
|
||||
is_bpf = str(mycommon.tryInt(is_bpf))
|
||||
|
||||
if (is_bpf not in ['0', '1']):
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - Le champ 'bpf' est incorrect. Les valeurs acceptées sont : '1' ou '0' ")
|
||||
return False, "Le champ 'bpf' est incorrect. Les valeurs acceptées sont : '1' ou '0' "
|
||||
|
||||
|
@ -4355,6 +4362,7 @@ def Add_Update_SessionFormation_mass_for_many_class(file=None, Folder=None, dict
|
|||
if (str(df['mode_animation'].values[n])):
|
||||
mode_animation = str(df['mode_animation'].values[n]).strip()
|
||||
mode_animation = str(mycommon.tryInt(mode_animation))
|
||||
|
||||
if (mode_animation != "1" and mode_animation != "0" and mode_animation != "2"):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " Le champ 'mode_animation' de la ligne " + str(
|
||||
|
@ -4667,8 +4675,13 @@ def Controle_Add_Update_SessionFormation_mass_for_many_class(saved_file=None, Fo
|
|||
|
||||
local_type_session = ""
|
||||
if ("type_session" in df.keys()):
|
||||
if (str(df['type_session'].values[n])):
|
||||
local_type_session = str(df['type_session'].values[n]).strip()
|
||||
type_session = str(df['type_session'].values[n])
|
||||
type_session = str(mycommon.tryInt(type_session))
|
||||
|
||||
if (type_session):
|
||||
local_type_session = type_session
|
||||
|
||||
print(" ### local_type_session = ", local_type_session)
|
||||
|
||||
if (local_type_session not in MYSY_GV.TYPE_SESSION):
|
||||
mycommon.myprint(
|
||||
|
@ -4770,7 +4783,10 @@ def Controle_Add_Update_SessionFormation_mass_for_many_class(saved_file=None, Fo
|
|||
return False, "Le champ 'location_type' est incorrect. . Les valeurs acceptés sont : "+str(MYSY_GV.TRAINING_LOCATION_TYPE)+ " "
|
||||
|
||||
if ("is_bpf" in df.keys()):
|
||||
if (str(df['is_bpf'].values[n]).strip() not in ['0', '1']):
|
||||
is_bpf = str(df['is_bpf'].values[n]).strip()
|
||||
is_bpf = str(mycommon.tryInt(is_bpf))
|
||||
|
||||
if (is_bpf not in ['0', '1']):
|
||||
mycommon.myprint(str(inspect.stack()[0][
|
||||
3]) + " - Le champ 'bpf' est incorrect. Les valeurs acceptées sont : '1' ou '0' ")
|
||||
return False, "Le champ 'bpf' est incorrect. Les valeurs acceptées sont : '1' ou '0' "
|
||||
|
@ -12870,7 +12886,12 @@ def Invoice_Partner_From_Session_By_Inscription_Id( diction):
|
|||
partner_invoice_line_data_detail = {}
|
||||
partner_invoice_line_data_detail['order_line_inscription_id'] = str(tmp_inscription_dat['_id'])
|
||||
partner_invoice_line_data_detail['order_line_inscription_type_apprenant'] = str(tmp_inscription_dat['type_apprenant'])
|
||||
partner_invoice_line_data_detail['order_line_inscription_modefinancement'] = str(tmp_inscription_dat['modefinancement'])
|
||||
|
||||
if( "modefinancement" in tmp_inscription_dat.keys()):
|
||||
partner_invoice_line_data_detail['order_line_inscription_modefinancement'] = str(tmp_inscription_dat['modefinancement'])
|
||||
else:
|
||||
partner_invoice_line_data_detail['order_line_inscription_modefinancement'] = ""
|
||||
|
||||
partner_invoice_line_data_detail['order_line_formation'] = class_data[0]['internal_url']
|
||||
partner_invoice_line_data_detail['order_line_prix_unitaire'] = str(prix_session)
|
||||
partner_invoice_line_data_detail['order_line_qty'] = "1"
|
||||
|
|
|
@ -2129,6 +2129,15 @@ def Controle_Add_Apprenant_mass(saved_file=None, Folder=None, diction=None):
|
|||
mydata['nom'] = str(df['nom'].values[n])
|
||||
mydata['email'] = str(df['email'].values[n])
|
||||
|
||||
civilite = ""
|
||||
if ("civilite" in df.keys()):
|
||||
if (str(df['civilite'].values[n])):
|
||||
civilite = str(df['civilite'].values[n]).lower()
|
||||
mydata['civilite'] = civilite
|
||||
|
||||
if (str(civilite).strip() == ""):
|
||||
mydata['civilite'] = "neutre"
|
||||
|
||||
|
||||
if (len(str(mydata['nom']).strip()) < 2):
|
||||
mycommon.myprint(
|
||||
|
|
|
@ -1366,7 +1366,7 @@ def update_class(diction):
|
|||
myquery = {"recid": str(user_recid), "active": "1",
|
||||
"demo_account": "1"}
|
||||
|
||||
#print(" myquery pr demo_account = " + str(myquery))
|
||||
print(" myquery pr demo_account = " + str(myquery))
|
||||
tmp = coll_partner_account.count_documents(myquery)
|
||||
|
||||
if (tmp > 0):
|
||||
|
@ -1383,6 +1383,7 @@ def update_class(diction):
|
|||
return False, "Votre pack / abonnement ne permet pas de créer les formations. Verifiez votre abonnement ", False
|
||||
|
||||
|
||||
print(" ### part_pack uuuu = ", part_pack)
|
||||
coll_pack = MYSY_GV.dbname['pack']
|
||||
local_tmp = coll_pack.find({'code_pack':str(part_pack).lower()})
|
||||
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
,index,mots,occurence,moyenne,id_formation,source_field,partner_owner_recid
|
||||
0,0,vendeur,1,0.5,TVC_01,keyword,43598820dd270936c3d2fd822717d0f18f194b1a1b894aaf89
|
||||
1,1,vente,1,0.5,TVC_01,keyword,43598820dd270936c3d2fd822717d0f18f194b1a1b894aaf89
|
|
|
@ -1,5 +0,0 @@
|
|||
mots ... partner_owner_recid
|
||||
0 vendeur ... 43598820dd270936c3d2fd822717d0f18f194b1a1b894a...
|
||||
1 vente ... 43598820dd270936c3d2fd822717d0f18f194b1a1b894a...
|
||||
|
||||
[2 rows x 6 columns]
|
54
email_mgt.py
54
email_mgt.py
|
@ -27,6 +27,7 @@ from sib_api_v3_sdk.rest import ApiException
|
|||
import jinja2
|
||||
import strype_payement as strype_payement
|
||||
import ressources_humaines as ressources_humaines
|
||||
import email_queu.email_queu_mgt as email_queu_mgt
|
||||
|
||||
configuration = sib_api_v3_sdk.Configuration()
|
||||
configuration.api_key['api-key'] = MYSY_GV.SENDINBLUE_API_KEY
|
||||
|
@ -3294,7 +3295,7 @@ def Prepare_and_Send_Email_From_Front(tab_files, Folder, diction):
|
|||
"params": convention_dictionnary_data,
|
||||
}
|
||||
|
||||
# Creation de l'email à enoyer zzzz
|
||||
# Creation de l'email à enoyer
|
||||
msg = MIMEMultipart("alternative")
|
||||
contenu_doc_Template = jinja2.Template(str(diction['email_corps']))
|
||||
|
||||
|
@ -3559,8 +3560,6 @@ def Prepare_and_Send_Email_From_Front_For_Unknown_Contact(tab_files, Folder, dic
|
|||
# Creation de l'email à enoyer
|
||||
msg = MIMEMultipart("alternative")
|
||||
|
||||
|
||||
|
||||
node = {}
|
||||
node['nom'] = ""
|
||||
node['prenom'] = ""
|
||||
|
@ -3590,8 +3589,10 @@ def Prepare_and_Send_Email_From_Front_For_Unknown_Contact(tab_files, Folder, dic
|
|||
local_diction['tab_email_cc'] = tab_email_cc
|
||||
local_diction['tab_email_bcc'] = tab_email_bcc
|
||||
local_diction['tab_files_to_attache_to_mail'] = tab_files_to_attache_to_mail
|
||||
local_diction['tab_saved_file_full_path'] = tab_saved_file_full_path
|
||||
local_diction['email_sujet'] = email_sujet
|
||||
local_diction['html_mime'] = html_mime
|
||||
local_diction['initial_message'] = sourceHtml
|
||||
local_diction['email'] = str(local_email_dest)
|
||||
|
||||
local_status, local_retval = send_invidual_email (local_diction)
|
||||
|
@ -3650,10 +3651,21 @@ def send_invidual_email(diction):
|
|||
email = diction['email']
|
||||
user_id = diction['user_id']
|
||||
related_collection = diction['related_collection']
|
||||
include_client = diction['include_client']
|
||||
include_tuteur = diction['include_tuteur']
|
||||
include_client = diction['include_client']
|
||||
partner_owner_recid = diction['partner_owner_recid']
|
||||
|
||||
if( "include_tuteur" in diction.keys() ):
|
||||
include_tuteur = diction['include_tuteur']
|
||||
else:
|
||||
include_tuteur = ""
|
||||
|
||||
if ("include_client" in diction.keys()):
|
||||
include_client = diction['include_client']
|
||||
else:
|
||||
include_client = ""
|
||||
|
||||
if ("partner_owner_recid" in diction.keys()):
|
||||
partner_owner_recid = diction['partner_owner_recid']
|
||||
else:
|
||||
partner_owner_recid = ""
|
||||
|
||||
|
||||
# Recuperer les données tuteurs
|
||||
|
@ -3710,6 +3722,33 @@ def send_invidual_email(diction):
|
|||
|
||||
tab_email_bcc.append(str(my_partner['email']))
|
||||
|
||||
queue_mail_diction = {}
|
||||
queue_mail_diction['token'] = diction['token']
|
||||
queue_mail_diction['from'] = MYSY_GV.O365_SMTP_COUNT_From_User
|
||||
queue_mail_diction['cc'] = ",".join(tab_email_cc)
|
||||
queue_mail_diction['bcc'] = ",".join(tab_email_bcc)
|
||||
queue_mail_diction['subject'] = email_sujet
|
||||
queue_mail_diction['to'] = str(email)
|
||||
queue_mail_diction['message'] = diction['initial_message']
|
||||
|
||||
if( "tab_saved_file_full_path" in diction.keys() ):
|
||||
queue_mail_diction['tab_saved_file_full_path'] = diction['tab_saved_file_full_path']
|
||||
else:
|
||||
queue_mail_diction = []
|
||||
|
||||
queue_mail_diction['smtp_account_password'] = MYSY_GV.O365_SMTP_COUNT_password
|
||||
queue_mail_diction['smtp_account_smtpsrv'] = MYSY_GV.O365_SMTP_COUNT_smtpsrv
|
||||
queue_mail_diction['smtp_account_user'] = MYSY_GV.O365_SMTP_COUNT_user
|
||||
queue_mail_diction['smtp_account_From_User'] = MYSY_GV.O365_SMTP_COUNT_user
|
||||
queue_mail_diction['smtp_account_port'] = MYSY_GV.O365_SMTP_COUNT_port
|
||||
|
||||
|
||||
tab_files = []
|
||||
queue_mail_status, queue_mail_retval = email_queu_mgt.Add_Message_To_Mail_Queue(tab_files, queue_mail_diction)
|
||||
if( queue_mail_status is False):
|
||||
print(" ## WARNING queue_mail_retval = ", queue_mail_retval)
|
||||
|
||||
|
||||
if (str(partner_own_smtp_value) == "1"):
|
||||
msg.attach(html_mime)
|
||||
msg['From'] = partner_SMTP_COUNT_From_User
|
||||
|
@ -3726,6 +3765,7 @@ def send_invidual_email(diction):
|
|||
print(" Email a envoyé " + str(email))
|
||||
cpt_email_envoye = cpt_email_envoye + 1
|
||||
|
||||
|
||||
else:
|
||||
msg.attach(html_mime)
|
||||
msg['From'] = MYSY_GV.O365_SMTP_COUNT_From_User
|
||||
|
|
|
@ -61,7 +61,7 @@ def Add_Message_To_Mail_Queue(tab_files, diction):
|
|||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', 'from', 'cc', 'bcc', 'subject', 'to', 'message',
|
||||
field_list = ['token', 'from', 'cc', 'bcc', 'subject', 'to', 'message', 'tab_saved_file_full_path',
|
||||
'smtp_account_password', 'smtp_account_smtpsrv', 'smtp_account_user', 'smtp_account_From_User', 'smtp_account_port']
|
||||
|
||||
incom_keys = diction.keys()
|
||||
|
@ -74,7 +74,9 @@ def Add_Message_To_Mail_Queue(tab_files, diction):
|
|||
"""
|
||||
Verification des champs obligatoires
|
||||
"""
|
||||
field_list_obligatoire = ['token', 'from', 'cc', 'bcc', 'subject', 'to', 'message']
|
||||
field_list_obligatoire = ['token', 'from', 'cc', 'bcc', 'subject', 'to', 'message', 'tab_saved_file_full_path',
|
||||
'smtp_account_password', 'smtp_account_smtpsrv', 'smtp_account_user',
|
||||
'smtp_account_From_User', 'smtp_account_port']
|
||||
|
||||
for val in field_list_obligatoire:
|
||||
if val not in diction:
|
||||
|
@ -129,6 +131,8 @@ def Add_Message_To_Mail_Queue(tab_files, diction):
|
|||
|
||||
new_data['partner_owner_recid'] = str(my_partner['recid'])
|
||||
|
||||
print(" ### mail to store in queue = ", new_data)
|
||||
|
||||
inserted_id = MYSY_GV.dbname['mail_queue'].insert_one(new_data).inserted_id
|
||||
if (not inserted_id):
|
||||
mycommon.myprint(
|
||||
|
@ -155,7 +159,7 @@ def Update_Message_To_Mail_Queue(diction):
|
|||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', 'from', 'cc', 'bcc', 'subject', 'to', 'message', 'status', 'message_id',
|
||||
field_list = ['token', 'from', 'cc', 'bcc', 'subject', 'to', 'message', 'status', 'tab_message_id',
|
||||
'smtp_account_password', 'smtp_account_smtpsrv', 'smtp_account_user', 'smtp_account_From_User', 'smtp_account_port']
|
||||
|
||||
incom_keys = diction.keys()
|
||||
|
@ -168,7 +172,7 @@ def Update_Message_To_Mail_Queue(diction):
|
|||
"""
|
||||
Verification des champs obligatoires
|
||||
"""
|
||||
field_list_obligatoire = ['token', 'status', 'message_id']
|
||||
field_list_obligatoire = ['token', 'tab_message_id']
|
||||
|
||||
for val in field_list_obligatoire:
|
||||
if val not in diction:
|
||||
|
@ -189,43 +193,55 @@ def Update_Message_To_Mail_Queue(diction):
|
|||
if (local_status is not True):
|
||||
return local_status, my_partner
|
||||
|
||||
"""
|
||||
Verifier la validité du message
|
||||
"""
|
||||
is_massage_valide = MYSY_GV.dbname['mail_queue'].count_documents({'_id':ObjectId(str(diction['message_id'])),
|
||||
'valide':'1',
|
||||
'locked':'0',
|
||||
'partner_owner_recid':str(my_partner['recid']),
|
||||
'statut':{'$ne':'1'}})
|
||||
tab_message_id_split = str(diction['tab_message_id']).split(",")
|
||||
tab_message_id = []
|
||||
|
||||
if( is_massage_valide != 1):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " L'identifiant du message n'est pas valide ")
|
||||
return False, " L'identifiant du message n'est pas valide "
|
||||
for tmp in tab_message_id_split:
|
||||
if( tmp ):
|
||||
tab_message_id.append(tmp)
|
||||
|
||||
|
||||
local_id = str(diction['_id'])
|
||||
for local_message_id in tab_message_id :
|
||||
|
||||
"""
|
||||
Verifier la validité du message
|
||||
"""
|
||||
is_massage_valide = MYSY_GV.dbname['mail_queue'].count_documents({'_id':ObjectId(str(local_message_id)),
|
||||
'valide':'1',
|
||||
'locked':'0',
|
||||
'partner_owner_recid':str(my_partner['recid']),
|
||||
'statut':{'$ne':'1'}})
|
||||
|
||||
if( is_massage_valide != 1):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " L'identifiant du message "+str(local_message_id)+" n'est pas valide")
|
||||
return False, " L'identifiant du message "+str(local_message_id)+" n'est pas valide "
|
||||
|
||||
|
||||
del diction['token']
|
||||
del diction['_id']
|
||||
del diction['tab_message_id']
|
||||
|
||||
new_data = diction
|
||||
new_data['date_update'] = str(datetime.now())
|
||||
new_data['update_by'] = str(my_partner['_id'])
|
||||
|
||||
data_cle = {}
|
||||
data_cle['mail_queue'] = str(my_partner['recid'])
|
||||
data_cle['_id'] = ObjectId(local_id)
|
||||
data_cle['partner_owner_recid'] = str(my_partner['recid'])
|
||||
data_cle['statut'] = {'$ne': '1'}
|
||||
for local_message_id in tab_message_id:
|
||||
local_id = str(local_message_id)
|
||||
|
||||
|
||||
result = MYSY_GV.dbname['mail_queue'].find_one_and_update(
|
||||
data_cle,
|
||||
{"$set": new_data},
|
||||
upsert=False,
|
||||
return_document=ReturnDocument.AFTER
|
||||
)
|
||||
new_data = diction
|
||||
new_data['date_update'] = str(datetime.now())
|
||||
new_data['update_by'] = str(my_partner['_id'])
|
||||
|
||||
data_cle = {}
|
||||
data_cle['_id'] = ObjectId(local_id)
|
||||
data_cle['partner_owner_recid'] = str(my_partner['recid'])
|
||||
data_cle['statut'] = {'$ne': '1'}
|
||||
|
||||
print(" ### data_cle = ", data_cle)
|
||||
|
||||
result = MYSY_GV.dbname['mail_queue'].find_one_and_update(
|
||||
data_cle,
|
||||
{"$set": new_data},
|
||||
upsert=False,
|
||||
return_document=ReturnDocument.AFTER
|
||||
)
|
||||
|
||||
|
||||
return True, "Le message a été mis à jour"
|
||||
|
@ -371,10 +387,3 @@ def Get_List_Message_To_Mail_Queue(diction):
|
|||
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Cette fonction envoie les emails d'un avec des filtrer données
|
||||
filt_type_session = {}
|
||||
if ("type_session" in diction.keys()):
|
||||
filt_type_session = {'type_session': str(diction['type_session']).strip()}
|
||||
"""
|
||||
|
|
114
main.py
114
main.py
|
@ -4755,6 +4755,24 @@ def Delete_Given_Partner_Client():
|
|||
return jsonify(status=localStatus, message=message)
|
||||
|
||||
|
||||
"""
|
||||
API pou Suppression d'une LIST de clients
|
||||
1 - pas de stagiaire associé
|
||||
2 - Pas de devis associé
|
||||
3 - Pas de commande associé
|
||||
4 - Pas de contact associé
|
||||
"""
|
||||
@app.route('/myclass/api/Delete_List_Partner_Client/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Delete_List_Partner_Client():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Delete_List_Partner_Client : payload = ",payload)
|
||||
localStatus, message = partner_client.Delete_List_Partner_Client(payload)
|
||||
return jsonify(status=localStatus, message=message)
|
||||
|
||||
|
||||
|
||||
"""
|
||||
API de recupération de la liste des types de client
|
||||
"""
|
||||
|
@ -4896,6 +4914,33 @@ def Enable_Partner_Client_Intranet_Account():
|
|||
|
||||
|
||||
|
||||
"""
|
||||
API pour archiver une liste de clients
|
||||
"""
|
||||
@app.route('/myclass/api/archive_partner_client/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def archive_partner_client():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### archive_partner_client : payload = ",payload)
|
||||
localStatus, message = partner_client.archive_partner_client(payload)
|
||||
return jsonify(status=localStatus, message=message)
|
||||
|
||||
|
||||
"""
|
||||
API pour desarchiver une liste de clients
|
||||
"""
|
||||
@app.route('/myclass/api/unarchive_partner_client/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def unarchive_partner_client():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### unarchive_partner_client : payload = ",payload)
|
||||
localStatus, message = partner_client.unarchive_partner_client(payload)
|
||||
return jsonify(status=localStatus, message=message)
|
||||
|
||||
|
||||
|
||||
"""
|
||||
API qui permet de modifier un contact donnée (nested list) d'un client de partenaire
|
||||
"""
|
||||
|
@ -10536,6 +10581,17 @@ def Internal_Global_MySy_Cron_Traitement():
|
|||
return True
|
||||
|
||||
|
||||
"""
|
||||
Fonction cron d'envoi des emails
|
||||
"""
|
||||
def Internal_Global_MySy_Cron_Email_Traitement():
|
||||
mycommon.myprint(" ### CRONNN Internal_Global_MySy_Cron_Email_Traitement : payload = ")
|
||||
print(" ### CRONNN Internal_Global_MySy_Cron_Email_Traitement : payload = ")
|
||||
status, retval = Job_Cron.Cron_Send_Mail_Queue_Message_With_Filter()
|
||||
print(" FIN traitement Internal_Global_MySy_Cron_Email_Traitement localStatus = ", status)
|
||||
return True
|
||||
|
||||
|
||||
|
||||
""""
|
||||
Test cron qui fait les relance des questionnaire non repondu (position, eval, etc)
|
||||
|
@ -11410,6 +11466,32 @@ def Update_LMS_Inscrition_End_Date():
|
|||
|
||||
|
||||
|
||||
"""
|
||||
API pour archiver une inscription
|
||||
"""
|
||||
@app.route('/myclass/api/archive_stagiaire/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def archive_stagiaire():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### archive_stagiaire payload = ",payload)
|
||||
status, retval = inscription.archive_stagiaire(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
|
||||
"""
|
||||
API pour desarchiver une inscription
|
||||
"""
|
||||
@app.route('/myclass/api/unarchive_stagiaire/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def unarchive_stagiaire():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### unarchive_stagiaire payload = ",payload)
|
||||
status, retval = inscription.unarchive_stagiaire(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
"""
|
||||
API qui recuperer les reponses d'un survey donné dans une fichier pdf
|
||||
|
@ -12378,6 +12460,7 @@ def Get_Given_base_document_automatic_setup():
|
|||
localStatus, message= base_document_automatic_setup.Get_Given_base_document_automatic_setup(payload)
|
||||
return jsonify(status=localStatus, message=message )
|
||||
|
||||
|
||||
"""
|
||||
API de test du cron qui va traiter automatiquement les documents à envoyer
|
||||
"""
|
||||
|
@ -12391,6 +12474,24 @@ def Cron_Daily_Automatic_Qualiopi_Documents():
|
|||
return jsonify(status=status, message="OK" )
|
||||
|
||||
|
||||
|
||||
"""
|
||||
API qui permet d'envoyer les emails qui sont dans file d'attente des emails
|
||||
"""
|
||||
@app.route('/myclass/api/Cron_Send_Mail_Queue_Message_With_Filter/', methods=['POST', 'GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Cron_Send_Mail_Queue_Message_With_Filter():
|
||||
payload = mycommon.strip_dictionary(request.form.to_dict())
|
||||
print(" ### CRONNN Cron_Send_Mail_Queue_Message_With_Filter : payload = ", payload)
|
||||
status, retval = Job_Cron.Cron_Send_Mail_Queue_Message_With_Filter(payload)
|
||||
print(" FIN traitement Cron_Send_Mail_Queue_Message_With_Filter status = ", status)
|
||||
|
||||
return jsonify(status=status, message=retval )
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
"""
|
||||
API de suppression d'un compte pour nicole
|
||||
"""
|
||||
|
@ -13562,7 +13663,7 @@ def Get_List_Message_To_Mail_Queue():
|
|||
if __name__ == '__main__':
|
||||
print(" debut api")
|
||||
|
||||
print(" sdqsdqs app.coapp.config['MAX_CONTENT_LENGTH'] = ", app.config['MAX_CONTENT_LENGTH'])
|
||||
print(" sdqsdqs app.config['MAX_CONTENT_LENGTH'] = ", app.config['MAX_CONTENT_LENGTH'])
|
||||
context = SSL.Context(SSL.SSLv23_METHOD)
|
||||
if (MYSY_GV.MYSY_ENV == "PROD"):
|
||||
mycommon.myprint(" ++++ ENVIRONNEMENT PRODUCTION ++++ ")
|
||||
|
@ -13579,6 +13680,8 @@ if __name__ == '__main__':
|
|||
mycommon.myprint("++ FLASK PORT " + str(MYSY_GV.MYSY_PORT_DEV) + " ++")
|
||||
mycommon.myprint("++ LMS_BAS_URL " + str(MYSY_GV.LMS_BAS_URL) + " ++")
|
||||
|
||||
|
||||
|
||||
"""
|
||||
WARNING Dasactivé en dev pour pas consommer de ressource pr rien.
|
||||
"""
|
||||
|
@ -13587,6 +13690,8 @@ if __name__ == '__main__':
|
|||
# Create the job
|
||||
scheduler.add_job(func=Flask_Cron_Strip_Get_Customer_Abonnement_Data, trigger="interval", minutes=3)
|
||||
scheduler.add_job(func=Internal_Global_MySy_Cron_Traitement, trigger="interval", minutes=1)
|
||||
# Cron des email toutes les heures
|
||||
scheduler.add_job(func=Cron_Send_Mail_Queue_Message_With_Filter, trigger="interval", hours=1)
|
||||
|
||||
print(" ### scheduler.print_jobs() = ", scheduler.print_jobs())
|
||||
# Start the scheduler
|
||||
|
@ -13613,6 +13718,8 @@ if __name__ == '__main__':
|
|||
|
||||
scheduler.add_job(func=Flask_Cron_Strip_Get_Customer_Abonnement_Data, trigger="interval", hours=22)
|
||||
scheduler.add_job(func=Internal_Global_MySy_Cron_Traitement, trigger="interval", hours=22)
|
||||
# Cron des email toutes les heures
|
||||
#scheduler.add_job(func=Cron_Send_Mail_Queue_Message_With_Filter, trigger="interval", hours=1)
|
||||
|
||||
# Start the scheduler
|
||||
scheduler.start()
|
||||
|
@ -13636,6 +13743,11 @@ if __name__ == '__main__':
|
|||
#scheduler.add_job(func=Flask_Cron_Strip_Get_Customer_Abonnement_Data, trigger="interval", minutes=50)
|
||||
scheduler.add_job(func=Flask_Cron_Strip_Get_Customer_Abonnement_Data, trigger="interval", hours=22)
|
||||
scheduler.add_job(func=Internal_Global_MySy_Cron_Traitement, trigger="interval", hours=1)
|
||||
# Cron des email toutes les heures
|
||||
#scheduler.add_job(func=Cron_Send_Mail_Queue_Message_With_Filter, trigger="interval", hours=1)
|
||||
|
||||
|
||||
|
||||
# Start the scheduler
|
||||
scheduler.start()
|
||||
|
||||
|
|
|
@ -51,11 +51,10 @@ def Add_Partner_Client(diction):
|
|||
'is_fournisseur', 'is_client', 'is_financeur', 'is_company', 'invoice_automatique',
|
||||
'type_financeur_id', 'type_pouvoir_public_id', 'partner_groupe_client_id',
|
||||
|
||||
'is_compagnie',
|
||||
'contact_civilite', 'contact_nom', 'contact_prenom', 'contact_email', 'is_contact_communication',
|
||||
'contact_fonction', 'contact_mobile', 'contact_phone', 'contact_adresse', 'contact_code_postal',
|
||||
'contact_ville',
|
||||
'contact_pays', 'contact_siret', 'contact_tva']
|
||||
'contact_pays', 'contact_siret', 'contact_tva', 'archive']
|
||||
|
||||
|
||||
|
||||
|
@ -153,6 +152,12 @@ def Add_Partner_Client(diction):
|
|||
siret = diction['siret']
|
||||
data['siret'] = siret
|
||||
|
||||
if ("archive" in diction.keys()):
|
||||
data['archive'] = str(diction['archive'])
|
||||
else:
|
||||
data['archive'] = "0"
|
||||
|
||||
|
||||
client_type_id = ""
|
||||
if ("client_type_id" in diction.keys()):
|
||||
if diction['client_type_id']:
|
||||
|
@ -163,6 +168,7 @@ def Add_Partner_Client(diction):
|
|||
if ("is_company" in diction.keys()):
|
||||
if diction['is_company']:
|
||||
is_company = diction['is_company']
|
||||
is_company = str(mycommon.tryInt(is_company))
|
||||
data['is_company'] = is_company
|
||||
|
||||
invoice_automatique = ""
|
||||
|
@ -430,7 +436,6 @@ def Add_Partner_Client(diction):
|
|||
" Impossible de créer le client du partner ")
|
||||
return False, " Impossible de créer le client "
|
||||
|
||||
|
||||
"""
|
||||
Si l'ajout du client a réussi, alors on ajoute le contact s'il y a un contact fourni
|
||||
"""
|
||||
|
@ -638,6 +643,9 @@ def Add_Partner_Prospect(diction):
|
|||
siret = diction['siret']
|
||||
data['siret'] = siret
|
||||
|
||||
data['archive'] = "0"
|
||||
|
||||
|
||||
client_type_id = ""
|
||||
if ("client_type_id" in diction.keys()):
|
||||
if diction['client_type_id']:
|
||||
|
@ -963,6 +971,8 @@ def Update_Partner_Client_Contact(diction):
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
email = ""
|
||||
if ("email" in diction.keys()):
|
||||
email = diction['email']
|
||||
|
@ -1027,7 +1037,7 @@ def Update_Partner_Client(diction):
|
|||
'invoice_tva','invoice_condition_paiement_id', 'invoice_adresse', 'invoice_ville',
|
||||
'invoice_code_postal', 'invoice_pays', 'client_type_id',
|
||||
'is_fournisseur', 'is_client', 'is_financeur', 'is_company', 'invoice_automatique',
|
||||
'type_financeur_id', 'type_pouvoir_public_id', 'partner_groupe_client_id']
|
||||
'type_financeur_id', 'type_pouvoir_public_id', 'partner_groupe_client_id', 'archive']
|
||||
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
|
@ -1109,6 +1119,11 @@ def Update_Partner_Client(diction):
|
|||
data_update['nom'] = diction['nom']
|
||||
|
||||
|
||||
archive = ""
|
||||
if ("archive" in diction.keys()):
|
||||
data_update['archive'] = diction['archive']
|
||||
|
||||
|
||||
if ("invoice_automatique" in diction.keys()):
|
||||
data_update['invoice_automatique'] = diction['invoice_automatique']
|
||||
|
||||
|
@ -1392,7 +1407,7 @@ def Get_Partner_List_Partner_Client(diction):
|
|||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token',]
|
||||
field_list = ['token', 'archive']
|
||||
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
|
@ -1432,6 +1447,13 @@ def Get_Partner_List_Partner_Client(diction):
|
|||
mycommon.myprint(str(inspect.stack()[0][3]) + " - impossible de récupérer les données de l'utilisateur")
|
||||
return False, str(inspect.stack()[0][3]) + " - impossible de récupérer les données de l'utilisateur. "
|
||||
|
||||
filt_archive = {}
|
||||
if ("archive" in diction.keys() and (diction["archive"] == "0" or diction["archive"] == "")):
|
||||
filt_archive = {'archive': {'$ne': '1'}}
|
||||
|
||||
elif ("archive" in diction.keys() and diction["archive"] == "1"):
|
||||
filt_archive = {'archive': '1'}
|
||||
|
||||
"""
|
||||
Clés de mise à jour
|
||||
"""
|
||||
|
@ -1444,10 +1466,13 @@ def Get_Partner_List_Partner_Client(diction):
|
|||
RetObject = []
|
||||
val_tmp = 1
|
||||
|
||||
for retval in MYSY_GV.dbname['partner_client'].find(data_cle).sort([("_id", pymongo.DESCENDING), ]):
|
||||
for retval in MYSY_GV.dbname['partner_client'].find({"$and":[data_cle, filt_archive]}).sort([("_id", pymongo.DESCENDING), ]):
|
||||
user = retval
|
||||
user['id'] = str(val_tmp)
|
||||
|
||||
if ("archive" not in retval.keys() ):
|
||||
user['archive'] = "0"
|
||||
|
||||
if( "invoice_condition_paiement_id" not in retval.keys() ):
|
||||
user['invoice_condition_paiement_id'] = ""
|
||||
|
||||
|
@ -1505,7 +1530,8 @@ def Get_Partner_List_Partner_Client_with_filter_Like(diction):
|
|||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', 'raison_sociale', 'nom', 'email',
|
||||
'is_client', 'is_financeur', 'is_fournisseur']
|
||||
'is_client', 'is_financeur', 'is_fournisseur',
|
||||
'archive']
|
||||
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
|
@ -1537,6 +1563,17 @@ def Get_Partner_List_Partner_Client_with_filter_Like(diction):
|
|||
if (local_status is not True):
|
||||
return local_status, my_partner
|
||||
|
||||
filt_archive = {}
|
||||
if ("archive" in diction.keys() and (diction["archive"] == "0" or diction["archive"] == "")):
|
||||
filt_archive = {'archive': {'$ne': '1'}}
|
||||
|
||||
elif ("archive" in diction.keys() and diction["archive"] == "1"):
|
||||
filt_archive = {'archive': '1'}
|
||||
|
||||
elif ("archive" not in diction.keys()):
|
||||
filt_archive = {'archive': {'$ne': '1'}}
|
||||
|
||||
|
||||
|
||||
filt_raison_sociale = {}
|
||||
if ("raison_sociale" in diction.keys()):
|
||||
|
@ -1565,7 +1602,7 @@ def Get_Partner_List_Partner_Client_with_filter_Like(diction):
|
|||
|
||||
filt_class_partner_recid = {'partner_owner_recid': str(my_partner['recid'])}
|
||||
|
||||
qry = {'$and': [filt_raison_sociale, filt_email, filt_nom, filt_client_is_client,
|
||||
qry = {'$and': [filt_archive, filt_raison_sociale, filt_email, filt_nom, filt_client_is_client,
|
||||
filt_client_is_financeur,filt_client_is_fournisseur, {'partner_owner_recid': str(my_partner['recid'])}
|
||||
]
|
||||
}
|
||||
|
@ -1582,6 +1619,9 @@ def Get_Partner_List_Partner_Client_with_filter_Like(diction):
|
|||
user['id'] = str(val_tmp)
|
||||
val_tmp = val_tmp + 1
|
||||
|
||||
if ("archive" not in New_retVal.keys()):
|
||||
user['user'] = "0"
|
||||
|
||||
if ("is_financeur" not in New_retVal.keys()):
|
||||
user['is_financeur'] = 0
|
||||
|
||||
|
@ -1687,7 +1727,6 @@ def Get_Given_Partner_Client(diction):
|
|||
RetObject = []
|
||||
val_tmp = 1
|
||||
|
||||
print(" ### data_cle 1 = ", data_cle)
|
||||
for retval in MYSY_GV.dbname['partner_client'].find(data_cle):
|
||||
user = retval
|
||||
user['id'] = str(val_tmp)
|
||||
|
@ -1721,6 +1760,10 @@ def Get_Given_Partner_Client(diction):
|
|||
if ("type_financeur_id" not in retval.keys()):
|
||||
user['type_financeur_id'] = ""
|
||||
|
||||
if ("archive" not in retval.keys()):
|
||||
user['archive'] = "0"
|
||||
|
||||
|
||||
if ("type_pouvoir_public_id" not in retval.keys()):
|
||||
user['type_pouvoir_public_id'] = ""
|
||||
|
||||
|
@ -1848,6 +1891,9 @@ def Get_Given_Partner_Client_From_Id(diction):
|
|||
if( "invoice_automatique" not in retval.keys() ):
|
||||
user['invoice_automatique'] = ""
|
||||
|
||||
if ("archive" not in retval.keys()):
|
||||
user['archive'] = "0"
|
||||
|
||||
if ("type_financeur_id" not in retval.keys()):
|
||||
user['type_financeur_id'] = ""
|
||||
|
||||
|
@ -2073,6 +2119,8 @@ def Add_Partner_Client_mass(file=None, Folder=None, diction=None):
|
|||
invoice_ville = str(df['invoice_ville'].values[n])
|
||||
mydata['invoice_ville'] = invoice_ville
|
||||
|
||||
|
||||
|
||||
invoice_pays = ""
|
||||
if ("invoice_pays" in df.keys()):
|
||||
if (str(df['invoice_pays'].values[n])):
|
||||
|
@ -2129,28 +2177,34 @@ def Add_Partner_Client_mass(file=None, Folder=None, diction=None):
|
|||
client_type_id = str(is_valide_type_client_data['_id'])
|
||||
mydata['client_type_id'] = client_type_id
|
||||
|
||||
is_compagnie = ""
|
||||
is_company = ""
|
||||
if ("is_compagnie" in df.keys()):
|
||||
if (str(df['is_compagnie'].values[n])):
|
||||
is_compagnie = str(df['is_compagnie'].values[n])
|
||||
mydata['is_compagnie'] = is_compagnie
|
||||
is_company = str(df['is_compagnie'].values[n])
|
||||
is_company = str(mycommon.tryInt(is_company))
|
||||
|
||||
mydata['is_company'] = is_company
|
||||
|
||||
is_fournisseur = ""
|
||||
if ("is_fournisseur" in df.keys()):
|
||||
if (str(df['is_fournisseur'].values[n])):
|
||||
is_fournisseur = str(df['is_fournisseur'].values[n])
|
||||
is_fournisseur = str(mycommon.tryInt(is_fournisseur))
|
||||
|
||||
mydata['is_fournisseur'] = is_fournisseur
|
||||
|
||||
is_client = ""
|
||||
if ("is_client" in df.keys()):
|
||||
if (str(df['is_client'].values[n])):
|
||||
is_client = str(df['is_client'].values[n])
|
||||
is_client = str(mycommon.tryInt(is_client))
|
||||
mydata['is_client'] = is_client
|
||||
|
||||
is_financeur = ""
|
||||
if ("is_financeur" in df.keys()):
|
||||
if (str(df['is_financeur'].values[n])):
|
||||
is_financeur = str(df['is_financeur'].values[n])
|
||||
is_financeur = str(mycommon.tryInt(is_financeur))
|
||||
mydata['is_financeur'] = is_financeur
|
||||
|
||||
|
||||
|
@ -2196,6 +2250,7 @@ def Add_Partner_Client_mass(file=None, Folder=None, diction=None):
|
|||
if ("is_contact_communication" in df.keys()):
|
||||
if (str(df['is_contact_communication'].values[n])):
|
||||
is_contact_communication = str(df['is_contact_communication'].values[n])
|
||||
is_contact_communication = str(mycommon.tryInt(is_contact_communication))
|
||||
mydata['is_contact_communication'] = is_contact_communication
|
||||
|
||||
|
||||
|
@ -2401,12 +2456,14 @@ def Controle_Add_Partner_Client_mass(saved_file=None, Folder=None, diction=None)
|
|||
if (mycommon.isEmailValide(contact_email) is False):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + "Le champ 'contact_email' pour la ligne "+str( n + 2) +" est invalide.")
|
||||
return False, "Le champ 'contact_email' pour la ligne "+str( n + 2) +" est invalide"
|
||||
3]) + "Le champ 'contact_email' pour la ligne "+str( n + 2) +" est invalide. contact_email = "+str(contact_email))
|
||||
return False, "Le champ 'contact_email' pour la ligne "+str( n + 2) +" est invalide. contact_email = "+str(contact_email)
|
||||
|
||||
# Contoler is_contact_communication
|
||||
if ("is_contact_communication" in df.keys()):
|
||||
is_contact_communication = str(df['is_contact_communication'].values[n]).strip()
|
||||
is_contact_communication = str(mycommon.tryInt(is_contact_communication))
|
||||
|
||||
if (is_contact_communication not in ['0', '1', '']):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
|
@ -2436,6 +2493,8 @@ def Controle_Add_Partner_Client_mass(saved_file=None, Folder=None, diction=None)
|
|||
# Controle du champ 'is_compagnie':
|
||||
if ("is_compagnie" in df.keys()):
|
||||
is_compagnie = str(df['is_compagnie'].values[n]).strip()
|
||||
is_compagnie = str(mycommon.tryInt(is_compagnie))
|
||||
|
||||
if (is_compagnie not in ['0', '1', '2', '']):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
|
@ -2445,6 +2504,8 @@ def Controle_Add_Partner_Client_mass(saved_file=None, Folder=None, diction=None)
|
|||
# Controle du champ 'is_fournisseur':
|
||||
if ("is_fournisseur" in df.keys()):
|
||||
is_fournisseur = str(df['is_fournisseur'].values[n]).strip()
|
||||
is_fournisseur = str(mycommon.tryInt(is_fournisseur))
|
||||
|
||||
if (is_fournisseur not in ['0', '1', '']):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
|
@ -2456,6 +2517,7 @@ def Controle_Add_Partner_Client_mass(saved_file=None, Folder=None, diction=None)
|
|||
# Controle du champ 'is_client':
|
||||
if ("is_client" in df.keys()):
|
||||
is_client = str(df['is_client'].values[n]).strip()
|
||||
is_client = str(mycommon.tryInt(is_client))
|
||||
if (is_client not in ['0', '1', '']):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
|
@ -2468,6 +2530,8 @@ def Controle_Add_Partner_Client_mass(saved_file=None, Folder=None, diction=None)
|
|||
# Controle du champ 'is_financeur':
|
||||
if ("is_financeur" in df.keys()):
|
||||
is_financeur = str(df['is_financeur'].values[n]).strip()
|
||||
is_financeur = str(mycommon.tryInt(is_financeur))
|
||||
|
||||
if (is_financeur not in ['0', '1', '']):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
|
@ -2633,6 +2697,120 @@ def Delete_Given_Partner_Client(diction):
|
|||
return False, " Impossible de supprimer le client "
|
||||
|
||||
|
||||
"""
|
||||
Suppression d'une liste de clients
|
||||
1 - pas de stagiaire associé
|
||||
2 - Pas de devis associé
|
||||
3 - Pas de commande associé
|
||||
4 - Pas de contact associé
|
||||
"""
|
||||
|
||||
def Delete_List_Partner_Client(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', 'tab_ids']
|
||||
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
if val not in field_list and val.startswith('my_') is False:
|
||||
mycommon.myprint(str(
|
||||
inspect.stack()[0][3]) + " Le champ '" + val + "' n'existe pas")
|
||||
return False, " Les informations fournies sont incorrectes",
|
||||
|
||||
"""
|
||||
Verification des champs obligatoires
|
||||
"""
|
||||
field_list_obligatoire = ['token','tab_ids' ]
|
||||
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 la liste des arguments ")
|
||||
return False, " Les informations fournies sont incorrectes",
|
||||
|
||||
"""
|
||||
Verification de l'identité et autorisation de l'entité qui
|
||||
appelle cette API
|
||||
"""
|
||||
token = ""
|
||||
if ("token" in diction.keys()):
|
||||
if diction['token']:
|
||||
token = diction['token']
|
||||
|
||||
local_status, my_partner = mycommon.Check_Connexion_And_Return_Partner_Data(diction)
|
||||
if (local_status is not True):
|
||||
return local_status, my_partner
|
||||
|
||||
tab_ids_work = str(diction['tab_ids']).split(",")
|
||||
tab_ids = []
|
||||
tab_ids_ObjectId = []
|
||||
for tmp in tab_ids_work :
|
||||
if( tmp ):
|
||||
tab_ids.append(tmp)
|
||||
tab_ids_ObjectId.append(ObjectId(str(tmp)))
|
||||
|
||||
|
||||
for client_id in tab_ids :
|
||||
# Verification de la validé du client
|
||||
is_existe_client_count = MYSY_GV.dbname['partner_client'].count_documents({'_id':ObjectId(str(client_id)), 'partner_owner_recid':str(my_partner['recid'])})
|
||||
if( is_existe_client_count <= 0 ):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " - Le client n'est pas valide ")
|
||||
return False, " - Le client n'est pas valide ",
|
||||
|
||||
if (is_existe_client_count > 1 ):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " - Plusieurs clients ont le même identifiant. Suppression annulée")
|
||||
return False, " - Plusieurs clients ont le même identifiant. Suppression annulée",
|
||||
|
||||
|
||||
# Verifier qu'il n'y pas de stagiaire associé
|
||||
is_Stagiaire_Count = MYSY_GV.dbname['inscription'].count_documents({'client_rattachement_id':str(client_id),
|
||||
'partner_owner_recid':str(my_partner['recid']),
|
||||
'valide':'1'})
|
||||
if( is_Stagiaire_Count > 0 ):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " - Le client a "+str(is_Stagiaire_Count)+" stagiaire(s) valide(s). Suppression annulée ")
|
||||
return False, " - Le client a "+str(is_Stagiaire_Count)+" stagiaire(s) valide(s). Suppression annulée ",
|
||||
|
||||
# Verifier qu'il n'y pas de devis ou commande associé
|
||||
is_devis_cmd_Count = MYSY_GV.dbname['partner_order_header'].count_documents(
|
||||
{'order_header_client_id': str(client_id),
|
||||
'partner_owner_recid': str(my_partner['recid']),
|
||||
'valide': '1'})
|
||||
if (is_devis_cmd_Count > 0):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " - Le client a " + str(
|
||||
is_devis_cmd_Count) + " commande(s) ou devis valide(s). Suppression annulée ")
|
||||
return False, " - Le client a " + str(
|
||||
is_devis_cmd_Count) + " commande(s) ou devis valide(s). Suppression annulée"
|
||||
|
||||
|
||||
# Supression à contact
|
||||
MYSY_GV.dbname['contact'].delete_many(
|
||||
{'related_collection':'partner_client',
|
||||
'related_collection_recid':{'$in':tab_ids},
|
||||
'partner_recid': str(my_partner['recid'])}
|
||||
)
|
||||
|
||||
|
||||
# Supression à faire
|
||||
MYSY_GV.dbname['partner_client'].delete_many({'_id':{'$in':tab_ids_ObjectId}, 'partner_owner_recid':str(my_partner['recid'])})
|
||||
|
||||
return True, "La suppression a été correctement faite."
|
||||
|
||||
|
||||
except Exception as e:
|
||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - Line : " + str(exc_tb.tb_lineno))
|
||||
return False, " Suppression impossible "
|
||||
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Recuperation de la liste des type de client
|
||||
"""
|
||||
|
@ -2769,7 +2947,10 @@ def Add_Client_Type(diction):
|
|||
return False, " Ce code existe déjà pour un type de client",
|
||||
|
||||
if( "is_fournisseur" in diction.keys() and diction['is_fournisseur']) :
|
||||
if ( str(diction['is_fournisseur']) not in ['0', '1'] ):
|
||||
is_fournisseur = str(diction['is_fournisseur'])
|
||||
is_fournisseur = str(mycommon.tryInt(is_fournisseur))
|
||||
|
||||
if ( is_fournisseur not in ['0', '1'] ):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " Est Fournisseur : La valeur " + str(diction['is_fournisseur']) + " n'est pas autorisée. Les valeurs admises sont : 0, 1 ")
|
||||
return False, " Est Fournisseur : La valeur " + str(diction['is_fournisseur']) + " n'est pas autorisée. Les valeurs admises sont : 0, 1 "
|
||||
|
@ -3772,3 +3953,195 @@ def Enable_Partner_Client_Intranet_Account(diction):
|
|||
return False, " Impossible de créer le compte intranet du client "
|
||||
|
||||
|
||||
"""
|
||||
02/06/2025 : Archivage d'un client
|
||||
"""
|
||||
def archive_partner_client(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 = ['tab_partner_client_ids', 'token']
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
if val not in field_list and val.startswith('my_') is False:
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3])+" - Le champ '" + val + "' n'existe pas, Creation formation annulée")
|
||||
return False, " Impossible de mettre à jour la formation"
|
||||
|
||||
'''
|
||||
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 = ['tab_partner_client_ids', 'token']
|
||||
|
||||
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 la liste des arguments ")
|
||||
return False, " Impossible de mettre à jour la formation"
|
||||
|
||||
# recuperation des paramettre
|
||||
mydata = {}
|
||||
my_internal_url = ""
|
||||
|
||||
if ("token" in diction.keys()):
|
||||
if diction['token']:
|
||||
mydata['token'] = diction['token']
|
||||
|
||||
# Verification de la validité du token
|
||||
tab_partner_client_ids = []
|
||||
tab_partner_client_ids_ObjectId = []
|
||||
if ("tab_partner_client_ids" in diction.keys()):
|
||||
tab_partner_client_ids = str(diction['tab_partner_client_ids']).split(",")
|
||||
|
||||
for tmp in tab_partner_client_ids:
|
||||
if (tmp):
|
||||
tab_partner_client_ids_ObjectId.append(ObjectId(tmp))
|
||||
|
||||
# Verification de la validité du token
|
||||
local_status, my_partner = mycommon.Check_Connexion_And_Return_Partner_Data(diction)
|
||||
if (local_status is not True):
|
||||
return local_status, my_partner
|
||||
|
||||
mydata['date_update'] = str(datetime.now())
|
||||
mydata['update_by'] = str(my_partner['_id'])
|
||||
mydata['archive'] = '1'
|
||||
|
||||
|
||||
# seules les formations avec locked = 0 et valide=1 sont modifiables
|
||||
ret_val = MYSY_GV.dbname['partner_client'].update_many(
|
||||
{'_id': {'$in': tab_partner_client_ids_ObjectId}, 'valide': '1',
|
||||
'partner_owner_recid': str(my_partner['recid'])},
|
||||
{"$set": mydata},
|
||||
|
||||
)
|
||||
|
||||
for partner_client_id in tab_partner_client_ids:
|
||||
# pour la collection 'myclass'
|
||||
now = str(datetime.now().strftime("%d/%m/%Y %H:%M:%S"))
|
||||
# print(" ####### laaaa diction = ", diction)
|
||||
|
||||
history_event_dict = {}
|
||||
history_event_dict['token'] = str(diction['token'])
|
||||
history_event_dict['related_collection'] = "partner_client"
|
||||
history_event_dict['related_collection_recid'] = str(partner_client_id)
|
||||
history_event_dict['action_date'] = str(now)
|
||||
|
||||
history_event_dict['action_description'] = "Archivage "
|
||||
local_status, local_retval = mycommon.Collection_Historique.Add_Historique_Event(history_event_dict)
|
||||
if (local_status is False):
|
||||
mycommon.myprint(
|
||||
" WARNING : Impossible de logguer l'historique pour l'évènement : " + str(history_event_dict))
|
||||
|
||||
return True, " Client(s) archivé(s) "
|
||||
|
||||
|
||||
except Exception as e:
|
||||
|
||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - Line : " + str(exc_tb.tb_lineno))
|
||||
|
||||
return False, " Impossible d'archiver les clients "
|
||||
|
||||
|
||||
"""
|
||||
02/06/2025 : De-Archivage d'un client
|
||||
"""
|
||||
def unarchive_partner_client(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 = ['tab_partner_client_ids', 'token']
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
if val not in field_list and val.startswith('my_') is False:
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3])+" - Le champ '" + val + "' n'existe pas, Creation formation annulée")
|
||||
return False, " Impossible de mettre à jour la formation"
|
||||
|
||||
'''
|
||||
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 = ['tab_partner_client_ids', 'token']
|
||||
|
||||
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 la liste des arguments ")
|
||||
return False, " Impossible de mettre à jour la formation"
|
||||
|
||||
# recuperation des paramettre
|
||||
mydata = {}
|
||||
my_internal_url = ""
|
||||
|
||||
if ("token" in diction.keys()):
|
||||
if diction['token']:
|
||||
mydata['token'] = diction['token']
|
||||
|
||||
# Verification de la validité du token
|
||||
tab_partner_client_ids = []
|
||||
tab_partner_client_ids_ObjectId = []
|
||||
if ("tab_partner_client_ids" in diction.keys()):
|
||||
tab_partner_client_ids = str(diction['tab_partner_client_ids']).split(",")
|
||||
|
||||
for tmp in tab_partner_client_ids:
|
||||
if (tmp):
|
||||
tab_partner_client_ids_ObjectId.append(ObjectId(tmp))
|
||||
|
||||
# Verification de la validité du token
|
||||
local_status, my_partner = mycommon.Check_Connexion_And_Return_Partner_Data(diction)
|
||||
if (local_status is not True):
|
||||
return local_status, my_partner
|
||||
|
||||
mydata['date_update'] = str(datetime.now())
|
||||
mydata['update_by'] = str(my_partner['_id'])
|
||||
mydata['archive'] = '0'
|
||||
|
||||
|
||||
|
||||
# seules les formations avec locked = 0 et valide=1 sont modifiables
|
||||
ret_val = MYSY_GV.dbname['partner_client'].update_many(
|
||||
{'_id': {'$in': tab_partner_client_ids_ObjectId}, 'valide': '1',
|
||||
'partner_owner_recid': str(my_partner['recid'])},
|
||||
{"$set": mydata},
|
||||
|
||||
)
|
||||
|
||||
for partner_client_id in tab_partner_client_ids:
|
||||
# pour la collection 'myclass'
|
||||
now = str(datetime.now().strftime("%d/%m/%Y %H:%M:%S"))
|
||||
# print(" ####### laaaa diction = ", diction)
|
||||
|
||||
history_event_dict = {}
|
||||
history_event_dict['token'] = str(diction['token'])
|
||||
history_event_dict['related_collection'] = "partner_client"
|
||||
history_event_dict['related_collection_recid'] = str(partner_client_id)
|
||||
history_event_dict['action_date'] = str(now)
|
||||
|
||||
history_event_dict['action_description'] = "Desarchivage "
|
||||
local_status, local_retval = mycommon.Collection_Historique.Add_Historique_Event(history_event_dict)
|
||||
if (local_status is False):
|
||||
mycommon.myprint(
|
||||
" WARNING : Impossible de logguer l'historique pour l'évènement : " + str(history_event_dict))
|
||||
|
||||
return True, " Client(s) desarchivée(s) "
|
||||
|
||||
|
||||
except Exception as e:
|
||||
|
||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - Line : " + str(exc_tb.tb_lineno))
|
||||
|
||||
return False, " Impossible d'archiver les clients "
|
||||
|
||||
|
|
202
prj_common.py
202
prj_common.py
|
@ -3324,6 +3324,7 @@ def GetAttendeeDetail_perSession(diction):
|
|||
|
||||
if ('inscription_collectoin' in local_Insc_retval.keys() and len(local_Insc_retval['inscription_collectoin']) > 0):
|
||||
|
||||
|
||||
if ("session_id" in local_Insc_retval.keys()):
|
||||
my_retrun_dict['session_id'] = local_Insc_retval['session_id']
|
||||
|
||||
|
@ -3350,6 +3351,7 @@ def GetAttendeeDetail_perSession(diction):
|
|||
my_retrun_dict['date_naissance'] = ""
|
||||
|
||||
|
||||
|
||||
if ("code_session" in local_Insc_retval['inscription_collectoin'][0].keys()):
|
||||
my_retrun_dict['code_session'] = str(local_Insc_retval['inscription_collectoin'][0]['code_session'])
|
||||
|
||||
|
@ -3559,6 +3561,12 @@ def GetAttendeeDetail_perSession(diction):
|
|||
local_opco = local_Insc_retval['opco']
|
||||
my_retrun_dict['opco'] = local_opco
|
||||
|
||||
local_archive = "0"
|
||||
if ("archive" in local_Insc_retval.keys()):
|
||||
local_archive = local_Insc_retval['archive']
|
||||
my_retrun_dict['archive'] = local_archive
|
||||
|
||||
|
||||
# Recuperation des champs spécifiques se trouvant dans le dictionnaire. ils commencent tous par 'my_'
|
||||
for val in local_Insc_retval.keys():
|
||||
if (val.startswith('my_')):
|
||||
|
@ -3652,195 +3660,6 @@ def GetAttendeeDetail_perSession(diction):
|
|||
|
||||
|
||||
|
||||
"""
|
||||
Important : : 28/12/2023 - update
|
||||
S'il y a de la data dans la collection 'apprenant_collection' cela veut dire qu'il y a un dossier apprenant,
|
||||
alors on va plutot retourner les info qui sont dans cette collection
|
||||
"""
|
||||
"""
|
||||
if ('apprenant_collection' in local_Insc_retval.keys() and len( local_Insc_retval['apprenant_collection']) > 0):
|
||||
print(" ### apprenant_collection = ", str(local_Insc_retval['apprenant_collection'][0]) )
|
||||
if ("civilite" in local_Insc_retval['apprenant_collection'][0].keys()):
|
||||
my_retrun_dict['civilite'] = str(local_Insc_retval['apprenant_collection'][0]['civilite']).lower()
|
||||
else:
|
||||
my_retrun_dict['civilite'] = ""
|
||||
|
||||
if ("date_naissance" in local_Insc_retval['apprenant_collection'][0].keys()):
|
||||
my_retrun_dict['date_naissance'] = str(local_Insc_retval['apprenant_collection'][0]['date_naissance'])
|
||||
else:
|
||||
my_retrun_dict['date_naissance'] = ""
|
||||
|
||||
local_nom = ""
|
||||
if ("nom" in local_Insc_retval['apprenant_collection'][0].keys()):
|
||||
local_nom = local_Insc_retval['apprenant_collection'][0]['nom']
|
||||
my_retrun_dict['nom'] = local_nom
|
||||
|
||||
local_prenom = ""
|
||||
if ("prenom" in local_Insc_retval['apprenant_collection'][0].keys()):
|
||||
local_prenom = local_Insc_retval['apprenant_collection'][0]['prenom']
|
||||
my_retrun_dict['prenom'] = local_prenom
|
||||
|
||||
if ("date_naissance" in local_Insc_retval['apprenant_collection'][0].keys()):
|
||||
my_retrun_dict['date_naissance'] = local_Insc_retval['apprenant_collection'][0]['date_naissance']
|
||||
else:
|
||||
my_retrun_dict['date_naissance'] = ""
|
||||
|
||||
if ("adresse" in local_Insc_retval['apprenant_collection'][0].keys()):
|
||||
my_retrun_dict['adresse'] = local_Insc_retval['apprenant_collection'][0]['adresse']
|
||||
else:
|
||||
my_retrun_dict['adresse'] = ""
|
||||
|
||||
if ("code_postal" in local_Insc_retval['apprenant_collection'][0].keys()):
|
||||
my_retrun_dict['code_postal'] = local_Insc_retval['apprenant_collection'][0]['code_postal']
|
||||
else:
|
||||
my_retrun_dict['code_postal'] = ""
|
||||
|
||||
if ("ville" in local_Insc_retval['apprenant_collection'][0].keys()):
|
||||
my_retrun_dict['ville'] = local_Insc_retval['apprenant_collection'][0]['ville']
|
||||
else:
|
||||
my_retrun_dict['ville'] = ""
|
||||
|
||||
if ("pays" in local_Insc_retval['apprenant_collection'][0].keys()):
|
||||
my_retrun_dict['pays'] = local_Insc_retval['apprenant_collection'][0]['pays']
|
||||
else:
|
||||
my_retrun_dict['pays'] = ""
|
||||
|
||||
|
||||
local_employeur = ""
|
||||
if ("employeur" in local_Insc_retval['apprenant_collection'][0].keys()):
|
||||
local_employeur = local_Insc_retval['apprenant_collection'][0]['employeur']
|
||||
my_retrun_dict['employeur'] = local_employeur
|
||||
|
||||
local_telephone = ""
|
||||
if ("telephone" in local_Insc_retval['apprenant_collection'][0].keys()):
|
||||
local_telephone = local_Insc_retval['apprenant_collection'][0]['telephone']
|
||||
my_retrun_dict['telephone'] = local_telephone
|
||||
|
||||
local_email = ""
|
||||
if ("email" in local_Insc_retval['apprenant_collection'][0].keys()):
|
||||
local_email = local_Insc_retval['apprenant_collection'][0]['email']
|
||||
my_retrun_dict['email'] = local_email
|
||||
|
||||
local_adresse = ""
|
||||
if ("adresse" in local_Insc_retval['apprenant_collection'][0].keys()):
|
||||
local_adresse = local_Insc_retval['apprenant_collection'][0]['adresse']
|
||||
my_retrun_dict['adresse'] = local_adresse
|
||||
|
||||
if ("ville" in local_Insc_retval['apprenant_collection'][0].keys()):
|
||||
my_retrun_dict['ville'] = local_Insc_retval['apprenant_collection'][0]['ville']
|
||||
else:
|
||||
my_retrun_dict['ville'] = ""
|
||||
|
||||
if ("code_postal" in local_Insc_retval['apprenant_collection'][0].keys()):
|
||||
my_retrun_dict['code_postal'] = local_Insc_retval['apprenant_collection'][0]['code_postal']
|
||||
else:
|
||||
my_retrun_dict['code_postal'] = ""
|
||||
|
||||
if ("pays" in local_Insc_retval['apprenant_collection'][0].keys()):
|
||||
my_retrun_dict['pays'] = local_Insc_retval['apprenant_collection'][0]['pays']
|
||||
else:
|
||||
my_retrun_dict['pays'] = ""
|
||||
|
||||
|
||||
|
||||
# Tuteurs
|
||||
if ("tuteur1_nom" in local_Insc_retval['apprenant_collection'][0].keys()):
|
||||
my_retrun_dict['tuteur1_nom'] = local_Insc_retval['apprenant_collection'][0]['tuteur1_nom']
|
||||
else:
|
||||
my_retrun_dict['tuteur1_nom'] = ""
|
||||
|
||||
if ("tuteur1_prenom" in local_Insc_retval['apprenant_collection'][0].keys()):
|
||||
my_retrun_dict['tuteur1_prenom'] = local_Insc_retval['apprenant_collection'][0]['tuteur1_prenom']
|
||||
else:
|
||||
my_retrun_dict['tuteur1_prenom'] = ""
|
||||
|
||||
if ("tuteur1_email" in local_Insc_retval['apprenant_collection'][0].keys()):
|
||||
my_retrun_dict['tuteur1_email'] = local_Insc_retval['apprenant_collection'][0]['tuteur1_email']
|
||||
else:
|
||||
my_retrun_dict['tuteur1_email'] = ""
|
||||
|
||||
if ("tuteur1_telephone" in local_Insc_retval['apprenant_collection'][0].keys()):
|
||||
my_retrun_dict['tuteur1_telephone'] = local_Insc_retval['apprenant_collection'][0]['tuteur1_telephone']
|
||||
else:
|
||||
my_retrun_dict['tuteur1_telephone'] = ""
|
||||
|
||||
if ("tuteur1_adresse" in local_Insc_retval['apprenant_collection'][0].keys()):
|
||||
my_retrun_dict['tuteur1_adresse'] = local_Insc_retval['apprenant_collection'][0]['tuteur1_adresse']
|
||||
else:
|
||||
my_retrun_dict['tuteur1_adresse'] = ""
|
||||
|
||||
if ("tuteur1_cp" in local_Insc_retval['apprenant_collection'][0].keys()):
|
||||
my_retrun_dict['tuteur1_cp'] = local_Insc_retval['apprenant_collection'][0]['tuteur1_cp']
|
||||
else:
|
||||
my_retrun_dict['tuteur1_cp'] = ""
|
||||
|
||||
if ("tuteur1_ville" in local_Insc_retval['apprenant_collection'][0].keys()):
|
||||
my_retrun_dict['tuteur1_ville'] = local_Insc_retval['apprenant_collection'][0]['tuteur1_ville']
|
||||
else:
|
||||
my_retrun_dict['tuteur1_ville'] = ""
|
||||
|
||||
if ("tuteur1_pays" in local_Insc_retval['apprenant_collection'][0].keys()):
|
||||
my_retrun_dict['tuteur1_pays'] = local_Insc_retval['apprenant_collection'][0]['tuteur1_pays']
|
||||
else:
|
||||
my_retrun_dict['tuteur1_pays'] = ""
|
||||
|
||||
if ("tuteur1_include_com" in local_Insc_retval['apprenant_collection'][0].keys()):
|
||||
my_retrun_dict['tuteur1_include_com'] = local_Insc_retval['apprenant_collection'][0]['tuteur1_include_com']
|
||||
else:
|
||||
my_retrun_dict['tuteur1_include_com'] = ""
|
||||
|
||||
if ("tuteur2_nom" in local_Insc_retval['apprenant_collection'][0].keys()):
|
||||
my_retrun_dict['tuteur2_nom'] = local_Insc_retval['apprenant_collection'][0]['tuteur2_nom']
|
||||
else:
|
||||
my_retrun_dict['tuteur2_nom'] = ""
|
||||
|
||||
if ("tuteur2_prenom" in local_Insc_retval['apprenant_collection'][0].keys()):
|
||||
my_retrun_dict['tuteur2_prenom'] = local_Insc_retval['apprenant_collection'][0]['tuteur2_prenom']
|
||||
else:
|
||||
my_retrun_dict['tuteur2_prenom'] = ""
|
||||
|
||||
|
||||
if ("tuteur2_email" in local_Insc_retval['apprenant_collection'][0].keys()):
|
||||
my_retrun_dict['tuteur2_email'] = local_Insc_retval['apprenant_collection'][0]['tuteur2_email']
|
||||
else:
|
||||
my_retrun_dict['tuteur2_email'] = ""
|
||||
|
||||
|
||||
if ("tuteur2_telephone" in local_Insc_retval['apprenant_collection'][0].keys()):
|
||||
my_retrun_dict['tuteur2_telephone'] = local_Insc_retval['apprenant_collection'][0]['tuteur2_telephone']
|
||||
else:
|
||||
my_retrun_dict['tuteur2_telephone'] = ""
|
||||
|
||||
|
||||
if ("tuteur2_adresse" in local_Insc_retval.keys()):
|
||||
my_retrun_dict['tuteur2_adresse'] = local_Insc_retval['apprenant_collection'][0]['tuteur2_adresse']
|
||||
else:
|
||||
my_retrun_dict['tuteur2_adresse'] = ""
|
||||
|
||||
|
||||
if ("tuteur2_cp" in local_Insc_retval['apprenant_collection'][0].keys()):
|
||||
my_retrun_dict['tuteur2_cp'] = local_Insc_retval['apprenant_collection'][0]['tuteur2_cp']
|
||||
else:
|
||||
my_retrun_dict['tuteur2_cp'] = ""
|
||||
|
||||
|
||||
if ("tuteur2_ville" in local_Insc_retval['apprenant_collection'][0].keys()):
|
||||
my_retrun_dict['tuteur2_ville'] = local_Insc_retval['apprenant_collection'][0]['tuteur2_ville']
|
||||
else:
|
||||
my_retrun_dict['tuteur2_ville'] = ""
|
||||
|
||||
if ("tuteur2_pays" in local_Insc_retval['apprenant_collection'][0].keys()):
|
||||
my_retrun_dict['tuteur2_pays'] = local_Insc_retval['apprenant_collection'][0]['tuteur2_pays']
|
||||
else:
|
||||
my_retrun_dict['tuteur2_pays'] = ""
|
||||
|
||||
|
||||
if ("tuteur2_include_com" in local_Insc_retval['apprenant_collection'][0].keys()):
|
||||
my_retrun_dict['tuteur2_include_com'] = local_Insc_retval['apprenant_collection'][0]['tuteur2_include_com']
|
||||
else:
|
||||
my_retrun_dict['tuteur2_include_com'] = ""
|
||||
|
||||
"""
|
||||
RetObject.append(JSONEncoder().encode(my_retrun_dict))
|
||||
|
||||
return True, RetObject
|
||||
|
@ -4962,7 +4781,6 @@ def Get_Dictionnary_data_For_Template(diction):
|
|||
|
||||
|
||||
for stagiaire_data in MYSY_GV.dbname['inscription'].find({'_id': {'$in': tab_stagiaire_id, },
|
||||
'status': '1',
|
||||
'partner_owner_recid': str(my_partner['recid'])
|
||||
}):
|
||||
|
||||
|
@ -6384,6 +6202,10 @@ def Is_Ressource_Available(diction):
|
|||
"$gte": filt_periode_start_date_ISODATE
|
||||
}
|
||||
},
|
||||
{
|
||||
"mysy_session_start_date": {"$lte": filt_periode_start_date_ISODATE},
|
||||
"mysy_session_end_date": {"$gte": filt_periode_end_date_ISODATE}
|
||||
}
|
||||
|
||||
]
|
||||
},
|
||||
|
|
|
@ -522,7 +522,7 @@ def Send_Survey_Alert_Notif(diction):
|
|||
try:
|
||||
field_list_obligatoire = [ 'user_question_reponse', 'partner_owner_recid']
|
||||
|
||||
print(" ### Send_Survey_Alert_Notif diction (trop long) = ")
|
||||
print(" ### Send_Survey_Alert_Notif diction (trop long) = ", diction)
|
||||
|
||||
for val in field_list_obligatoire:
|
||||
if val not in diction:
|
||||
|
|
Loading…
Reference in New Issue