28/05/23 - 15h

master
cherif 2023-05-28 15:37:15 +02:00
parent da40cfd17a
commit 3a8fdc9233
6 changed files with 1165 additions and 15 deletions

View File

@ -3,9 +3,11 @@
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="25/05/23 - 17h"> <list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="25/05/23 - 17h">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <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$/Log/log_file.log" beforeDir="false" afterPath="$PROJECT_DIR$/Log/log_file.log" 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$/Session_Formation.py" beforeDir="false" afterPath="$PROJECT_DIR$/Session_Formation.py" 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$/business_prices.py" beforeDir="false" afterPath="$PROJECT_DIR$/business_prices.py" afterDir="false" /> <change beforePath="$PROJECT_DIR$/email_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/email_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" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />

View File

@ -312,9 +312,10 @@ if (MYSY_ENV == "PROD"):
MYSY_MARIADB_HOST = "192.168.1.21" MYSY_MARIADB_HOST = "192.168.1.21"
MYSY_MARIADB_PORT = 3306 MYSY_MARIADB_PORT = 3306
MYSY_LMS_BDD = "mysy_db_chamilo_prod" MYSY_LMS_BDD = "mysy_db_chamilo_prod"
MYSY_LMS_URL = "" MYSY_LMS_URL = "https://prodlms.mysy-hosting.fr/"
MYSY_LMS_BASE_DIRECTORY = "/var/www/html/chamilo_mysy_prod/" MYSY_LMS_BASE_DIRECTORY = "/var/www/html/chamilo_mysy_prod/"
LMS_BAS_URL = "mysy-training.fr/" LMS_BAS_URL = "mysy-hosting.fr/"
""" DEV on localHost """ DEV on localHost
elif (MYSY_ENV == "DEV"): elif (MYSY_ENV == "DEV"):

File diff suppressed because one or more lines are too long

View File

@ -472,7 +472,7 @@ def createOrder(diction):
if val not in diction: if val not in diction:
mycommon.myprint( mycommon.myprint(
str(inspect.stack()[0][3]) + " - La valeur '" + val + "' n'est pas presente dans liste ") str(inspect.stack()[0][3]) + " - La valeur '" + val + "' n'est pas presente dans liste ")
return False, " Impossible de créer la facture" return False, " Impossible de créer la facture", False
# recuperation des paramettre # recuperation des paramettre
my_token = "" my_token = ""
@ -489,17 +489,17 @@ def createOrder(diction):
if retval is False: if retval is False:
mycommon.myprint(str(inspect.stack()[0][3]) + " - Le token n'est pas valide") mycommon.myprint(str(inspect.stack()[0][3]) + " - Le token n'est pas valide")
return False, " Impossible de créer la facture" return False, " Impossible de créer la facture", False
# Recuperation du recid de l'utilisateur # Recuperation du recid de l'utilisateur
user_recid = mycommon.get_parnter_recid_from_token(my_token) user_recid = mycommon.get_parnter_recid_from_token(my_token)
if user_recid is False: if user_recid is False:
mycommon.myprint(str(inspect.stack()[0][3]) + " - Impossible de recuperer le token de l'utilisateur") mycommon.myprint(str(inspect.stack()[0][3]) + " - Impossible de recuperer le token de l'utilisateur")
return False," Impossible de créer la facture" return False," Impossible de créer la facture", False
if (len(str(my_token)) <= 0): if (len(str(my_token)) <= 0):
mycommon.myprint(str(inspect.stack()[0][3]) + " - Le token est vide") mycommon.myprint(str(inspect.stack()[0][3]) + " - Le token est vide")
return False, " Impossible de créer la facture" return False, " Impossible de créer la facture", False
new_data = {} new_data = {}
if ("nb_product" in diction.keys()): if ("nb_product" in diction.keys()):
@ -674,7 +674,16 @@ def createOrder(diction):
# Recuperation ds données de payement # Recuperation ds données de payement
coll_part_payment = MYSY_GV.dbname['payement_mode'] coll_part_payment = MYSY_GV.dbname['payement_mode']
local_count = coll_part_payment.count_documents({'client_recid': user_recid, 'valide': '1'})
if (local_count <= 0):
mycommon.myprint(
str(inspect.stack()[0][3]) + "Aucun mode de payement pour ce client, Impossible de créer la commande ")
return False, "Aucun mode de payement pour ce client ", None
part_account = coll_part_payment.find({'client_recid': user_recid, 'valide': '1'}) part_account = coll_part_payment.find({'client_recid': user_recid, 'valide': '1'})
#print(" new_data['total_ht'] = "+str(new_data['total_ht']) + " -- new_data['total_tva'] " #print(" new_data['total_ht'] = "+str(new_data['total_ht']) + " -- new_data['total_tva'] "
# +str(new_data['total_tva'])+ " -- new_data['total_ttc'] = "+ str(new_data['total_ttc'])) # +str(new_data['total_tva'])+ " -- new_data['total_ttc'] = "+ str(new_data['total_ttc']))
@ -778,7 +787,7 @@ def createOrder(diction):
except Exception as e: except Exception as e:
exc_type, exc_obj, exc_tb = sys.exc_info() exc_type, exc_obj, exc_tb = sys.exc_info()
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno)) mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
return False, " Impossible de créer la facture" return False, " Impossible de créer la facture", False

