diff --git a/.idea/misc.xml b/.idea/misc.xml index f6104af..6b12f5d 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,6 +1,6 @@ - + diff --git a/.idea/myclass_api.iml b/.idea/myclass_api.iml index 7eb1baf..1467ed4 100644 --- a/.idea/myclass_api.iml +++ b/.idea/myclass_api.iml @@ -4,7 +4,7 @@ - + \ No newline at end of file diff --git a/class_mgt.py b/class_mgt.py index de6ed68..2137ec0 100644 --- a/class_mgt.py +++ b/class_mgt.py @@ -2209,4 +2209,73 @@ def get_class_by_metier(diction): except Exception as e: exc_type, exc_obj, exc_tb = sys.exc_info() mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno)) - return False, "Impossible de recuperer les formations par metier" \ No newline at end of file + return False, "Impossible de recuperer les formations par metier" + + + + +""" +Cette fonction modifier le ranking des formations d'un partenaire en masse. +Par exemple, lorqu'il change d'abonnement et passe +du standard au gold, toutes ses formation prenne le ranking des golds. +""" +def UpdataPartnerRankingClass(diction): + try: + + ''' + 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 = ['partnaire_recid', 'new_pack_name'] + + + 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, "Impossible de mettre à jour le rang des formations" + + # Recuperation du rang associé au pack + + new_ranking_value = "" + coll_pack = MYSY_GV.dbname["pack"] + tmp = coll_pack.count_documents({"code_pack":str(diction["new_pack_name"]).lower()}) + + if( tmp <= 0 ): + mycommon.myprint( + str(inspect.stack()[0][3]) + " - le pack "+str(diction["new_pack_name"]).lower()+ " n'est pas paramettré corretement") + return False, "Impossible de mettre à jour le rang des formations" + + ranking_tab = None + + ranking_tab = coll_pack.find({"code_pack":str(diction["new_pack_name"]).lower()}) + + + if( ranking_tab and ranking_tab[0] and ranking_tab[0]["ranking"] ): + new_ranking_value = str(ranking_tab[0]["ranking"]) + else: + mycommon.myprint( + str(inspect.stack()[0][3]) + " - le pack " + str( + diction["new_pack_name"]) + " n'est pas paramettré corretement - V2") + return False, "Impossible de mettre à jour le rang des formations" + + + coll_class = MYSY_GV.dbname['myclass'] + + now = datetime.now() + update_data = {"display_rank":str(new_ranking_value), "date_update":str(now)} + + ret_val = coll_class.update_many( + {"partner_owner_recid": str(diction['partnaire_recid']), "valide":"1"}, + {"$set": update_data}, ) + + mycommon.myprint( + str(inspect.stack()[0][3]) + " - Le RANKING de "+str(ret_val.matched_count)+" ont été mise à jour avec la valeur "+str(update_data)) + + + return True, " Mise à jour du display_rank OK" + + except Exception as e: + exc_type, exc_obj, exc_tb = sys.exc_info() + mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno)) + return False, "Impossible de mettre à jour le rang des formations" \ No newline at end of file diff --git a/ela_factures_mgt.py b/ela_factures_mgt.py index 11369a0..bcd9319 100644 --- a/ela_factures_mgt.py +++ b/ela_factures_mgt.py @@ -26,6 +26,7 @@ import ftplib import pysftp from flask import send_file from dateutil.relativedelta import relativedelta +import class_mgt as class_mgt class JSONEncoder(json.JSONEncoder): @@ -245,6 +246,24 @@ def add_payement_mode(diction): print("mode de payement data :"+str(new_data)) + print("str(new_data['num_carte']) = "+str(new_data['num_carte']) ) + print("str(new_data['nom_carte']) = " + str(new_data['nom_carte']) ) + + """if( str(new_data['type']) == "cb"): + if( len(str(new_data['num_carte'])) <= 0 or len(str(new_data['nom_carte'])) ): + mycommon.myprint( + str(inspect.stack()[0][3]) + " : Les données de la carte sont incorrectes") + return False, "Impossible d'ajouter le mode de paiement. Les données de la carte sont incorrectes" + + if (str(new_data['type']) == "sepa"): + if (len(str(new_data['iban'])) <= 0 or len(str(new_data['bic'])) + or len(str(new_data['nom_compte'])) ): + mycommon.myprint( + str(inspect.stack()[0][3]) + " : Les données bancaires sont incorrectes") + return False, "Impossible d'ajouter le mode de paiement. Les données bancaires sont incorrectes" + """ + + ret_val = coll_name.find_one_and_update( {'client_recid': user_recid, 'valide': '1'}, {"$set": new_data}, @@ -604,6 +623,10 @@ def createOrder(diction): if (total_ttc_float > 0): CreateInvoice(new_data) + # Apres la facturation, on met à jour le display_ranking des formations du partenaire. + tmp_diction = {"partnaire_recid":str(user_recid), "new_pack_na" + "me":str(mypack)} + class_mgt.UpdataPartnerRankingClass(tmp_diction) return True, "la commande été correctement créee", str(new_data['order_id']) else: mycommon.myprint( diff --git a/prj_common.py b/prj_common.py index 27ffc3c..64fd990 100644 --- a/prj_common.py +++ b/prj_common.py @@ -2201,8 +2201,3 @@ def correction_collection(): 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, False - - -""" -cherif -""" \ No newline at end of file