01/02/2025 - 20h

master
cherif 2025-02-01 20:05:26 +01:00
parent e6a9ea6272
commit e060ec266a
9 changed files with 7821 additions and 119 deletions

View File

@ -1,18 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="20/01/2025 - 18h">
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="30/01/2025 - 16h">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/E_Sign_Document.py" beforeDir="false" afterPath="$PROJECT_DIR$/E_Sign_Document.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/GlobalVariable.py" beforeDir="false" afterPath="$PROJECT_DIR$/GlobalVariable.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Inscription_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/Inscription_mgt.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Log/log_file.log" beforeDir="false" afterPath="$PROJECT_DIR$/Log/log_file.log" afterDir="false" />
<change beforePath="$PROJECT_DIR$/ela_factures_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/ela_factures_mgt.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/ela_user_account.py" beforeDir="false" afterPath="$PROJECT_DIR$/ela_user_account.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Session_Formation.py" beforeDir="false" afterPath="$PROJECT_DIR$/Session_Formation.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/articles_avis.py" beforeDir="false" afterPath="$PROJECT_DIR$/articles_avis.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/class_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/class_mgt.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/lms_chamilo/mysy_lms.py" beforeDir="false" afterPath="$PROJECT_DIR$/lms_chamilo/mysy_lms.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/partner_client.py" beforeDir="false" afterPath="$PROJECT_DIR$/partner_client.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/user_message_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/user_message_mgt.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/tools_cherif/tools_cherif.py" beforeDir="false" afterPath="$PROJECT_DIR$/tools_cherif/tools_cherif.py" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -83,13 +81,6 @@
<option name="presentableId" value="Default" />
<updated>1680804787304</updated>
</task>
<task id="LOCAL-00383" summary="dddqsdddd">
<created>1725013352921</created>
<option name="number" value="00383" />
<option name="presentableId" value="LOCAL-00383" />
<option name="project" value="LOCAL" />
<updated>1725013352921</updated>
</task>
<task id="LOCAL-00384" summary="dddqsddddss">
<created>1725026643840</created>
<option name="number" value="00384" />
@ -426,7 +417,14 @@
<option name="project" value="LOCAL" />
<updated>1737392376182</updated>
</task>
<option name="localTasksCounter" value="432" />
<task id="LOCAL-00432" summary="30/01/2025 - 16h">
<created>1738251430864</created>
<option name="number" value="00432" />
<option name="presentableId" value="LOCAL-00432" />
<option name="project" value="LOCAL" />
<updated>1738251430865</updated>
</task>
<option name="localTasksCounter" value="433" />
<servers />
</component>
<component name="Vcs.Log.Tabs.Properties">
@ -468,7 +466,6 @@
</option>
</component>
<component name="VcsManagerConfiguration">
<MESSAGE value="13/10/2024 - 14h" />
<MESSAGE value="13/10/2024 - sdf14h" />
<MESSAGE value="13/10/2024 - sdfqsdqs14h" />
<MESSAGE value="qsdsq" />
@ -493,6 +490,7 @@
<MESSAGE value="17/01/2025 - 15:30" />
<MESSAGE value="18/01/2025 - 17h" />
<MESSAGE value="20/01/2025 - 18h" />
<option name="LAST_COMMIT_MESSAGE" value="20/01/2025 - 18h" />
<MESSAGE value="30/01/2025 - 16h" />
<option name="LAST_COMMIT_MESSAGE" value="30/01/2025 - 16h" />
</component>
</project>

View File