View File

@ -2418,6 +2418,7 @@ def Email_Part_Espace_Hosting( diction):
mycommon.myprint(str(inspect.stack()[0][3]) + " - impossible de recuperer les données du partenaire") mycommon.myprint(str(inspect.stack()[0][3]) + " - impossible de recuperer les données du partenaire")
return False, str(inspect.stack()[0][3]) + " - impossible de recuperer les données du partenaire" return False, str(inspect.stack()[0][3]) + " - impossible de recuperer les données du partenaire"
print(" ### in Email_Part_Espace_Hosting my_partner data = ", my_partner)
nom = "" nom = ""
if ("nom" in my_partner.keys()): if ("nom" in my_partner.keys()):
nom = my_partner['nom'] nom = my_partner['nom']
@ -2437,10 +2438,11 @@ def Email_Part_Espace_Hosting( diction):
lms_url = my_partner['lms_virtualhost_url'] lms_url = my_partner['lms_virtualhost_url']
login = "" login = ""
if ("email" in my_partner.keys()): if ("lms_username" in my_partner.keys()):
if( '@' in str(my_partner['email'])): login = my_partner['lms_username']
login_tab = str(my_partner['email']).strip().split('@')
login = login_tab[0]
print(" ### in Email_Part_Espace_Hosting login = ", login)
if( login == ""): if( login == ""):
mycommon.myprint(str(inspect.stack()[0][3]) + " - Le login du partenaire est incorrecte") mycommon.myprint(str(inspect.stack()[0][3]) + " - Le login du partenaire est incorrecte")

View File

