02/10/2022 - 16h
parent
8edfb8c062
commit
f8c029f9c5
16
class_mgt.py
16
class_mgt.py
|
@ -2046,10 +2046,10 @@ def add_class_mass(file=None, Folder=None, diction=None):
|
|||
|
||||
status, saved_file = mycommon.Upload_Save_CSV_File(file, Folder)
|
||||
if (status == False):
|
||||
return False, "Impossible d'inserer les formation en masse "
|
||||
return False, "Impossible d'inserer les formation en masse, le nom du fichier est incorrect "
|
||||
|
||||
#" Lecture du fichier "
|
||||
print(" Lecture du fichier : "+saved_file)
|
||||
#print(" Lecture du fichier : "+saved_file)
|
||||
nb_line = 0
|
||||
|
||||
df = pd.read_csv(saved_file, encoding='utf8', on_bad_lines='skip', sep=';')
|
||||
|
@ -2065,7 +2065,7 @@ def add_class_mass(file=None, Folder=None, diction=None):
|
|||
|
||||
total_rows = len(df)
|
||||
|
||||
print(df.columns)
|
||||
#print(df.columns)
|
||||
for val in df.columns:
|
||||
if str(val).lower() not in field_list:
|
||||
mycommon.myprint(
|
||||
|
@ -2149,7 +2149,7 @@ def add_class_mass(file=None, Folder=None, diction=None):
|
|||
mydata['img_url'] = ""
|
||||
|
||||
|
||||
print(" ### mydata['img_url'] = '"+str(mydata['img_url'])+"' ")
|
||||
#print(" ### mydata['img_url'] = '"+str(mydata['img_url'])+"' ")
|
||||
if( len(str(mydata['img_url'])) > 0 ):
|
||||
# Verifier si l'image existe
|
||||
status_tmp, img = mycommon.TryUrlImage(str(mydata['img_url']))
|
||||
|
@ -2192,7 +2192,7 @@ def add_class_mass(file=None, Folder=None, diction=None):
|
|||
|
||||
clean_dict = {k: mydata[k] for k in mydata if ( str(mydata[k]) != "nan") }
|
||||
|
||||
print( clean_dict)
|
||||
#print( clean_dict)
|
||||
status, retval = add_class(clean_dict)
|
||||
|
||||
if( status is False ):
|
||||
|
@ -2363,12 +2363,12 @@ def UpdataPartnerRankingClass(diction):
|
|||
myquery = {"recid": str(diction['partnaire_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):
|
||||
new_ranking_value = MYSY_GV.DEMO_RANKING_VALUE
|
||||
print(" myquery pr demo_account 222 = " + str(tmp))
|
||||
#print(" myquery pr demo_account 222 = " + str(tmp))
|
||||
|
||||
|
||||
coll_class = MYSY_GV.dbname['myclass']
|
||||
|
@ -2464,7 +2464,7 @@ def get_associated_class_of_partnair(diction):
|
|||
return False, " Impossible de recuperer la formation"
|
||||
|
||||
tmp_val = coll_name.find_one({'internal_url':my_internal_url},{'partner_owner_recid':1})
|
||||
print(str(tmp_val))
|
||||
#print(str(tmp_val))
|
||||
if( tmp_val and tmp_val['partner_owner_recid']):
|
||||
partner_recid = tmp_val['partner_owner_recid']
|
||||
else:
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
,index,mots,occurence,moyenne,id_formation,source_field
|
||||
0,0,after,1,0.33,VP14120,title
|
||||
1,1,effect,1,0.33,VP14120,title
|
||||
2,2,essentiel,1,0.33,VP14120,title
|
||||
0,0,logo,1,0.5,LS_PA1201913,title
|
||||
1,1,realiser,1,0.5,LS_PA1201913,title
|
||||
|
|
|
|
@ -1,4 +1,3 @@
|
|||
mots occurence moyenne id_formation source_field
|
||||
0 after 1 0.33 VP14120 title
|
||||
1 effect 1 0.33 VP14120 title
|
||||
2 essentiel 1 0.33 VP14120 title
|
||||
mots occurence moyenne id_formation source_field
|
||||
0 logo 1 0.5 LS_PA1201913 title
|
||||
1 realiser 1 0.5 LS_PA1201913 title
|
32
partners.py
32
partners.py
|
@ -695,12 +695,42 @@ def get_partner_account(diction):
|
|||
|
||||
print(" parters RECID = "+str(partnere_recid))
|
||||
|
||||
is_first_connexion = True
|
||||
|
||||
RetObject = []
|
||||
for retVal in coll_name.find({'recid': str(partnere_recid)}):
|
||||
mycommon.myprint (str(retVal))
|
||||
#mycommon.myprint (str(retVal))
|
||||
if ("firstconnexion" in retVal.keys()):
|
||||
if retVal['firstconnexion'] and str(retVal['firstconnexion'] == "0"):
|
||||
is_first_connexion = False
|
||||
|
||||
user = retVal
|
||||
RetObject.append(JSONEncoder().encode(user))
|
||||
|
||||
"""
|
||||
Si la première connexion, alors on met la le champs avec la valeur firstconnexion = 0
|
||||
"""
|
||||
my_new_data = {}
|
||||
now = str(datetime.now())
|
||||
|
||||
if( is_first_connexion is True):
|
||||
my_new_data = {'firstconnexion':'0', 'lastconnexion':now}
|
||||
else:
|
||||
my_new_data = {'lastconnexion': now}
|
||||
|
||||
ret_val = coll_name.find_one_and_update({'recid': str(partnere_recid)},
|
||||
{"$set": my_new_data},
|
||||
upsert=False,
|
||||
return_document=ReturnDocument.AFTER
|
||||
)
|
||||
|
||||
if ret_val and ret_val['_id']:
|
||||
mycommon.myprint("Connexion du partner recid = "+str(partnere_recid)+" OK. Mise à jour du firstconnexion et/ou lastconnexion : OK")
|
||||
|
||||
else:
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) +
|
||||
" WARNING : Impossible de mettre à jour du firstconnexion et/ou lastconnexion du partner recid = "+str(partnere_recid)+". ")
|
||||
|
||||
return True, RetObject
|
||||
|
||||
except Exception as e:
|
||||
|
|
|
@ -74,16 +74,17 @@ def Upload_Save_CSV_File(file=None, Folder=None):
|
|||
'''
|
||||
if(len(basename2) != 2 ):
|
||||
myprint(str(inspect.stack()[0][3]) + " - : Le nom du fichier est incorret")
|
||||
return False, None
|
||||
return False, "Le nom du fichier est incorrect"
|
||||
|
||||
if( str(basename2[1]).lower() != "csv" ):
|
||||
myprint(str(inspect.stack()[0][3]) + " - : Ce n'est pas un fichier csv")
|
||||
return False, None
|
||||
return False, "Le fichier doit être de type '.csv'"
|
||||
|
||||
|
||||
new_basename2= re.sub(r'[^a-zA-Z0-9]', '', str(basename2[0]))
|
||||
|
||||
timestr = time.strftime("%Y%m%d%H%M%S")
|
||||
new_file_name = str(basename2[0]) + "_" + str(timestr) + "." + str(basename2[1])
|
||||
new_file_name = str(new_basename2) + "_" + str(timestr) + "." + str(basename2[1])
|
||||
file.filename = new_file_name
|
||||
file.save(os.path.join(str(Folder), secure_filename(file.filename))) # t
|
||||
|
||||
|
@ -96,7 +97,7 @@ def Upload_Save_CSV_File(file=None, Folder=None):
|
|||
except Exception as e :
|
||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||
myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
|
||||
return False, None
|
||||
return False, "Impossible de traiter le fichier."
|
||||
|
||||
'''
|
||||
Controle de l'import des images.
|
||||
|
@ -1303,7 +1304,7 @@ def recordImage(file=None, Folder=None, diction=None):
|
|||
|
||||
|
||||
# " Lecture du fichier "
|
||||
print(" Lecture du fichier : " + saved_file+". le token est :"+str(mytoken ))
|
||||
#print(" Lecture du fichier : " + saved_file+". le token est :"+str(mytoken ))
|
||||
nb_line = 0
|
||||
coll_name = MYSY_GV.dbname['image_ch']
|
||||
|
||||
|
@ -1425,7 +1426,7 @@ def recordClassImage(file=None, Folder=None, diction=None):
|
|||
return False, "Impossible d'inserer l'image de la formation "
|
||||
|
||||
# " Lecture du fichier "
|
||||
print(" Lecture du fichier : " + saved_file + ". le token est :" + str(mytoken))
|
||||
#print(" Lecture du fichier : " + saved_file + ". le token est :" + str(mytoken))
|
||||
nb_line = 0
|
||||
coll_name = MYSY_GV.dbname['image_ch']
|
||||
|
||||
|
|
Loading…
Reference in New Issue