24/08/22 17h
parent
2fc85a666b
commit
192c7db3d4
47
class_mgt.py
47
class_mgt.py
|
@ -99,6 +99,25 @@ def add_class(diction):
|
|||
mycommon.myprint(str(inspect.stack()[0][3]) + " - Impossible de recuperer le recid du partenaire")
|
||||
return False, " Les informations d'identification sont incorrectes"
|
||||
|
||||
part_status, part_pack, part_pack_nb_training_auto = mycommon.Partner_Get_pack_nbTraining(user_recid)
|
||||
if( part_status is False):
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - Impossible de recuperer le pack et le nombre de formation du partenaire")
|
||||
return False, " Les informations d'identification sont incorrectes"
|
||||
"""
|
||||
Recuperation du nombre de formations actif de ce partner
|
||||
"""
|
||||
part_status2, part_nb_active_training = mycommon.Get_partner_nb_active_training(user_recid)
|
||||
if (part_status2 is False):
|
||||
mycommon.myprint(str(
|
||||
inspect.stack()[0][3]) + " - Impossible de recuperer le pack et le nombre de formation du partenaire")
|
||||
return False, " Les informations d'identification sont incorrectes"
|
||||
|
||||
if( mycommon.tryInt(part_nb_active_training) >= mycommon.tryInt(part_pack_nb_training_auto) ):
|
||||
mycommon.myprint(str(
|
||||
inspect.stack()[0][3]) + " - Vous avez atteint le nombre maximum de formation autorisé")
|
||||
return False, " Vous avez atteint le nombre maximum de formation autorisé ("+str(part_pack_nb_training_auto)+"" \
|
||||
"). La formation '"+str(diction['external_code'])+"' n'a pas été enregistrée"
|
||||
|
||||
mydata['partner_owner_recid'] = user_recid
|
||||
|
||||
class_internal_url = ""
|
||||
|
@ -1559,6 +1578,34 @@ def add_class_mass(file=None, Folder=None, diction=None):
|
|||
str(inspect.stack()[0][3])+" : entete du fichier csv. '" + val + "' n'est pas acceptée")
|
||||
return False, " Entete du fichier csv. '" + val + "' n'est pas acceptée"
|
||||
|
||||
# Recuperation du recid de l'utilisateur
|
||||
user_recid = mycommon.get_parnter_recid_from_token(diction['token'])
|
||||
if user_recid is False:
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " - Impossible de recuperer le token du partenaire")
|
||||
return False, " Les informations d'identification sont incorrectes"
|
||||
|
||||
part_status, part_pack, part_pack_nb_training_auto = mycommon.Partner_Get_pack_nbTraining(user_recid)
|
||||
if (part_status is False):
|
||||
mycommon.myprint(str(
|
||||
inspect.stack()[0][3]) + " - Impossible de recuperer le pack et le nombre de formation du partenaire")
|
||||
return False, " Les informations d'identification sont incorrectes"
|
||||
|
||||
"""
|
||||
Recuperation du nombre de formations actif de ce partner
|
||||
"""
|
||||
part_status2, part_nb_active_training = mycommon.Get_partner_nb_active_training(user_recid)
|
||||
if (part_status2 is False):
|
||||
mycommon.myprint(str(
|
||||
inspect.stack()[0][3]) + " - Impossible de recuperer le pack et le nombre de formation du partenaire")
|
||||
return False, " Les informations d'identification sont incorrectes"
|
||||
|
||||
new_nb_active = mycommon.tryInt(part_nb_active_training) + total_rows
|
||||
if ( new_nb_active > mycommon.tryInt(part_pack_nb_training_auto) ):
|
||||
mycommon.myprint(str(
|
||||
inspect.stack()[0][3]) + " - Vous avez atteint le nombre maximum de formation autorisé")
|
||||
return False, " Vous avez atteint le nombre maximum de formation autorisé (" + str(
|
||||
new_nb_active) + "). "
|
||||
|
||||
x = range(0, total_rows)
|
||||
|
||||
|
|
|
@ -543,7 +543,23 @@ def createOrder(diction):
|
|||
|
||||
if ret_val and ret_val.inserted_id:
|
||||
print( "str(new_data['invoice_email']) = "+str(new_data['invoice_email']))
|
||||
# Envoie de l'email
|
||||
email.SalesOrderConfirmationEmail(str(new_data['invoice_email']), new_data )
|
||||
|
||||
# Mise à jour du partenaire (ajouter le nouveau pack)
|
||||
if ("pack" in diction.keys()):
|
||||
if diction['pack']:
|
||||
mypack = diction['pack']
|
||||
coll_partner = MYSY_GV.dbname['partnair_account']
|
||||
ret_val = coll_partner.find_one_and_update(
|
||||
{'recid': str(user_recid), },
|
||||
{"$set": {'pack_service':str(mypack)}},
|
||||
upsert=False,
|
||||
return_document=ReturnDocument.AFTER
|
||||
)
|
||||
|
||||
|
||||
|
||||
return True, "la commande été correctement créee", str(new_data['order_id'])
|
||||
else:
|
||||
mycommon.myprint(
|
||||
|
|
|
@ -1562,6 +1562,68 @@ def Get_Suggested_Word():
|
|||
|
||||
return True, insertObject
|
||||
|
||||
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, False
|
||||
|
||||
|
||||
'''
|
||||
Cette fonction prendre le recid d'un partenaire et retourne
|
||||
- son pack
|
||||
- le nombre de formation accordé
|
||||
'''
|
||||
def Partner_Get_pack_nbTraining(partner_recid):
|
||||
try:
|
||||
|
||||
if( len(str(partner_recid)) <= 0):
|
||||
return False, "", ""
|
||||
|
||||
partner_pack = ""
|
||||
partner_pack_nb_formation = ""
|
||||
coll_partner = MYSY_GV.dbname['partnair_account']
|
||||
tmp = coll_partner.find({'recid':str(partner_recid)})
|
||||
|
||||
print("tmp = " + str(tmp[0]))
|
||||
|
||||
if(tmp and tmp[0] ):
|
||||
partner_pack = tmp[0]['pack_service']
|
||||
partner_pack = str(partner_pack).lower()
|
||||
print(" partner_pack = "+partner_pack)
|
||||
coll_pack = MYSY_GV.dbname['pack']
|
||||
tmp_pack = coll_pack.find({'code_pack':str(partner_pack)})
|
||||
print("tmp_pack = "+str(tmp_pack[0]))
|
||||
if( tmp_pack and tmp_pack[0]):
|
||||
partner_pack_nb_formation = tmp_pack[0]['nb_formation']
|
||||
else:
|
||||
return False, partner_pack, partner_pack_nb_formation
|
||||
else:
|
||||
return False, partner_pack, partner_pack_nb_formation
|
||||
|
||||
|
||||
return True, partner_pack, partner_pack_nb_formation
|
||||
|
||||
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, False, False
|
||||
|
||||
|
||||
""""
|
||||
Cette fonction prend un recid et retourne le nombre de formation deja actif.
|
||||
"""
|
||||
def Get_partner_nb_active_training(partner_recid):
|
||||
try:
|
||||
|
||||
if( len(str(partner_recid)) <= 0):
|
||||
return False, ""
|
||||
|
||||
partner_class_nb_formation = ""
|
||||
coll_partner_class = MYSY_GV.dbname['myclass']
|
||||
tmp = coll_partner_class.count_documents({'partner_owner_recid':str(partner_recid), 'valide':'1'})
|
||||
|
||||
return True, str(tmp)
|
||||
|
||||
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))
|
||||
|
|
Loading…
Reference in New Issue