@ -30,6 +30,7 @@ import paramiko
from Levenshtein import distance as lev from Levenshtein import distance as lev
import class_mgt as class_mgt import class_mgt as class_mgt
import Session_Formation as Session_Formation import Session_Formation as Session_Formation
from unidecode import unidecode
""" """
Test connexion SQL sur localhost Phpmyadmin Test connexion SQL sur localhost Phpmyadmin
""" """
@ -172,6 +173,7 @@ def Create_MySy_LMS_User(diction):
username = str(str(username)+"_"+str(suffix_nom_partner)).lower() username = str(str(username)+"_"+str(suffix_nom_partner)).lower()
username = unidecode(username)
registration_date = datetime.now().strftime("%Y-%m-%d %H:%M:%S") registration_date = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
@ -347,6 +349,7 @@ def Create_MySy_LMS_User(diction):
virutal_host_url = "" virutal_host_url = ""
local_data = {} local_data = {}
local_data['token'] = my_token local_data['token'] = my_token
local_data['lms_username'] = username
local_status, local_message, local_virtualhost_id, local_virtualhost_full_url = LMS_Create_VirtualHost(local_data) local_status, local_message, local_virtualhost_id, local_virtualhost_full_url = LMS_Create_VirtualHost(local_data)
if (local_status is False): if (local_status is False):
mycommon.myprint(str(inspect.stack()[0][3]) + " - WARNING : impossible de créer le virtualHost dans le LMS ") mycommon.myprint(str(inspect.stack()[0][3]) + " - WARNING : impossible de créer le virtualHost dans le LMS ")
@ -2129,7 +2132,7 @@ def LMS_Create_VirtualHost(diction):
# Ici on doit mettre tous les champs possible (obligatoire ou non) de la BDD dans la liste # Ici on doit mettre tous les champs possible (obligatoire ou non) de la BDD dans la liste
# field_list. # field_list.
''' '''
field_list = ['token'] field_list = ['token', 'lms_username']
incom_keys = diction.keys() incom_keys = diction.keys()
for val in incom_keys: for val in incom_keys:
if val not in field_list: if val not in field_list:
@ -2141,7 +2144,7 @@ def LMS_Create_VirtualHost(diction):
Une fois qu'on a controlé que toutes les clés mise dans l'API sont correcte. etape precedente, 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 On controle que les champs obligatoires sont presents dans la liste
''' '''
field_list_obligatoire = ['token'] field_list_obligatoire = ['token', 'lms_username']
for val in field_list_obligatoire: for val in field_list_obligatoire:
if val not in diction: if val not in diction:
mycommon.myprint( mycommon.myprint(
@ -2153,6 +2156,11 @@ def LMS_Create_VirtualHost(diction):
if diction['token']: if diction['token']:
my_token = diction['token'] my_token = diction['token']
lms_username = ""
if ("lms_username" in diction.keys()):
if diction['lms_username']:
lms_username = diction['lms_username']
partner_recid = mycommon.get_parnter_recid_from_token(my_token) partner_recid = mycommon.get_parnter_recid_from_token(my_token)
if (partner_recid is False): if (partner_recid is False):
mycommon.myprint( mycommon.myprint(
@ -2233,6 +2241,7 @@ def LMS_Create_VirtualHost(diction):
print(" #### le prefixe d'url : '"+str(lms_prefixe_url)+"' N'EXISTE PAS. On va créer l'url") print(" #### le prefixe d'url : '"+str(lms_prefixe_url)+"' N'EXISTE PAS. On va créer l'url")
registration_date = datetime.now().strftime("%Y-%m-%d %H:%M:%S") registration_date = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
full_url = str("https://"+str(lms_prefixe_url)+"."+str(MYSY_GV.LMS_BAS_URL)).lower() full_url = str("https://"+str(lms_prefixe_url)+"."+str(MYSY_GV.LMS_BAS_URL)).lower()
full_url = unidecode(full_url)
virtualHost_url = full_url virtualHost_url = full_url
my_query = " INSERT INTO access_url (url, description, active, created_by, tms, url_type) "\ my_query = " INSERT INTO access_url (url, description, active, created_by, tms, url_type) "\
@ -2262,6 +2271,8 @@ def LMS_Create_VirtualHost(diction):
mysy_coll_query['lms_virtualhost_id'] = str(virtualHost_Id) mysy_coll_query['lms_virtualhost_id'] = str(virtualHost_Id)
mysy_coll_query['lms_virtualhost_url'] = str(virtualHost_url) mysy_coll_query['lms_virtualhost_url'] = str(virtualHost_url)
mysy_coll_query['date_update'] = str(datetime.now()) mysy_coll_query['date_update'] = str(datetime.now())
mysy_coll_query['lms_username'] = str(lms_username)
ret_val = MYSY_GV.dbname['partnair_account'].find_one_and_update( ret_val = MYSY_GV.dbname['partnair_account'].find_one_and_update(
{'token': diction['token'], 'active': '1', 'locked': '0'}, {'token': diction['token'], 'active': '1', 'locked': '0'},
{"$set": mysy_coll_query}, {"$set": mysy_coll_query},