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"
|
||||
#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']
|
||||
|
@ -412,7 +420,7 @@ def add_class(diction):
|
|||
#Indexation Title de la nouvelle formation ajoutée
|
||||
training_to_index_title = {}
|
||||
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)
|
||||
|
||||
return True, "La formation a bien été ajoutée"
|
||||
|
@ -709,6 +717,23 @@ def update_class(diction):
|
|||
mydata['isalaune'] = "1"
|
||||
#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']
|
||||
|
@ -745,6 +770,7 @@ def update_class(diction):
|
|||
|
||||
|
||||
|
||||
|
||||
'''
|
||||
Desactivation d'une formation
|
||||
|
||||
|
|
|
@ -40,8 +40,9 @@ def ela_index_class(external_code="", source_field = ""):
|
|||
myobjectif = {}
|
||||
myobjectif['indexed'] = '1'
|
||||
|
||||
ret_val2 = collection.find_and_modify(query={"external_code":external_code},
|
||||
update={"$set": myobjectif}
|
||||
ret_val2 = collection.find_one_and_update({"external_code":external_code},
|
||||
{"$set": myobjectif},
|
||||
return_document=ReturnDocument.AFTER
|
||||
)
|
||||
|
||||
if (ret_val2 and ret_val2['_id']):
|
||||
|
@ -65,8 +66,9 @@ def ela_index_class(external_code="", source_field = ""):
|
|||
myobjectif = {}
|
||||
myobjectif['indexed_title'] = '1'
|
||||
|
||||
ret_val2 = collection.find_and_modify(query={"external_code": external_code},
|
||||
update={"$set": myobjectif}
|
||||
ret_val2 = collection.find_one_and_update({"external_code": external_code},
|
||||
{"$set": myobjectif},
|
||||
return_document=ReturnDocument.AFTER
|
||||
)
|
||||
|
||||
if (ret_val2 and ret_val2['_id']):
|
||||
|
@ -90,8 +92,9 @@ def ela_index_class(external_code="", source_field = ""):
|
|||
myobjectif = {}
|
||||
myobjectif['indexed_desc'] = '1'
|
||||
|
||||
ret_val2 = collection.find_and_modify(query={"external_code": external_code},
|
||||
update={"$set": myobjectif}
|
||||
ret_val2 = collection.find_one_and_update({"external_code": external_code},
|
||||
{"$set": myobjectif},
|
||||
return_document=ReturnDocument.AFTER
|
||||
)
|
||||
|
||||
if (ret_val2 and ret_val2['_id']):
|
||||
|
@ -116,8 +119,9 @@ def ela_index_class(external_code="", source_field = ""):
|
|||
myobjectif = {}
|
||||
myobjectif['indexed_obj'] = '1'
|
||||
|
||||
ret_val2 = collection.find_and_modify(query={"external_code": external_code},
|
||||
update={"$set": myobjectif}
|
||||
ret_val2 = collection.find_one_and_update({"external_code": external_code},
|
||||
{"$set": myobjectif},
|
||||
return_document=ReturnDocument.AFTER
|
||||
)
|
||||
|
||||
if (ret_val2 and ret_val2['_id']):
|
||||
|
@ -142,8 +146,9 @@ def ela_index_class(external_code="", source_field = ""):
|
|||
myobjectif = {}
|
||||
myobjectif['indexed_keyword'] = '1'
|
||||
|
||||
ret_val2 = collection.find_and_modify(query={"external_code": external_code},
|
||||
update={"$set": myobjectif}
|
||||
ret_val2 = collection.find_one_and_update({"external_code": external_code},
|
||||
{"$set": myobjectif},
|
||||
return_document=ReturnDocument.AFTER
|
||||
)
|
||||
|
||||
if (ret_val2 and ret_val2['_id']):
|
||||
|
@ -167,8 +172,9 @@ def ela_index_class(external_code="", source_field = ""):
|
|||
myobjectif = {}
|
||||
myobjectif['indexed_video_text'] = '1'
|
||||
|
||||
ret_val2 = collection.find_and_modify(query={"external_code": external_code},
|
||||
update={"$set": myobjectif}
|
||||
ret_val2 = collection.find_one_and_update({"external_code": external_code},
|
||||
{"$set": myobjectif},
|
||||
return_document=ReturnDocument.AFTER
|
||||
)
|
||||
|
||||
if (ret_val2 and ret_val2['_id']):
|
||||
|
@ -337,7 +343,7 @@ def ela_index_given_classes_title(diction) :
|
|||
# Making a Connection with MongoClient
|
||||
try:
|
||||
# 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()
|
||||
|
||||
'''
|
||||
|
@ -366,11 +372,11 @@ def ela_index_given_classes_title(diction) :
|
|||
check = True
|
||||
partner_owner_recid = diction['partner_owner_recid']
|
||||
|
||||
reindex = ""
|
||||
if ("reindex" in diction.keys()):
|
||||
if diction['reindex']:
|
||||
reindex_all = ""
|
||||
if ("reindex_all" in diction.keys()):
|
||||
if diction['reindex_all']:
|
||||
check = True
|
||||
reindex = diction['reindex']
|
||||
reindex_all = diction['reindex_all']
|
||||
|
||||
if( check is False ):
|
||||
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):
|
||||
myquery['partner_owner_recid'] = partner_owner_recid
|
||||
|
||||
if (reindex and len(str(reindex)) > 0):
|
||||
if(reindex == "0" ):
|
||||
if (reindex_all and len(str(reindex_all)) > 0):
|
||||
if(reindex_all != "1" ):
|
||||
myquery['indexed_title'] = "0"
|
||||
|
||||
#print(" QUERY INDEX TITLE ="+str(myquery))
|
||||
print(" QUERY INDEX TITLE ="+str(myquery))
|
||||
|
||||
for doc in collection.find(myquery):
|
||||
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"
|
||||
|
||||
|
||||
|
||||
'''
|
||||
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"
|
||||
|
@ -916,8 +923,9 @@ def ela_index_articles_avis(titre_formation="", source_field = ""):
|
|||
myobjectif = {}
|
||||
myobjectif['indexed'] = '1'
|
||||
|
||||
ret_val2 = collection.find_and_modify(query={"title_formation":titre_formation, "valide":"1"},
|
||||
update={"$set": myobjectif}
|
||||
ret_val2 = collection.find_one_and_update({"title_formation":titre_formation, "valide":"1"},
|
||||
{"$set": myobjectif},
|
||||
return_document=ReturnDocument.AFTER
|
||||
)
|
||||
|
||||
if (ret_val2 and ret_val2['_id']):
|
||||
|
|
|
@ -199,13 +199,16 @@ def desable_user_objectif(diction):
|
|||
mycommon.myprint(" on recherche " + user_recid)
|
||||
|
||||
# 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):
|
||||
# mycommon.myprint(" MIS A J "+str(myobjectif))
|
||||
# Il s'agit d'une mise à jour
|
||||
ret_val = coll_name.find_and_modify(query={'user_recid': user_recid, 'name': name, 'active': '1'},
|
||||
update={"$set": myobjectif}
|
||||
ret_val = coll_name.find_one_and_update({'user_recid': user_recid, 'name': name, 'active': '1'},
|
||||
{"$set": myobjectif},
|
||||
return_document=ReturnDocument.AFTER
|
||||
)
|
||||
|
||||
if (ret_val and ret_val['_id']):
|
||||
|
@ -304,21 +307,22 @@ def add_update_user_objectif(diction):
|
|||
mycommon.myprint(" on recherche recid "+user_recid)
|
||||
|
||||
# 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))
|
||||
if( tmp > 3 ):
|
||||
mycommon.myprint(" L'utilisateur '"+user_recid+"' 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
|
||||
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(" filetr"+str(email_user)+" name "+name)
|
||||
if( tmp > 0 ):
|
||||
#mycommon.myprint(" MIS A J "+str(myobjectif))
|
||||
# Il s'agit d'une mise à jour
|
||||
ret_val = coll_name.find_and_modify(query={'user_recid': user_recid, 'name':name, 'active': '1'},
|
||||
update={"$set":myobjectif }
|
||||
ret_val = coll_name.find_one_and_update({'user_recid': user_recid, 'name':name, 'active': '1'},
|
||||
{"$set":myobjectif },
|
||||
return_document=ReturnDocument.AFTER
|
||||
)
|
||||
|
||||
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é "
|
||||
|
||||
|
||||
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")
|
||||
return False, "Impossible de valider ce compte "
|
||||
|
||||
|
||||
tmp = coll_name.find({'_id': ObjectId(str(value)), 'active': '0'})
|
||||
partner_email = 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();
|
||||
|
||||
now = datetime.now()
|
||||
ret_val = coll_name.find_and_modify(query={'_id':ObjectId(str(value)), 'locked':'0'},
|
||||
update={"$set":
|
||||
ret_val = coll_name.find_one_and_update({'_id':ObjectId(str(value)), 'locked':'0'},
|
||||
{"$set":
|
||||
{'active': "1","date_update":str(now),
|
||||
'token':str(my_token),
|
||||
'stripe_account_id':part_stripe_account_id,
|
||||
}
|
||||
}
|
||||
},
|
||||
return_document=ReturnDocument.AFTER
|
||||
)
|
||||
|
||||
if( ret_val and ret_val['_id']):
|
||||
|
|
|
@ -10,7 +10,7 @@ from autocorrect import Speller
|
|||
from datetime import datetime
|
||||
import re
|
||||
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['indexed_video_text'] = '1'
|
||||
|
||||
ret_val2 = collection.find_and_modify(query={"external_code": external_code},
|
||||
update={"$set": myobjectif}
|
||||
ret_val2 = collection.find_one_and_update({"external_code": external_code},
|
||||
{"$set": myobjectif},
|
||||
return_document=ReturnDocument.AFTER
|
||||
)
|
||||
|
||||
if (ret_val2 and ret_val2['_id']):
|
||||
|
|
Loading…
Reference in New Issue