@ -6300,6 +6300,13 @@ def AcceptAttendeeInscription(diction):
new_diction['locked'] = "0"
new_diction['username'] = email
new_diction['session_end_date'] = session_end_date
# 01/02/2025 : gestion date fin validité compte lms. Par defaut la session est active 30 jours apres la fin de la session
local_session_end_date = datetime.strptime(str(session_end_date).strip(), '%d/%m/%Y')
local_lms_access_end_date = local_session_end_date+timedelta(days=30)
local_lms_access_end_date_formated = str(local_lms_access_end_date.strftime("%d/%m/%Y"))
local_status, local_message, local_participant_lms_id = mys_lms.Create_MySy_LMS_Apprenant(new_diction)
if (local_status is False):
@ -6313,13 +6320,13 @@ def AcceptAttendeeInscription(diction):
"""
print(" ### Mise à jour 'inscription' pour inscription_line_id = ", str(diction['inscription_id']),
" local_participant_lms_id = ", local_participant_lms_id, " str(new_diction['password'] ",
str(new_diction['password']))
str(new_diction['password']), " lms_account_expiration_date = ",local_lms_access_end_date_formated )
local_ret_val = MYSY_GV.dbname['inscription'].find_one_and_update(
{'_id': ObjectId(str(diction['inscription_id'])), 'partner_owner_recid':str(my_partner['recid'])},
{"$set": {'lms_user_id': str(local_participant_lms_id),
'lms_pwd': str(new_diction['password']),
'lms_class_code': str(lms_class_code),
'lms_account_expiration_date':str(session_end_date)}
'lms_account_expiration_date':str(local_lms_access_end_date_formated)}
},
upsert=False,
return_document=ReturnDocument.AFTER
@ -13891,3 +13898,108 @@ def Delete_Inscription_Split_Invoice(diction):
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - Line : " + str(exc_tb.tb_lineno))
return False, " Impossible supprimer le partage de facture "
"""
Cette fonction permet de modidier la fin de
validité des acces au e-learning pour une liste
d'inscription.
Concretement cette fonction va desincrire l'apprenant à la formation dans le LMS
"""
def Update_LMS_Inscrition_End_Date(diction):
try:
diction = mycommon.strip_dictionary(diction)
"""
Verification des input acceptés
"""
field_list = ['token', 'session_id', 'tab_inscription_ids', 'end_date']
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'est pas autorisé")
return False, " Les informations fournies sont incorrectes"
"""
Verification des champs obligatoires
"""
field_list_obligatoire = ['token', 'session_id', 'tab_inscription_ids', 'end_date']
for val in field_list_obligatoire:
if val not in diction:
mycommon.myprint(
str(inspect.stack()[0][3]) + " - La valeur '" + val + "' n'est pas presente dans liste ")
return False, " Les informations fournies sont incorrectes"
"""
Verification de l'identité et autorisation de l'entité qui
appelle cette API
"""
my_token = ""
if ("token" in diction.keys()):
if diction['token']:
my_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, False
end_date = str(diction['end_date'])[0:10]
local_status = mycommon.CheckisDate(end_date)
if (local_status is False):
mycommon.myprint(str(
inspect.stack()[0][3]) + " La date de fin n'est pas au format jj/mm/aaaa.")
return False, " La date de fin n'est pas au format jj/mm/aaaa."
# Verifier que la session est valide
is_session_id_valide = MYSY_GV.dbname['session_formation'].count_documents(
{'_id': ObjectId(str(diction['session_id'])),
'valide': '1',
'partner_owner_recid': str(my_partner['recid'])})
if (is_session_id_valide != 1):
mycommon.myprint(
str(inspect.stack()[0][
3]) + " L'identifiant de la session est invalide ")
return False, " L'identifiant de la session est invalide ", False
my_inscription_ids = ""
if ("tab_inscription_ids" in diction.keys()):
if diction['tab_inscription_ids']:
my_inscription_ids = diction['tab_inscription_ids']
tab_my_inscription_ids = str(my_inscription_ids).split(",")
tab_my_inscription_ids_ObjectId = []
for tmp in tab_my_inscription_ids:
tab_my_inscription_ids_ObjectId.append(ObjectId(str(tmp)))
tab_my_inscription_ids = str(my_inscription_ids).split(",")
now = str(datetime.now())
update_data = {}
update_data['date_update'] = now
update_data['update_by'] = str(my_partner['_id'])
update_data['lms_account_expiration_date'] = str(end_date)
update = MYSY_GV.dbname['inscription'].update_many({'partner_owner_recid': str(my_partner['recid']),
'session_id': diction['session_id'],
'_id':{'$in':tab_my_inscription_ids_ObjectId},},
{'$set': update_data})
return True, " La mise à jour é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, " Impossible de mettre à jour la date "

File diff suppressed because it is too large Load Diff

View File

@ -9645,7 +9645,6 @@ def Prepare_and_Send_Facture_From_Session_By_Inscription_Id(tab_files, Folder, d
print(" ### tab_my_inscription_ids = ", tab_my_inscription_ids)
for my_inscription_id in tab_my_inscription_ids:
tmp_count = MYSY_GV.dbname['inscription'].count_documents({'session_id': str(diction['session_id']),
'_id': ObjectId(str(my_inscription_id)),
'partner_owner_recid': str(
@ -9658,7 +9657,6 @@ def Prepare_and_Send_Facture_From_Session_By_Inscription_Id(tab_files, Folder, d
tab_my_inscription_ids_Object.append(ObjectId(str(my_inscription_id)))
# Verifier que la session est valide
is_session_valide = MYSY_GV.dbname['session_formation'].count_documents(
{'_id': ObjectId(str(diction['session_id'])),
@ -9671,30 +9669,27 @@ def Prepare_and_Send_Facture_From_Session_By_Inscription_Id(tab_files, Folder, d
3]) + " L'identifiant de la session est invalide ")
return False, " L'identifiant de la session est invalide ", False
# Verifier qu'il ya bien des inscriptions valides dans la session pour le client
liste_client_rattachement_id = []
liste_client_facturation_rattachement_id = MYSY_GV.dbname['inscription'].distinct("facture_client_rattachement_id",
{'session_id': str(diction['session_id']),
'status': '1',
'partner_owner_recid': str(
my_partner['recid']),
"facture_client_rattachement_id": {'$ne': ''},
"invoiced": {'$ne': '1'},
"_id": {'$in': tab_my_inscription_ids_Object},
}
)
liste_client_facturation_rattachement_id = MYSY_GV.dbname['inscription'].distinct(
"facture_client_rattachement_id",
{'session_id': str(diction['session_id']),
'status': '1',
'partner_owner_recid': str(
my_partner['recid']),
"facture_client_rattachement_id": {'$ne': ''},
"invoiced": {'$ne': '1'},
"_id": {'$in': tab_my_inscription_ids_Object},
}
)
print(" ### la liste des liste_client_facturation_rattachement_id = ", liste_client_facturation_rattachement_id)
# Ajout des client de facturation
for tmp in liste_client_facturation_rattachement_id :
for tmp in liste_client_facturation_rattachement_id:
liste_client_rattachement_id.append(tmp)
print(" ### la liste des liste_client_rattachement_id = ", liste_client_rattachement_id)
"""
@ -9886,7 +9881,6 @@ def Prepare_and_Send_Facture_From_Session_By_Inscription_Id(tab_files, Folder, d
}
})
# Sauvegarde des fichiers joints depuis le front
tab_saved_file_full_path = []
for file in tab_files:
@ -9977,115 +9971,110 @@ def Prepare_and_Send_Facture_From_Session_By_Inscription_Id(tab_files, Folder, d
tab_local_invoice_ref_interne.append(str(local_invoice_ref_interne))
# Traitement pour les facture : liste_client_client_rattachement_id
for single_client in liste_client_client_rattachement_id:
print(" Traitement du client_id = ", single_client)
print(" Traitement du client_id = ", single_client)
# Recuperation des contacts de communication du client
local_diction = {}
local_diction['token'] = diction['token']
local_diction['_id'] = str(single_client)
# Recuperation des contacts de communication du client
local_diction = {}
local_diction['token'] = diction['token']
local_diction['_id'] = str(single_client)
print(" ##### local_diction = ", local_diction)
local_status, partner_client_contact_communication = partner_client.Get_Partner_Client_Communication_Contact(
local_diction)
print(" ##### local_diction = ", local_diction)
local_status, partner_client_contact_communication = partner_client.Get_Partner_Client_Communication_Contact(
local_diction)
if (local_status is False):
mycommon.myprint(" Impossible de récupérer les contacts de communication du client ")
return False, " Impossible de récupérer les contacts de communication du client ", False
if (local_status is False):
mycommon.myprint(" Impossible de récupérer les contacts de communication du client ")
return False, " Impossible de récupérer les contacts de communication du client ", False
print(" ### partner_client_contact_communication = ", partner_client_contact_communication)
tab_local_email_production = []
for tmp in partner_client_contact_communication:
tmp_JSON = ast.literal_eval(tmp)
if ("email" in tmp_JSON.keys()):
tab_local_email_production.append(str(tmp_JSON["email"]))
print(" ### partner_client_contact_communication = ", partner_client_contact_communication)
tab_local_email_production = []
for tmp in partner_client_contact_communication:
tmp_JSON = ast.literal_eval(tmp)
if ("email" in tmp_JSON.keys()):
tab_local_email_production.append(str(tmp_JSON["email"]))
list_local_email_production = ",".join(tab_local_email_production)
list_local_email_production = ",".join(tab_local_email_production)
new_diction_client = {}
new_diction_client['partner_client_id'] = single_client
new_diction_client['token'] = diction['token']
new_diction_client['courrier_template_id'] = diction['courrier_template_id']
new_diction_client['email_test'] = diction['email_test']
new_diction_client['email_production'] = str(list_local_email_production)
new_diction_client['session_id'] = diction['session_id']
new_diction_client = {}
new_diction_client['partner_client_id'] = single_client
new_diction_client['token'] = diction['token']
new_diction_client['courrier_template_id'] = diction['courrier_template_id']
new_diction_client['email_test'] = diction['email_test']
new_diction_client['email_production'] = str(list_local_email_production)
new_diction_client['session_id'] = diction['session_id']
print(" ##### new_diction_client 0102 = ", new_diction_client)
print(" ##### new_diction_client 0102 = ", new_diction_client)
# Creation de la facture du client
diction_invoice = {}
diction_invoice['token'] = diction['token']
diction_invoice['partner_client_id'] = single_client
diction_invoice['session_id'] = diction['session_id']
diction_invoice['tab_inscription_ids'] = tab_my_inscription_ids_Object
print(" ##### liste_client_client_rattachement_id : diction_invoice 0202 icici = ", diction_invoice)
local_create_invoice_status, local_create_invoice_retval, local_invoice_ref_interne = Invoice_Partner_From_Session_By_Inscription_Id(
diction_invoice)
if (local_create_invoice_status is False):
return local_create_invoice_status, local_create_invoice_retval, False
# Creation de la facture du client
diction_invoice = {}
diction_invoice['token'] = diction['token']
diction_invoice['partner_client_id'] = single_client
diction_invoice['session_id'] = diction['session_id']
diction_invoice['tab_inscription_ids'] = tab_my_inscription_ids_Object
print(" ##### liste_client_client_rattachement_id : diction_invoice 0202 icici = ", diction_invoice)
local_create_invoice_status, local_create_invoice_retval, local_invoice_ref_interne = Invoice_Partner_From_Session_By_Inscription_Id(
diction_invoice)
if (local_create_invoice_status is False):
return local_create_invoice_status, local_create_invoice_retval, False
"""
Mettre à jour les lignes associées à ce client pour dire que la ligne est facturé
"""
now = str(datetime.now())
update_data = {}
update_data['invoiced'] = "1"
update_data['invoiced_ref'] = str(local_invoice_ref_interne)
update_data['invoiced_date'] = now
update_data['date_update'] = now
update_data['update_by'] = str(my_partner['_id'])
"""
Mettre à jour les lignes associées à ce client pour dire que la ligne est facturé
"""
now = str(datetime.now())
update_data = {}
update_data['invoiced'] = "1"
update_data['invoiced_ref'] = str(local_invoice_ref_interne)
update_data['invoiced_date'] = now
update_data['date_update'] = now
update_data['update_by'] = str(my_partner['_id'])
update = MYSY_GV.dbname['inscription'].update_many({'partner_owner_recid': str(my_partner['recid']),
'session_id': diction['session_id'],
'facture_client_rattachement_id': str(
single_client),
"_id": {'$in': tab_my_inscription_ids_Object},
},
{'$set': update_data})
tab_local_invoice_ref_interne.append(str(local_invoice_ref_interne))
update = MYSY_GV.dbname['inscription'].update_many({'partner_owner_recid': str(my_partner['recid']),
'session_id': diction['session_id'],
'facture_client_rattachement_id': str(
single_client),
"_id": {'$in': tab_my_inscription_ids_Object},
},
{'$set': update_data})
tab_local_invoice_ref_interne.append(str(local_invoice_ref_interne))
"""
07/03/20204 : mettre un statut de facturation sur la session afin de voir
tout de suite quel session est entièrement facturée ou partiellement.
regles :
Si toutes les inscription associées à une session sont facturée ==> invoiced_statut de la session = 2
Si au moins une inscription associée à une session est facturé ==> invoiced_statut de la session = 1
Si non invoiced_statut de la session =0
"""
nb_inscription_facture = MYSY_GV.dbname['inscription'].count_documents({'partner_owner_recid':my_partner['recid'],
'invoiced':'1'})
nb_inscription_facture = MYSY_GV.dbname['inscription'].count_documents(
{'partner_owner_recid': my_partner['recid'],
'invoiced': '1'})
nb_inscription_non_facture = MYSY_GV.dbname['inscription'].count_documents(
{'partner_owner_recid': my_partner['recid'],
'invoiced': {'$ne':'1'}})
'invoiced': {'$ne': '1'}})
nb_inscription_valide = MYSY_GV.dbname['inscription'].count_documents(
{'partner_owner_recid': my_partner['recid'],
'status':'1'})
'status': '1'})
invoiced_statut = "0"
if( nb_inscription_facture == nb_inscription_valide ):
if (nb_inscription_facture == nb_inscription_valide):
# toutes les inscription valides ont été facturée
invoiced_statut = "2"
elif ( nb_inscription_facture > 0 ):
elif (nb_inscription_facture > 0):
# Au moins une ligne a été facturée
invoiced_statut = "1"
# Mise à jour du statut de facturation de la session
MYSY_GV.dbname['session_formation'].update_one({'partner_owner_recid':my_partner['recid'],
'valide':'1',
'_id':ObjectId(str(diction['session_id']))
MYSY_GV.dbname['session_formation'].update_one({'partner_owner_recid': my_partner['recid'],
'valide': '1',
'_id': ObjectId(str(diction['session_id']))
},
{'$set':{'invoiced_statut':invoiced_statut}})
{'$set': {'invoiced_statut': invoiced_statut}})
# Creation de l'historique dans les action 'courrier_template_tracking_history'
local_qry = {'partner_owner_recid': str(my_partner['recid']), 'session_id': str(diction['session_id']),

View File

@ -378,11 +378,11 @@ def get_last_3_articles(diction):
# mycommon.myprint("AVANT ==> "+str(x['description']))
if( "qualite" in x.keys() ):
val = x['qualite']
if (len(x['qualite']) > MYSY_GV.MAX_CARACT):
x['qualite'] = val[:MYSY_GV.MAX_CARACT] + " ..."
if (len(x['qualite']) > MYSY_GV.MAX_CARACT_DEDUIT):
x['qualite'] = val[:MYSY_GV.MAX_CARACT_DEDUIT] + " ..."
else:
x['qualite'] = val[:MYSY_GV.MAX_CARACT]
x['qualite'] = val[:MYSY_GV.MAX_CARACT_DEDUIT]
val = x['avis']
CLEANR = re.compile('<.*?>')
@ -392,8 +392,8 @@ def get_last_3_articles(diction):
#print(" ### CLEANRCLEANR = "+str(clean_avis))
if (len(clean_avis) > MYSY_GV.MAX_CARACT):
x['avis'] = clean_avis[:MYSY_GV.MAX_CARACT] + " ..."
if (len(clean_avis) > MYSY_GV.MAX_CARACT_DEDUIT):
x['avis'] = clean_avis[:MYSY_GV.MAX_CARACT_DEDUIT] + " ..."
else:
x['avis'] = str(clean_avis)

View File

@ -5520,6 +5520,7 @@ def delete_Class(diction):
# Verifier qu'il n'y a pas de session associée à cette formation
existe_Session_count = MYSY_GV.dbname['session_formation'].count_documents({'class_internal_url':str(Myclass_Data['internal_url']),
'_id': ObjectId(str(diction['class_id'])),
'partner_owner_recid':str(my_partner['recid']),
'valide':'1'})
@ -6047,6 +6048,7 @@ def Duplicate_Class(diction):
new_class['internal_code'] = new_internal_code
new_class['internal_url'] = new_internal_url
new_class['external_code'] = new_external_code
new_class['lms_class_code'] = ""
inserted = MYSY_GV.dbname['myclass'].insert_one(new_class)
@ -6195,6 +6197,7 @@ def Duplicate_Class_from_internal_url(diction):
new_class['internal_code'] = new_internal_code
new_class['internal_url'] = new_internal_url
new_class['external_code'] = new_external_code
new_class['lms_class_code'] = ""
inserted = MYSY_GV.dbname['myclass'].insert_one(new_class)
@ -6213,7 +6216,7 @@ def Duplicate_Class_from_internal_url(diction):
history_event_dict = {}
history_event_dict['token'] = str(diction['token'])
history_event_dict['related_collection'] = "myclass"
history_event_dict['related_collection_recid'] = str(inserted['_id'])
history_event_dict['related_collection_recid'] = str(inserted.inserted_id)
history_event_dict['action_date'] = str(now)
history_event_dict['action_description'] = "Creation Formation avec duplication de la formation " + str(

View File

@ -1936,7 +1936,7 @@ def Create_MySy_LMS_Apprenant(diction):
hashed_pwd) + "', " \
"enabled='1', " \
"expired='0', " \
"locked = '0', expiration_date = '"+str(session_end_date_str)+"', " \
"locked = '0', " \
"auth_source = 'platform'," \
"roles = 'a:0:{}', " \
"language = 'french'," \
@ -1960,7 +1960,7 @@ def Create_MySy_LMS_Apprenant(diction):
" registration_date = '"+registration_date+"'," \
" credentials_expired='0', " \
"enabled='1', " \
"expired='0', expiration_date = '"+str(session_end_date_str)+"', " \
"expired='0', " \
"created_at='" + str( registration_date) + "'," \
" updated_at='" + str( registration_date) + "', " \
" status = '5', " \
@ -3822,10 +3822,10 @@ def Push_Class_To_MySy_LMS(diction):
query = "select title, code from course "
print(" ### query = ", query)
cur.execute(query)
"""
for cours_title_and_code in cur:
print(" ### cours = ", cours_title_and_code)
"""
"""
Verifier que le user qui poste la formation ( my_partner['mysy_lms_user_id'])

57
main.py
View File

@ -10844,6 +10844,20 @@ def Delete_Inscription_Split_Invoice():
return jsonify(status=status, message=retval)
"""
API pour mettre à jour lms_account_expiration_date pour une liste _id
"""
@app.route('/myclass/api/Update_LMS_Inscrition_End_Date/', methods=['POST','GET'])
@crossdomain(origin='*')
def Update_LMS_Inscrition_End_Date():
# On recupere le corps (payload) de la requete
payload = mycommon.strip_dictionary (request.form.to_dict())
print(" ### Update_LMS_Inscrition_End_Date payload = ",payload)
status, retval = inscription.Update_LMS_Inscrition_End_Date(payload)
return jsonify(status=status, message=retval)
"""
API qui recuperer les reponses d'un survey donné dans une fichier pdf
@ -11707,6 +11721,49 @@ def Blog_Img_Store_Article_Image():
return jsonify(status=localStatus, message=message)
"""
Nettoyage / mise en conformité html des
articles du blog
"""
@app.route('/myclass/api/Conformite_Article_Blog_Dev/', methods=['POST','GET'])
@crossdomain(origin='*')
def Conformite_Article_Blog_Dev():
# On recupere le corps (payload) de la requete
payload = mycommon.strip_dictionary (request.form.to_dict())
print(" ### email_validation : payload = ",payload)
localStatus, message= tools_cherif.Conformite_Article_Blog_Dev()
return jsonify(status=localStatus, message=message )
@app.route('/myclass/api/Conformite_Article_Blog_Recette/', methods=['POST','GET'])
@crossdomain(origin='*')
def Conformite_Article_Blog_Recette():
# On recupere le corps (payload) de la requete
payload = mycommon.strip_dictionary (request.form.to_dict())
print(" ### email_validation : payload = ",payload)
localStatus, message= tools_cherif.Conformite_Article_Blog_Recette()
return jsonify(status=localStatus, message=message )
@app.route('/myclass/api/Conformite_Article_Blog_Demo/', methods=['POST','GET'])
@crossdomain(origin='*')
def Conformite_Article_Blog_Demo():
# On recupere le corps (payload) de la requete
payload = mycommon.strip_dictionary (request.form.to_dict())
print(" ### email_validation : payload = ",payload)
localStatus, message= tools_cherif.Conformite_Article_Blog_Demo()
return jsonify(status=localStatus, message=message )
@app.route('/myclass/api/Conformite_Article_Blog_Prod/', methods=['POST','GET'])
@crossdomain(origin='*')
def Conformite_Article_Blog_Prod():
# On recupere le corps (payload) de la requete
payload = mycommon.strip_dictionary (request.form.to_dict())
print(" ### email_validation : payload = ",payload)
localStatus, message= tools_cherif.Conformite_Article_Blog_Prod()
return jsonify(status=localStatus, message=message )
if __name__ == '__main__':
print(" debut api")
context = SSL.Context(SSL.SSLv23_METHOD)

View File

@ -1540,3 +1540,207 @@ def Delete_And_Load_DB_Collection_courrier_template_From_rec_to_Demo_Env():
print(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
return False, " Impossible de Delete_And_Load_DB_Collection_courrier_template_From_rec_to_Demo_Env"
"""
Nettoyage / mise en conformité html des
articles du blog
"""
def Conformite_Article_Blog_Dev():
try:
# REC_base_config_dashbord
CONNECTION_STRING = "mongodb://localhost:27017"
client = MongoClient(CONNECTION_STRING)
REC_dbname = client['cherifdb_rec']
DEM_dbname = client['cherifdb_demo']
DEV_dbname = client['cherifdb_dev']
"""
Ici les collections avec les filtres pr chaque collection
"""
qry_rec = {'partner_owner_recid': 'default'}
## On vide les table d'abord dans l'environnement cible
for tmp in DEV_dbname['articles_avis'].find({}):
print(" tmp['avis'] = ", tmp['avis'])
val = tmp['avis']
val = str(val).replace("<p>&nbsp;</p>", "")
val = str(val).replace('<h3 style="font-size: 1.5rem;">',
'<div style="font-family: DM Sans; font-style: normal;font-weight: 600; font-size: 24px; line-height: 28px; color: #16274F; text-align: left; margin-bottom: 10px;"> ')
val = str(val).replace("</h3>", "</div>")
val = str(val).replace("<p>", ' <div style="font-family: Inter; font-style: normal; font-weight: 400; font-size: 20px; line-height: 32px; color: #4B5162; margin-bottom: 2rem;">')
val = str(val).replace("</p>", "</div>")
val = str(val).replace('<h3 class="MsoNormal">&nbsp;</div>', "")
val = str(val).replace('<ol>', '<ol style="margin-bottom: 2rem;">')
val = str(val).replace('<ul>', '<ul style="margin-bottom: 2rem;">')
print(" ===================================================")
print(" val = ", val)
DEV_dbname['articles_avis'].find_one_and_update({'_id': ObjectId(str(tmp['_id'])),},
{"$set": {'avis':val}},
return_document=ReturnDocument.AFTER,
upsert=True,
)
return True, "OK"
except Exception as e:
exc_type, exc_obj, exc_tb = sys.exc_info()
print(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
return False, " Impossible de Conformite_Article_Blog"
def Conformite_Article_Blog_Recette():
try:
# REC_base_config_dashbord
CONNECTION_STRING = "mongodb://localhost:27017"
client = MongoClient(CONNECTION_STRING)
REC_dbname = client['cherifdb_rec']
DEM_dbname = client['cherifdb_demo']
DEV_dbname = client['cherifdb_dev']
"""
Ici les collections avec les filtres pr chaque collection
"""
qry_rec = {'partner_owner_recid': 'default'}
## On vide les table d'abord dans l'environnement cible
for tmp in REC_dbname['articles_avis'].find({}):
print(" tmp['avis'] = ", tmp['avis'])
val = tmp['avis']
val = str(val).replace("<p>&nbsp;</p>", "")
val = str(val).replace('<h3 style="font-size: 1.5rem;">',
'<div style="font-family: DM Sans; font-style: normal;font-weight: 600; font-size: 24px; line-height: 28px; color: #16274F; text-align: left; margin-bottom: 10px;"> ')
val = str(val).replace("</h3>", "</div>")
val = str(val).replace("<p>", ' <div style="font-family: Inter; font-style: normal; font-weight: 400; font-size: 20px; line-height: 32px; color: #4B5162; margin-bottom: 2rem;">')
val = str(val).replace("</p>", "</div>")
val = str(val).replace('<h3 class="MsoNormal">&nbsp;</div>', "")
val = str(val).replace('<h3>',
'<div style="font-family: DM Sans; font-style: normal;font-weight: 600; font-size: 24px; line-height: 28px; color: #16274F; text-align: left; margin-bottom: 10px;"> ')
val = str(val).replace("</h3>", "</div>")
print(" ===================================================")
print(" val = ", val)
REC_dbname['articles_avis'].find_one_and_update({'_id': ObjectId(str(tmp['_id'])),},
{"$set": {'avis':val}},
return_document=ReturnDocument.AFTER,
upsert=True,
)
return True, "OK"
except Exception as e:
exc_type, exc_obj, exc_tb = sys.exc_info()
print(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
return False, " Impossible de Conformite_Article_Blog REC_dbname"
def Conformite_Article_Blog_Demo():
try:
# REC_base_config_dashbord
CONNECTION_STRING = "mongodb://localhost:27017"
client = MongoClient(CONNECTION_STRING)
REC_dbname = client['cherifdb_rec']
DEM_dbname = client['cherifdb_demo']
DEV_dbname = client['cherifdb_dev']
"""
Ici les collections avec les filtres pr chaque collection
"""
qry_rec = {'partner_owner_recid': 'default'}
## On vide les table d'abord dans l'environnement cible
for tmp in DEM_dbname['articles_avis'].find({}):
print(" tmp['avis'] = ", tmp['avis'])
val = tmp['avis']
val = str(val).replace("<p>&nbsp;</p>", "")
val = str(val).replace('<h3 style="font-size: 1.5rem;">',
'<div style="font-family: DM Sans; font-style: normal;font-weight: 600; font-size: 24px; line-height: 28px; color: #16274F; text-align: left; margin-bottom: 10px;"> ')
val = str(val).replace("</h3>", "</div>")
val = str(val).replace("<p>", ' <div style="font-family: Inter; font-style: normal; font-weight: 400; font-size: 20px; line-height: 32px; color: #4B5162; margin-bottom: 2rem;">')
val = str(val).replace("</p>", "</div>")
val = str(val).replace('<h3 class="MsoNormal">&nbsp;</div>', "")
val = str(val).replace('<h3>',
'<div style="font-family: DM Sans; font-style: normal;font-weight: 600; font-size: 24px; line-height: 28px; color: #16274F; text-align: left; margin-bottom: 10px;"> ')
val = str(val).replace("</h3>", "</div>")
val = str(val).replace('<h3><br>',
'<div style="font-family: DM Sans; font-style: normal;font-weight: 600; font-size: 24px; line-height: 28px; color: #16274F; text-align: left; margin-bottom: 10px;"> ')
print(" ===================================================")
print(" val = ", val)
DEM_dbname['articles_avis'].find_one_and_update({'_id': ObjectId(str(tmp['_id'])),},
{"$set": {'avis':val}},
return_document=ReturnDocument.AFTER,
upsert=True,
)
return True, "OK"
except Exception as e:
exc_type, exc_obj, exc_tb = sys.exc_info()
print(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
return False, " Impossible de Conformite_Article_Blog DEM_dbname"
def Conformite_Article_Blog_Prod():
try:
# REC_base_config_dashbord
CONNECTION_STRING = "mongodb://localhost:27017"
client = MongoClient(CONNECTION_STRING)
PROD_dbname = client['cherifdb']
"""
Ici les collections avec les filtres pr chaque collection
"""
qry_rec = {'partner_owner_recid': 'default'}
## On vide les table d'abord dans l'environnement cible
for tmp in PROD_dbname['articles_avis'].find({}):
print(" tmp['avis'] = ", tmp['avis'])
val = tmp['avis']
val = str(val).replace("<p>&nbsp;</p>", "")
val = str(val).replace('<h3 style="font-size: 1.5rem;">',
'<div style="font-family: DM Sans; font-style: normal;font-weight: 600; font-size: 24px; line-height: 28px; color: #16274F; text-align: left; margin-bottom: 10px;"> ')
val = str(val).replace("</h3>", "</div>")
val = str(val).replace("<p>", ' <div style="font-family: Inter; font-style: normal; font-weight: 400; font-size: 20px; line-height: 32px; color: #4B5162; margin-bottom: 2rem;">')
val = str(val).replace("</p>", "</div>")
val = str(val).replace('<h3 class="MsoNormal">&nbsp;</div>', "")
val = str(val).replace('<h3>',
'<div style="font-family: DM Sans; font-style: normal;font-weight: 600; font-size: 24px; line-height: 28px; color: #16274F; text-align: left; margin-bottom: 10px;"> ')
val = str(val).replace("</h3>", "</div>")
print(" ===================================================")
print(" val = ", val)
PROD_dbname['articles_avis'].find_one_and_update({'_id': ObjectId(str(tmp['_id'])),},
{"$set": {'avis':val}},
return_document=ReturnDocument.AFTER,
upsert=True,
)
return True, "OK"
except Exception as e:
exc_type, exc_obj, exc_tb = sys.exc_info()
print(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
return False, " Impossible de Conformite_Article_Blog PROD_dbname"