back_portage
parent
57842d8db4
commit
c2aa12c07e
28
class_mgt.py
28
class_mgt.py
|
@ -381,7 +381,15 @@ def add_class(diction):
|
||||||
mydata['isalaune'] = "1"
|
mydata['isalaune'] = "1"
|
||||||
#print(" myquery pr demo_account 222 = " + str(tmp))
|
#print(" myquery pr demo_account 222 = " + str(tmp))
|
||||||
|
|
||||||
|
else:
|
||||||
|
# Ce n'est pas un compte demo, il faut donc recuperer le display rank tu pack - part_pack
|
||||||
|
coll_pack = MYSY_GV.dbname['pack']
|
||||||
|
local_tmp = coll_pack.find({'code_pack': str(part_pack)})
|
||||||
|
|
||||||
|
if (local_tmp[0] and "ranking" in local_tmp[0].keys()):
|
||||||
|
if local_tmp[0]['ranking']:
|
||||||
|
print(" ### le ranking du pack est " + str(local_tmp[0]['ranking']))
|
||||||
|
mydata['display_rank'] = str(local_tmp[0]['ranking'])
|
||||||
|
|
||||||
|
|
||||||
coll_name = MYSY_GV.dbname['myclass']
|
coll_name = MYSY_GV.dbname['myclass']
|
||||||
|
@ -412,7 +420,7 @@ def add_class(diction):
|
||||||
#Indexation Title de la nouvelle formation ajoutée
|
#Indexation Title de la nouvelle formation ajoutée
|
||||||
training_to_index_title = {}
|
training_to_index_title = {}
|
||||||
training_to_index_title['internal_url'] =mydata['internal_url']
|
training_to_index_title['internal_url'] =mydata['internal_url']
|
||||||
training_to_index_title['reindex'] = '1'
|
training_to_index_title['reindex_all'] = '0'
|
||||||
eibdd.ela_index_given_classes_title(training_to_index_title)
|
eibdd.ela_index_given_classes_title(training_to_index_title)
|
||||||
|
|
||||||
return True, "La formation a bien été ajoutée"
|
return True, "La formation a bien été ajoutée"
|
||||||
|
@ -709,6 +717,23 @@ def update_class(diction):
|
||||||
mydata['isalaune'] = "1"
|
mydata['isalaune'] = "1"
|
||||||
#print(" myquery pr demo_account 222 = " + str(tmp))
|
#print(" myquery pr demo_account 222 = " + str(tmp))
|
||||||
|
|
||||||
|
else:
|
||||||
|
#Ce n'est pas un compte demo, il faut donc recuperer le display rank tu pack - part_pack
|
||||||
|
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"
|
||||||
|
|
||||||
|
|
||||||
|
coll_pack = MYSY_GV.dbname['pack']
|
||||||
|
local_tmp = coll_pack.find({'code_pack':str(part_pack)})
|
||||||
|
|
||||||
|
if (local_tmp[0] and "ranking" in local_tmp[0].keys()):
|
||||||
|
if local_tmp[0]['ranking']:
|
||||||
|
print(" ### le ranking du pack est "+str(local_tmp[0]['ranking']) )
|
||||||
|
mydata['display_rank'] = str(local_tmp[0]['ranking'])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
coll_name = MYSY_GV.dbname['myclass']
|
coll_name = MYSY_GV.dbname['myclass']
|
||||||
|
@ -745,6 +770,7 @@ def update_class(diction):
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
'''
|
'''
|
||||||
Desactivation d'une formation
|
Desactivation d'une formation
|
||||||
|
|
||||||
|
|
|
@ -40,8 +40,9 @@ def ela_index_class(external_code="", source_field = ""):
|
||||||
myobjectif = {}
|
myobjectif = {}
|
||||||
myobjectif['indexed'] = '1'
|
myobjectif['indexed'] = '1'
|
||||||
|
|
||||||
ret_val2 = collection.find_and_modify(query={"external_code":external_code},
|
ret_val2 = collection.find_one_and_update({"external_code":external_code},
|
||||||
update={"$set": myobjectif}
|
{"$set": myobjectif},
|
||||||
|
return_document=ReturnDocument.AFTER
|
||||||
)
|
)
|
||||||
|
|
||||||
if (ret_val2 and ret_val2['_id']):
|
if (ret_val2 and ret_val2['_id']):
|
||||||
|
@ -65,8 +66,9 @@ def ela_index_class(external_code="", source_field = ""):
|
||||||
myobjectif = {}
|
myobjectif = {}
|
||||||
myobjectif['indexed_title'] = '1'
|
myobjectif['indexed_title'] = '1'
|
||||||
|
|
||||||
ret_val2 = collection.find_and_modify(query={"external_code": external_code},
|
ret_val2 = collection.find_one_and_update({"external_code": external_code},
|
||||||
update={"$set": myobjectif}
|
{"$set": myobjectif},
|
||||||
|
return_document=ReturnDocument.AFTER
|
||||||
)
|
)
|
||||||
|
|
||||||
if (ret_val2 and ret_val2['_id']):
|
if (ret_val2 and ret_val2['_id']):
|
||||||
|
@ -90,8 +92,9 @@ def ela_index_class(external_code="", source_field = ""):
|
||||||
myobjectif = {}
|
myobjectif = {}
|
||||||
myobjectif['indexed_desc'] = '1'
|
myobjectif['indexed_desc'] = '1'
|
||||||
|
|
||||||
ret_val2 = collection.find_and_modify(query={"external_code": external_code},
|
ret_val2 = collection.find_one_and_update({"external_code": external_code},
|
||||||
update={"$set": myobjectif}
|
{"$set": myobjectif},
|
||||||
|
return_document=ReturnDocument.AFTER
|
||||||
)
|
)
|
||||||
|
|
||||||
if (ret_val2 and ret_val2['_id']):
|
if (ret_val2 and ret_val2['_id']):
|
||||||
|
@ -116,8 +119,9 @@ def ela_index_class(external_code="", source_field = ""):
|
||||||
myobjectif = {}
|
myobjectif = {}
|
||||||
myobjectif['indexed_obj'] = '1'
|
myobjectif['indexed_obj'] = '1'
|
||||||
|
|
||||||
ret_val2 = collection.find_and_modify(query={"external_code": external_code},
|
ret_val2 = collection.find_one_and_update({"external_code": external_code},
|
||||||
update={"$set": myobjectif}
|
{"$set": myobjectif},
|
||||||
|
return_document=ReturnDocument.AFTER
|
||||||
)
|
)
|
||||||
|
|
||||||
if (ret_val2 and ret_val2['_id']):
|
if (ret_val2 and ret_val2['_id']):
|
||||||
|
@ -142,8 +146,9 @@ def ela_index_class(external_code="", source_field = ""):
|
||||||
myobjectif = {}
|
myobjectif = {}
|
||||||
myobjectif['indexed_keyword'] = '1'
|
myobjectif['indexed_keyword'] = '1'
|
||||||
|
|
||||||
ret_val2 = collection.find_and_modify(query={"external_code": external_code},
|
ret_val2 = collection.find_one_and_update({"external_code": external_code},
|
||||||
update={"$set": myobjectif}
|
{"$set": myobjectif},
|
||||||
|
return_document=ReturnDocument.AFTER
|
||||||
)
|
)
|
||||||
|
|
||||||
if (ret_val2 and ret_val2['_id']):
|
if (ret_val2 and ret_val2['_id']):
|
||||||
|
@ -167,8 +172,9 @@ def ela_index_class(external_code="", source_field = ""):
|
||||||
myobjectif = {}
|
myobjectif = {}
|
||||||
myobjectif['indexed_video_text'] = '1'
|
myobjectif['indexed_video_text'] = '1'
|
||||||
|
|
||||||
ret_val2 = collection.find_and_modify(query={"external_code": external_code},
|
ret_val2 = collection.find_one_and_update({"external_code": external_code},
|
||||||
update={"$set": myobjectif}
|
{"$set": myobjectif},
|
||||||
|
return_document=ReturnDocument.AFTER
|
||||||
)
|
)
|
||||||
|
|
||||||
if (ret_val2 and ret_val2['_id']):
|
if (ret_val2 and ret_val2['_id']):
|
||||||
|
@ -337,7 +343,7 @@ def ela_index_given_classes_title(diction) :
|
||||||
# Making a Connection with MongoClient
|
# Making a Connection with MongoClient
|
||||||
try:
|
try:
|
||||||
# Dictionnaire des champs utilisables
|
# Dictionnaire des champs utilisables
|
||||||
field_list = ['internal_url', 'partner_owner_recid', 'reindex']
|
field_list = ['internal_url', 'partner_owner_recid', 'reindex_all']
|
||||||
incom_keys = diction.keys()
|
incom_keys = diction.keys()
|
||||||
|
|
||||||
'''
|
'''
|
||||||
|
@ -366,11 +372,11 @@ def ela_index_given_classes_title(diction) :
|
||||||
check = True
|
check = True
|
||||||
partner_owner_recid = diction['partner_owner_recid']
|
partner_owner_recid = diction['partner_owner_recid']
|
||||||
|
|
||||||
reindex = ""
|
reindex_all = ""
|
||||||
if ("reindex" in diction.keys()):
|
if ("reindex_all" in diction.keys()):
|
||||||
if diction['reindex']:
|
if diction['reindex_all']:
|
||||||
check = True
|
check = True
|
||||||
reindex = diction['reindex']
|
reindex_all = diction['reindex_all']
|
||||||
|
|
||||||
if( check is False ):
|
if( check is False ):
|
||||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - Aucune formation à indexer")
|
mycommon.myprint(str(inspect.stack()[0][3]) + " - Aucune formation à indexer")
|
||||||
|
@ -404,11 +410,11 @@ def ela_index_given_classes_title(diction) :
|
||||||
if (partner_owner_recid and len(str(partner_owner_recid)) > 0):
|
if (partner_owner_recid and len(str(partner_owner_recid)) > 0):
|
||||||
myquery['partner_owner_recid'] = partner_owner_recid
|
myquery['partner_owner_recid'] = partner_owner_recid
|
||||||
|
|
||||||
if (reindex and len(str(reindex)) > 0):
|
if (reindex_all and len(str(reindex_all)) > 0):
|
||||||
if(reindex == "0" ):
|
if(reindex_all != "1" ):
|
||||||
myquery['indexed_title'] = "0"
|
myquery['indexed_title'] = "0"
|
||||||
|
|
||||||
#print(" QUERY INDEX TITLE ="+str(myquery))
|
print(" QUERY INDEX TITLE ="+str(myquery))
|
||||||
|
|
||||||
for doc in collection.find(myquery):
|
for doc in collection.find(myquery):
|
||||||
if ("title" in doc.keys()):
|
if ("title" in doc.keys()):
|
||||||
|
@ -434,6 +440,7 @@ def ela_index_given_classes_title(diction) :
|
||||||
return False, "Impossible d'indexer la BDD des formations ==> KO"
|
return False, "Impossible d'indexer la BDD des formations ==> KO"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
'''
|
'''
|
||||||
La fonction "ela_index_all_classes_desc" va aller chercher chaque cours dans la BDD
|
La fonction "ela_index_all_classes_desc" va aller chercher chaque cours dans la BDD
|
||||||
et créer les mots clées des "description" qui sont ensuite enregister dans la table "elaindex"
|
et créer les mots clées des "description" qui sont ensuite enregister dans la table "elaindex"
|
||||||
|
@ -916,8 +923,9 @@ def ela_index_articles_avis(titre_formation="", source_field = ""):
|
||||||
myobjectif = {}
|
myobjectif = {}
|
||||||
myobjectif['indexed'] = '1'
|
myobjectif['indexed'] = '1'
|
||||||
|
|
||||||
ret_val2 = collection.find_and_modify(query={"title_formation":titre_formation, "valide":"1"},
|
ret_val2 = collection.find_one_and_update({"title_formation":titre_formation, "valide":"1"},
|
||||||
update={"$set": myobjectif}
|
{"$set": myobjectif},
|
||||||
|
return_document=ReturnDocument.AFTER
|
||||||
)
|
)
|
||||||
|
|
||||||
if (ret_val2 and ret_val2['_id']):
|
if (ret_val2 and ret_val2['_id']):
|
||||||
|
|
|
@ -199,13 +199,16 @@ def desable_user_objectif(diction):
|
||||||
mycommon.myprint(" on recherche " + user_recid)
|
mycommon.myprint(" on recherche " + user_recid)
|
||||||
|
|
||||||
# Verification si ce user a deja une formation du meme nom
|
# Verification si ce user a deja une formation du meme nom
|
||||||
tmp = coll_name.find({'user_recid': user_recid, 'name': name, 'active': '1'}).count()
|
#tmp = coll_name.find({'user_recid': user_recid, 'name': name, 'active': '1'}).count()
|
||||||
|
|
||||||
|
tmp = coll_name.count_documents({'user_recid': user_recid, 'name': name, 'active': '1'})
|
||||||
|
|
||||||
if (tmp > 0):
|
if (tmp > 0):
|
||||||
# mycommon.myprint(" MIS A J "+str(myobjectif))
|
# mycommon.myprint(" MIS A J "+str(myobjectif))
|
||||||
# Il s'agit d'une mise à jour
|
# Il s'agit d'une mise à jour
|
||||||
ret_val = coll_name.find_and_modify(query={'user_recid': user_recid, 'name': name, 'active': '1'},
|
ret_val = coll_name.find_one_and_update({'user_recid': user_recid, 'name': name, 'active': '1'},
|
||||||
update={"$set": myobjectif}
|
{"$set": myobjectif},
|
||||||
|
return_document=ReturnDocument.AFTER
|
||||||
)
|
)
|
||||||
|
|
||||||
if (ret_val and ret_val['_id']):
|
if (ret_val and ret_val['_id']):
|
||||||
|
@ -304,21 +307,22 @@ def add_update_user_objectif(diction):
|
||||||
mycommon.myprint(" on recherche recid "+user_recid)
|
mycommon.myprint(" on recherche recid "+user_recid)
|
||||||
|
|
||||||
# Verification si cette personne a deja plus de 3 objectifs actifs
|
# Verification si cette personne a deja plus de 3 objectifs actifs
|
||||||
tmp = coll_name.find({'user_recid': user_recid, 'active':'1'}).count()
|
tmp = coll_name.count_documents({'user_recid': user_recid, 'active':'1'})
|
||||||
mycommon.myprint(" TMP = "+str(tmp))
|
mycommon.myprint(" TMP = "+str(tmp))
|
||||||
if( tmp > 3 ):
|
if( tmp > 3 ):
|
||||||
mycommon.myprint(" L'utilisateur '"+user_recid+"' a deja plus de 3 objectifs actifs ")
|
mycommon.myprint(" L'utilisateur '"+user_recid+"' a deja plus de 3 objectifs actifs ")
|
||||||
return False, " L'utilisateur a deja plus de 3 objectifs actifs "
|
return False, " L'utilisateur a deja plus de 3 objectifs actifs "
|
||||||
|
|
||||||
# Verification si ce user a deja une formation du meme nom
|
# Verification si ce user a deja une formation du meme nom
|
||||||
tmp = coll_name.find({'user_recid': user_recid, 'name':name, 'active': '1'}).count()
|
tmp = coll_name.count_documents({'user_recid': user_recid, 'name':name, 'active': '1'})
|
||||||
#mycommon.myprint(" recherche update "+str(tmp))
|
#mycommon.myprint(" recherche update "+str(tmp))
|
||||||
#mycommon.myprint(" filetr"+str(email_user)+" name "+name)
|
#mycommon.myprint(" filetr"+str(email_user)+" name "+name)
|
||||||
if( tmp > 0 ):
|
if( tmp > 0 ):
|
||||||
#mycommon.myprint(" MIS A J "+str(myobjectif))
|
#mycommon.myprint(" MIS A J "+str(myobjectif))
|
||||||
# Il s'agit d'une mise à jour
|
# Il s'agit d'une mise à jour
|
||||||
ret_val = coll_name.find_and_modify(query={'user_recid': user_recid, 'name':name, 'active': '1'},
|
ret_val = coll_name.find_one_and_update({'user_recid': user_recid, 'name':name, 'active': '1'},
|
||||||
update={"$set":myobjectif }
|
{"$set":myobjectif },
|
||||||
|
return_document=ReturnDocument.AFTER
|
||||||
)
|
)
|
||||||
|
|
||||||
if (ret_val and ret_val['_id']):
|
if (ret_val and ret_val['_id']):
|
||||||
|
|
13
partners.py
13
partners.py
|
@ -739,13 +739,13 @@ def valide_partnair_account(value):
|
||||||
return False, "Ce compte a deja été activé "
|
return False, "Ce compte a deja été activé "
|
||||||
|
|
||||||
|
|
||||||
tmp = coll_name.find({'_id':ObjectId(str(value)), 'active':'0'})
|
tmp_count = coll_name.count_documents({'_id':ObjectId(str(value)), 'active':'0'})
|
||||||
|
|
||||||
if( tmp.count() <= 0 ):
|
if( tmp_count <= 0 ):
|
||||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - il n'y aucun compte à activer")
|
mycommon.myprint(str(inspect.stack()[0][3]) + " - il n'y aucun compte à activer")
|
||||||
return False, "Impossible de valider ce compte "
|
return False, "Impossible de valider ce compte "
|
||||||
|
|
||||||
|
tmp = coll_name.find({'_id': ObjectId(str(value)), 'active': '0'})
|
||||||
partner_email = tmp[0]['email']
|
partner_email = tmp[0]['email']
|
||||||
|
|
||||||
print(" ########## Email = "+str(tmp[0]['email']))
|
print(" ########## Email = "+str(tmp[0]['email']))
|
||||||
|
@ -787,13 +787,14 @@ def valide_partnair_account(value):
|
||||||
#my_tmp_pwd = mycommon.create_token_urlsafe();
|
#my_tmp_pwd = mycommon.create_token_urlsafe();
|
||||||
|
|
||||||
now = datetime.now()
|
now = datetime.now()
|
||||||
ret_val = coll_name.find_and_modify(query={'_id':ObjectId(str(value)), 'locked':'0'},
|
ret_val = coll_name.find_one_and_update({'_id':ObjectId(str(value)), 'locked':'0'},
|
||||||
update={"$set":
|
{"$set":
|
||||||
{'active': "1","date_update":str(now),
|
{'active': "1","date_update":str(now),
|
||||||
'token':str(my_token),
|
'token':str(my_token),
|
||||||
'stripe_account_id':part_stripe_account_id,
|
'stripe_account_id':part_stripe_account_id,
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
return_document=ReturnDocument.AFTER
|
||||||
)
|
)
|
||||||
|
|
||||||
if( ret_val and ret_val['_id']):
|
if( ret_val and ret_val['_id']):
|
||||||
|
|
|
@ -10,7 +10,7 @@ from autocorrect import Speller
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import re
|
import re
|
||||||
import Ela_Spacy as ls
|
import Ela_Spacy as ls
|
||||||
|
from pymongo import ReturnDocument
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -52,8 +52,9 @@ def YTUBES_ela_index_class_transcription(external_code="", source_field = ""):
|
||||||
myobjectif = {}
|
myobjectif = {}
|
||||||
myobjectif['indexed_video_text'] = '1'
|
myobjectif['indexed_video_text'] = '1'
|
||||||
|
|
||||||
ret_val2 = collection.find_and_modify(query={"external_code": external_code},
|
ret_val2 = collection.find_one_and_update({"external_code": external_code},
|
||||||
update={"$set": myobjectif}
|
{"$set": myobjectif},
|
||||||
|
return_document=ReturnDocument.AFTER
|
||||||
)
|
)
|
||||||
|
|
||||||
if (ret_val2 and ret_val2['_id']):
|
if (ret_val2 and ret_val2['_id']):
|
||||||
|
|
Loading…
Reference in New Issue