parent
0f6e4cd65c
commit
873a0ddd00
|
|
@ -4,11 +4,17 @@
|
|||
<option name="autoReloadType" value="SELECTIVE" />
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="05/07/26 - 20h">
|
||||
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="09/07/26 - 20h">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/GlobalVariable.py" beforeDir="false" afterPath="$PROJECT_DIR$/GlobalVariable.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Inscription_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/Inscription_mgt.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Log/log_file.log" beforeDir="false" afterPath="$PROJECT_DIR$/Log/log_file.log" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/class_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/class_mgt.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/ela_user_account.py" beforeDir="false" afterPath="$PROJECT_DIR$/ela_user_account.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/email_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/email_mgt.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/note_evaluation_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/note_evaluation_mgt.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/prj_common.py" beforeDir="false" afterPath="$PROJECT_DIR$/prj_common.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/session_admission_fi.py" beforeDir="false" afterPath="$PROJECT_DIR$/session_admission_fi.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/wrapper.py" beforeDir="false" afterPath="$PROJECT_DIR$/wrapper.py" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
|
|
@ -453,7 +459,7 @@
|
|||
<option name="project" value="LOCAL" />
|
||||
<updated>1747251650255</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="606" />
|
||||
<option name="localTasksCounter" value="607" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="Vcs.Log.Tabs.Properties">
|
||||
|
|
@ -495,7 +501,6 @@
|
|||
</option>
|
||||
</component>
|
||||
<component name="VcsManagerConfiguration">
|
||||
<MESSAGE value="15/05/2026 - 17h30" />
|
||||
<MESSAGE value="16/05/2026 - 13h30" />
|
||||
<MESSAGE value="19/05/2026 - 20h30" />
|
||||
<MESSAGE value="20/05/2026 - 12h30" />
|
||||
|
|
@ -520,6 +525,7 @@
|
|||
<MESSAGE value="30/06/26 - 20h" />
|
||||
<MESSAGE value="03/07/26 - 20h" />
|
||||
<MESSAGE value="05/07/26 - 20h" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="05/07/26 - 20h" />
|
||||
<MESSAGE value="09/07/26 - 20h" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="09/07/26 - 20h" />
|
||||
</component>
|
||||
</project>
|
||||
|
|
@ -1297,4 +1297,12 @@ OVH_CONSUMER_KEY="0712f5a9e7255894f48bdf0aa7d97cae"
|
|||
OVH_SMS_SERVICE_NAME="sms-bc2043990-1"
|
||||
OVH_SMS_SENDER="EYSY"
|
||||
|
||||
SMS_MESSAGE_MAX_LENGTH = 155
|
||||
SMS_MESSAGE_MAX_LENGTH = 155
|
||||
|
||||
|
||||
"""
|
||||
Type de formation :
|
||||
- formation ou
|
||||
- atelier
|
||||
"""
|
||||
FORMATION_TYPE = ['formation', 'atelier', '']
|
||||
|
|
@ -3029,7 +3029,7 @@ def UpdateStagiairetoClass(diction):
|
|||
'pays', 'ine', 'matricule', 'nom_fille', 'num_cvec', 'handicap_detail', 'num_secu',
|
||||
'is_handicap', 'nationalite', 'situation_famille', 'date_naissance', 'naissance_lieu',
|
||||
'naissance_departement', 'naissance_pays', 'identite_type', 'piece_identite_num',
|
||||
'is_rgpd', 'is_droit_image']
|
||||
'is_rgpd', 'is_droit_image', 'telephone']
|
||||
|
||||
for field in tab_champ:
|
||||
if( str(field) in ret_val2.keys()):
|
||||
|
|
@ -11631,6 +11631,541 @@ def Get_Statgaire_List_Partner_with_filter_uptimized(diction):
|
|||
return False, "Impossible de récupérer la liste des stagiaires"
|
||||
|
||||
|
||||
def Get_Statgaire_List_Partner_with_filter_uptimized_With_Img(diction):
|
||||
try:
|
||||
field_list = ['token', 'class_internal_url', 'code_session', 'status', 'email', 'nom',
|
||||
'class_title', 'code_session', 'client_nom', 'client_rattachement_id',
|
||||
'session_id', 'archive', 'invoiced']
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
if val not in field_list and val.startswith('my_') is False:
|
||||
mycommon.myprint(str(inspect.stack()[0][
|
||||
3]) + " - Le champ '" + val + "' n'est pas autorisé, Creation partenaire annulée")
|
||||
return False, "Toutes les informations fournies ne sont pas valables"
|
||||
|
||||
"""
|
||||
Verification de la liste des champs obligatoires
|
||||
"""
|
||||
field_list_obligatoire = ['token']
|
||||
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 la liste des arguments ")
|
||||
return False, "Toutes les informations necessaires n'ont pas été fournies"
|
||||
|
||||
# Recuperation du recid du partner
|
||||
mydata = {}
|
||||
mytoken = ""
|
||||
if ("token" in diction.keys()):
|
||||
if diction['token']:
|
||||
mytoken = diction['token']
|
||||
|
||||
local_status, my_partner = mycommon.Check_Connexion_And_Return_Partner_Data(diction)
|
||||
if (local_status is not True):
|
||||
return local_status, my_partner
|
||||
|
||||
partner_recid = my_partner['recid']
|
||||
|
||||
"""
|
||||
30/07/2024 - Pour la gestion du recyclage, recuperer les paramettres du partner dans la collection "base_partner_setup"
|
||||
- recyclage_warning
|
||||
- recyclage_warning_lead_time
|
||||
"""
|
||||
recyclage_warning = "0"
|
||||
recyclage_warning_lead_time = "0"
|
||||
partner_base_setup_recyclage_warning = MYSY_GV.dbname['base_partner_setup'].find_one(
|
||||
{"config_name": 'recyclage_warning',
|
||||
'valide': '1', 'locked': '0',
|
||||
'partner_owner_recid': my_partner['recid']})
|
||||
|
||||
if (partner_base_setup_recyclage_warning and "config_value" in partner_base_setup_recyclage_warning.keys()):
|
||||
recyclage_warning = partner_base_setup_recyclage_warning['config_value']
|
||||
|
||||
if (recyclage_warning == "1"):
|
||||
partner_base_setup_recyclage_warning_lead_time = MYSY_GV.dbname['base_partner_setup'].find_one(
|
||||
{"config_name": 'recyclage_warning_lead_time',
|
||||
'valide': '1', 'locked': '0',
|
||||
'partner_owner_recid': my_partner['recid']})
|
||||
|
||||
if (
|
||||
partner_base_setup_recyclage_warning_lead_time and "config_value" in partner_base_setup_recyclage_warning_lead_time.keys()):
|
||||
recyclage_warning_lead_time = str(
|
||||
mycommon.tryInt(str(partner_base_setup_recyclage_warning_lead_time['config_value'])))
|
||||
|
||||
"""
|
||||
Etape 1 : si on a le champ 'code session' saisie par l'utilisateur,
|
||||
alors on va commencer par aller cherche toutes les session avec un regex de la valeur saisie filter sur le partner_recid
|
||||
|
||||
"""
|
||||
filt_session_code = {}
|
||||
list_session_id = []
|
||||
if ("code_session" in diction.keys()):
|
||||
filt_code_session = {'code_session': {'$regex': str(diction['code_session']), "$options": "i"}}
|
||||
|
||||
"""
|
||||
qry_list_session_id = { { '$and' :[ {'code_session': {'$regex': str(diction['code_session']), "$options": "i"}},
|
||||
{'partner_owner_recid': str(partner_recid)} ]}, {'_id':1}}
|
||||
"""
|
||||
|
||||
qry_list_session_id = {"$and": [{'code_session': {'$regex': str(diction['code_session']), "$options": "i"}},
|
||||
{'partner_owner_recid': str(partner_recid)}]}
|
||||
|
||||
# print(" ### qry_list_session_id aa = ", qry_list_session_id)
|
||||
list_session_id_count = MYSY_GV.dbname['session_formation'].count_documents(qry_list_session_id)
|
||||
|
||||
if (list_session_id_count <= 0):
|
||||
# Aucune session
|
||||
return True, []
|
||||
|
||||
for val in MYSY_GV.dbname['session_formation'].find(qry_list_session_id):
|
||||
list_session_id.append(str(val['_id']))
|
||||
|
||||
# print(" ### liste des Id des sessions eligible list_session_id = ", list_session_id)
|
||||
filt_session_code = {'session_id': {'$in': list_session_id, }}
|
||||
|
||||
filt_archive = {}
|
||||
if ("archive" in diction.keys() and (diction["archive"] == "0" or diction["archive"] == "")):
|
||||
filt_archive = {'archive': {'$ne': '1'}}
|
||||
|
||||
elif ("archive" in diction.keys() and diction["archive"] == "1"):
|
||||
filt_archive = {'archive': '1'}
|
||||
|
||||
elif ("archive" not in diction.keys()):
|
||||
filt_archive = {'archive': {'$ne': '1'}}
|
||||
|
||||
filt_class_title = {}
|
||||
if ("class_title" in diction.keys()):
|
||||
filt_class_title = {
|
||||
'title': {'$regex': mycommon.regex_replace_cartere(str(diction['class_title'])), "$options": "i"}}
|
||||
|
||||
filt_class_internal_url = {}
|
||||
if ("class_internal_url" in diction.keys()):
|
||||
filt_class_internal_url = {
|
||||
'class_internal_url': {'$regex': mycommon.regex_replace_cartere(str(diction['class_internal_url'])),
|
||||
"$options": "i"}}
|
||||
|
||||
filt_email = {}
|
||||
if ("email" in diction.keys()):
|
||||
filt_email = {'email': {'$regex': mycommon.regex_replace_cartere(str(diction['email'])), "$options": "i"}}
|
||||
|
||||
filt_nom = {}
|
||||
if ("nom" in diction.keys()):
|
||||
filt_nom = {'nom': {'$regex': mycommon.regex_replace_cartere(str(diction['nom'])), "$options": "i"}}
|
||||
|
||||
"""
|
||||
Filtre général
|
||||
"""
|
||||
if ("nom" in diction.keys()):
|
||||
qry_gle = {"$or": [
|
||||
{'prenom': {'$regex': mycommon.regex_replace_cartere(str(diction['nom'])), "$options": "i"}},
|
||||
{'nom': {'$regex': mycommon.regex_replace_cartere(str(diction['nom'])), "$options": "i"}},
|
||||
{'email': {'$regex': mycommon.regex_replace_cartere(str(diction['nom'])), "$options": "i"}},
|
||||
{'telephone': {'$regex': mycommon.regex_replace_cartere(str(diction['nom'])), "$options": "i"}},
|
||||
]}
|
||||
else:
|
||||
qry_gle = {}
|
||||
|
||||
filt_class_partner_recid = {'partner_owner_recid': str(partner_recid)}
|
||||
|
||||
filt_client_rattachement_id = {}
|
||||
if ("client_rattachement_id" in diction.keys()):
|
||||
filt_client_rattachement_id = {'client_rattachement_id': str(diction['client_rattachement_id'])}
|
||||
|
||||
filt_session_id = {}
|
||||
if ("session_id" in diction.keys()):
|
||||
filt_session_id = {'session_id': str(diction['session_id'])}
|
||||
|
||||
filt_invoiced = {}
|
||||
if ("invoiced" in diction.keys() and str(diction['invoiced']).strip() == "1"):
|
||||
filt_invoiced = {'invoiced': str(diction['invoiced'])}
|
||||
|
||||
if ("invoiced" in diction.keys() and str(diction['invoiced']).strip() != "1" ):
|
||||
filt_invoiced = {'invoiced': {'$ne':'1'} }
|
||||
|
||||
# -----
|
||||
|
||||
filt_client_nom = {}
|
||||
sub_filt_client_nom = {}
|
||||
Lists_partner_client_id = []
|
||||
if ("client_nom" in diction.keys()):
|
||||
|
||||
sub_filt_client_nom = {"$or": [
|
||||
{'raison_sociale': {'$regex': mycommon.regex_replace_cartere(str(diction['client_nom'])), "$options": "i"}, },
|
||||
{'nom': {'$regex': mycommon.regex_replace_cartere(str(diction['client_nom'])), "$options": "i"}, 'partner_owner_recid': str(partner_recid), 'valide': '1', 'locked': '0'},
|
||||
{'email': {'$regex': mycommon.regex_replace_cartere(str(diction['client_nom'])), "$options": "i"}, 'partner_owner_recid': str(partner_recid), 'valide': '1', 'locked': '0'},
|
||||
{'telephone': {'$regex': mycommon.regex_replace_cartere(str(diction['client_nom'])), "$options": "i"}, 'partner_owner_recid': str(partner_recid), 'valide': '1', 'locked': '0'},
|
||||
|
||||
]}
|
||||
|
||||
|
||||
# Recuperation des '_id' des clients dont le nom match en regexp
|
||||
print(" ### sub_filt_client_nom = ", sub_filt_client_nom)
|
||||
for List_Client_Data in MYSY_GV.dbname['partner_client'].find(sub_filt_client_nom, {'_id': 1}):
|
||||
Lists_partner_client_id.append(str(List_Client_Data['_id']))
|
||||
|
||||
filt_client_nom = {'client_rattachement_id': {'$in': Lists_partner_client_id, }}
|
||||
print(' ### filt_client_nom = ', filt_client_nom)
|
||||
|
||||
# ----
|
||||
|
||||
query = [{'$match':
|
||||
{
|
||||
'$and': [filt_archive, filt_class_internal_url, filt_session_code, qry_gle, filt_client_nom,
|
||||
filt_client_rattachement_id,
|
||||
filt_session_id, filt_invoiced, {'partner_owner_recid': str(partner_recid), 'valide': '1',
|
||||
'class_id': {'$exists': True, '$ne': ""},
|
||||
'session_id': {'$exists': True, '$ne': ""}
|
||||
}]}},
|
||||
|
||||
{'$sort': {'_id': -1}},
|
||||
{'$lookup':
|
||||
{
|
||||
'from': 'session_formation',
|
||||
'let': {'session_id': "$session_id", 'partner_owner_recid': '$partner_owner_recid'},
|
||||
'pipeline': [
|
||||
{'$match':
|
||||
{'$expr':
|
||||
{'$and':
|
||||
[
|
||||
{'$eq': ["$_id", {'$convert': {
|
||||
'input': "$$session_id",
|
||||
'to': "objectId",
|
||||
'onError': {'error': 'true'},
|
||||
'onNull': {'isnull': 'true'}
|
||||
}}]},
|
||||
|
||||
{'$eq': ["$valide", "1"]},
|
||||
{'$eq': ["$partner_owner_recid", '$$partner_owner_recid']},
|
||||
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{'$project': {"_id": 1,'code_session':1, 'date_debut':1, 'date_fin':1, 'code_postal':1, 'prix_session':1, 'presentiel':1, 'distantiel':1,
|
||||
'session_ondemande':1, "partner_owner_recid": 1, "valide": 1}
|
||||
},
|
||||
],
|
||||
'as': 'session_formation_collection'
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
]
|
||||
|
||||
#print("#### Get_Statgaire_List_Partner_with_filter_uptimized laa 01 : query = ", query)
|
||||
RetObject = []
|
||||
cpt = 0
|
||||
for retVal in MYSY_GV.dbname['inscription'].aggregate(query):
|
||||
val = {}
|
||||
|
||||
|
||||
# Verifier si le client est valide
|
||||
client_valide = "1"
|
||||
if ("client_rattachement_id" in retVal.keys() and retVal['client_rattachement_id']):
|
||||
client_rattachement_id_count = MYSY_GV.dbname['partner_client'].count_documents(
|
||||
{'_id': ObjectId(retVal['client_rattachement_id']),
|
||||
'valide': '1',
|
||||
'locked': '0',
|
||||
'partner_owner_recid': str(my_partner['recid'])})
|
||||
if (client_rattachement_id_count <= 0):
|
||||
client_valide = "0"
|
||||
|
||||
# Verifier si le client de facturation est valide
|
||||
client_facturation_valide = "1"
|
||||
if ("facture_client_rattachement_id" in retVal.keys() and retVal['facture_client_rattachement_id']):
|
||||
facture_client_rattachement_id_id_count = MYSY_GV.dbname['partner_client'].count_documents(
|
||||
{'_id': ObjectId(retVal['facture_client_rattachement_id']),
|
||||
'valide': '1',
|
||||
'locked': '0',
|
||||
'partner_owner_recid': str(my_partner['recid'])})
|
||||
if (facture_client_rattachement_id_id_count <= 0):
|
||||
client_facturation_valide = "0"
|
||||
|
||||
if (client_valide == "1" and client_facturation_valide == "1"):
|
||||
|
||||
val['id'] = str(cpt)
|
||||
cpt = cpt + 1
|
||||
val['_id'] = retVal['_id']
|
||||
val['session_id'] = retVal['session_id']
|
||||
val['class_internal_url'] = retVal['class_internal_url']
|
||||
val['nom'] = retVal['nom']
|
||||
val['partner_owner_recid'] = retVal['partner_owner_recid']
|
||||
val['prenom'] = retVal['prenom']
|
||||
|
||||
val['email'] = retVal['email']
|
||||
|
||||
|
||||
|
||||
type_apprenant_code = ""
|
||||
type_apprenant_id = ""
|
||||
if ("type_apprenant_id" in retVal.keys() and retVal['type_apprenant_id']):
|
||||
type_apprenant_data = MYSY_GV.dbname['type_apprenant'].find_one(
|
||||
{'_id': ObjectId(str(retVal['type_apprenant_id'])),
|
||||
'valide': '1',
|
||||
'locked': '0',
|
||||
'partner_owner_recid': str(retVal['partner_owner_recid'])})
|
||||
|
||||
if (type_apprenant_data and "code" in type_apprenant_data.keys()):
|
||||
type_apprenant_code = str(type_apprenant_data['code'])
|
||||
type_apprenant_id = str(type_apprenant_data['_id'])
|
||||
|
||||
val['type_apprenant_code'] = type_apprenant_code
|
||||
val['type_apprenant_id'] = type_apprenant_id
|
||||
|
||||
###
|
||||
|
||||
|
||||
if ("civilite" in retVal.keys()):
|
||||
val['civilite'] = str(retVal['civilite']).lower()
|
||||
else:
|
||||
val['civilite'] = ""
|
||||
|
||||
if (str(val['civilite']) not in MYSY_GV.CIVILITE):
|
||||
val['civilite'] = "neutre"
|
||||
|
||||
if (str(val['civilite']).strip() == ""):
|
||||
val['civilite'] = "neutre"
|
||||
|
||||
|
||||
|
||||
if ("archive" not in retVal.keys()):
|
||||
val['archive'] = "0"
|
||||
|
||||
if ("opco" in retVal.keys()):
|
||||
|
||||
val['opco'] = retVal['opco']
|
||||
else:
|
||||
val['opco'] = ""
|
||||
|
||||
|
||||
|
||||
if ("telephone" in retVal.keys()):
|
||||
val['telephone'] = retVal['telephone']
|
||||
else:
|
||||
val['telephone'] = ""
|
||||
|
||||
if ("date_naissance" in retVal.keys() and retVal['date_naissance']):
|
||||
val['date_naissance'] = retVal['date_naissance']
|
||||
else:
|
||||
val['date_naissance'] = ""
|
||||
|
||||
|
||||
|
||||
if ("ville" in retVal.keys()):
|
||||
val['ville'] = retVal['ville']
|
||||
else:
|
||||
val['ville'] = ""
|
||||
|
||||
|
||||
val['status'] = retVal['status']
|
||||
|
||||
val['class_id'] = str(retVal['class_id'])
|
||||
|
||||
|
||||
|
||||
client_rattachement_id = ""
|
||||
client_rattachement_nom = ""
|
||||
|
||||
# Si il a un client rattacher, recuperation des information du client
|
||||
# print(" ### retVal = ", retVal )
|
||||
if ("client_rattachement_id" in retVal.keys()):
|
||||
if (retVal['client_rattachement_id'] and str(retVal['client_rattachement_id']) != 'undefined'):
|
||||
client_retval = MYSY_GV.dbname['partner_client'].find_one(
|
||||
{'_id': ObjectId(retVal['client_rattachement_id']),
|
||||
'valide': '1', 'locked': '0'})
|
||||
|
||||
if (client_retval is not None):
|
||||
client_rattachement_id = client_retval['_id']
|
||||
client_rattachement_nom = client_retval['nom']
|
||||
|
||||
val['client_rattachement_id'] = client_rattachement_id
|
||||
val['client_rattachement_nom'] = client_rattachement_nom
|
||||
|
||||
if ("facture_client_rattachement_id" in retVal.keys()):
|
||||
val['facture_client_rattachement_id'] = retVal['facture_client_rattachement_id']
|
||||
else:
|
||||
val['facture_client_rattachement_id'] = ""
|
||||
|
||||
# ----
|
||||
|
||||
invoiced = ""
|
||||
if ("invoiced" in retVal.keys()):
|
||||
invoiced = retVal['invoiced']
|
||||
val['invoiced'] = invoiced
|
||||
|
||||
invoiced_ref = ""
|
||||
if ("invoiced_ref" in retVal.keys()):
|
||||
invoiced_ref = retVal['invoiced_ref']
|
||||
val['invoiced_ref'] = invoiced_ref
|
||||
|
||||
invoiced_date = ""
|
||||
if ("invoiced_date" in retVal.keys()):
|
||||
invoiced_date = str(retVal['invoiced_date'])[0:10]
|
||||
val['invoiced_date'] = invoiced_date
|
||||
|
||||
financeur_rattachement_id = ""
|
||||
financeur_rattachement_nom = ""
|
||||
|
||||
# Si il a un client rattacher, recuperation des information du client
|
||||
# print(" ### retVal = ", retVal )
|
||||
if ("financeur_rattachement_id" in retVal.keys()):
|
||||
if (retVal['financeur_rattachement_id'] and str(
|
||||
retVal['financeur_rattachement_id']) != 'undefined'):
|
||||
client_retval = MYSY_GV.dbname['partner_client'].find_one(
|
||||
{'_id': ObjectId(retVal['financeur_rattachement_id']),
|
||||
'valide': '1', 'locked': '0'})
|
||||
|
||||
if (client_retval is not None):
|
||||
financeur_rattachement_id = client_retval['_id']
|
||||
financeur_rattachement_nom = client_retval['nom']
|
||||
|
||||
val['financeur_rattachement_id'] = financeur_rattachement_id
|
||||
val['financeur_rattachement_nom'] = financeur_rattachement_nom
|
||||
|
||||
|
||||
|
||||
session_retval = {}
|
||||
if( "session_formation_collection" in retVal.keys() and len(retVal['session_formation_collection']) > 0 ):
|
||||
session_retval = retVal['session_formation_collection'][0]
|
||||
|
||||
|
||||
if ("titre" in session_retval.keys()):
|
||||
val['title'] = session_retval['domaine']
|
||||
else:
|
||||
val['title'] = ""
|
||||
|
||||
if ("code_session" in session_retval.keys()):
|
||||
val['code_session'] = str(session_retval['code_session'])
|
||||
else:
|
||||
val['code_session'] = ""
|
||||
|
||||
if ("date_debut" in session_retval.keys()):
|
||||
val['date_du'] = str(session_retval['date_debut'])[0:10]
|
||||
else:
|
||||
val['date_du'] = ""
|
||||
|
||||
if ("date_fin" in session_retval.keys()):
|
||||
val['date_au'] = str(session_retval['date_fin'])[0:10]
|
||||
else:
|
||||
val['date_au'] = ""
|
||||
|
||||
if ("code_postal" in session_retval.keys()):
|
||||
val['code_postal'] = session_retval['code_postal']
|
||||
else:
|
||||
val['code_postal'] = ""
|
||||
|
||||
if ("prix_session" in session_retval.keys()):
|
||||
val['price'] = session_retval['prix_session']
|
||||
else:
|
||||
val['price'] = ""
|
||||
|
||||
if ("presentiel" in session_retval.keys()):
|
||||
val['presentiel'] = session_retval['presentiel']
|
||||
else:
|
||||
val['presentiel'] = "0"
|
||||
|
||||
if ("distantiel" in session_retval.keys()):
|
||||
val['distantiel'] = session_retval['distantiel']
|
||||
else:
|
||||
val['distantiel'] = "0"
|
||||
|
||||
if ("session_ondemande" in session_retval.keys()):
|
||||
val['session_ondemande'] = session_retval['session_ondemande']
|
||||
else:
|
||||
val['session_ondemande'] = "0"
|
||||
|
||||
"""
|
||||
Gestion du recyclage d'un apprenant si la formation a laquelle il a participer
|
||||
necessite un recyclage.
|
||||
On ne fait ce controle que sur l'inscription 'recyclage_managed' != "1" ou est
|
||||
"""
|
||||
val['class_recyclage_delai'] = ""
|
||||
val['class_recyclage_periodicite'] = ""
|
||||
val['class_recyclage_alert'] = ""
|
||||
val['nb_jour_avant_recyclage'] = ""
|
||||
val['warning_recyclage'] = "0"
|
||||
|
||||
local_class_recyclage = "0"
|
||||
local_class_recyclage_float = 0
|
||||
if ('myclass_collection' in retVal.keys() and len(retVal['myclass_collection']) > 0
|
||||
and "recyclage_alert" in retVal['myclass_collection'][0].keys()
|
||||
and retVal['myclass_collection'][0]['recyclage_alert'] ):
|
||||
local_class_recyclage = retVal['myclass_collection'][0]['recyclage_alert']
|
||||
local_class_recyclage_float = mycommon.tryFloat(str(retVal['myclass_collection'][0]['recyclage_alert']))
|
||||
|
||||
|
||||
if( local_class_recyclage_float > 0 ):
|
||||
if (retVal['status'] == "1" and (
|
||||
"recyclage_managed" not in retVal.keys() or retVal['recyclage_managed'] != "1")):
|
||||
|
||||
if ("recyclage_delai" in retVal['myclass_collection'][0].keys()):
|
||||
val['class_recyclage_delai'] = retVal['myclass_collection'][0]['recyclage_delai']
|
||||
|
||||
if ("recyclage_periodicite" in retVal['myclass_collection'][0].keys()):
|
||||
val['class_recyclage_periodicite'] = retVal['myclass_collection'][0][
|
||||
'recyclage_periodicite']
|
||||
|
||||
if ("recyclage_alert" in retVal['myclass_collection'][0].keys()):
|
||||
val['class_recyclage_alert'] = retVal['myclass_collection'][0]['recyclage_alert']
|
||||
|
||||
if (str(val['class_recyclage_delai']) != "" and str(
|
||||
val['class_recyclage_periodicite']) != "" and str(val['class_recyclage_alert']) != ""):
|
||||
session_date_debut = str(session_retval['date_debut'])[0:10]
|
||||
session_date_debut_datetime = datetime.strptime(str(session_date_debut).strip(), '%d/%m/%Y')
|
||||
if (str(val['class_recyclage_periodicite']) == "mois"):
|
||||
class_recyclage_delai_int = mycommon.tryInt(str(val['class_recyclage_delai']))
|
||||
session_date_debut_datetime = session_date_debut_datetime + relativedelta(
|
||||
months=+class_recyclage_delai_int)
|
||||
|
||||
elif (str(val['class_recyclage_periodicite']) == "annee"):
|
||||
class_recyclage_delai_int = mycommon.tryInt(str(val['class_recyclage_delai']))
|
||||
session_date_debut_datetime = session_date_debut_datetime + relativedelta(
|
||||
years=+class_recyclage_delai_int)
|
||||
|
||||
mytoday = datetime.today().strftime("%d/%m/%Y")
|
||||
mytoday_datetime = datetime.strptime(str(mytoday).strip(), '%d/%m/%Y')
|
||||
|
||||
local_delta = session_date_debut_datetime - mytoday_datetime
|
||||
val['nb_jour_avant_recyclage'] = str(local_delta.days)
|
||||
|
||||
if (local_delta.days < mycommon.tryInt(str(val['class_recyclage_alert']))):
|
||||
val['warning_recyclage'] = "1"
|
||||
|
||||
"""
|
||||
13/07/26 - Recuperer l'image de l'inscrit pour le trombinoscope
|
||||
"""
|
||||
qery_images = {'locked': '0', 'valide': '1', 'related_collection': 'inscription',
|
||||
'related_collection_recid': str(retVal['_id'])}
|
||||
|
||||
logo_img = ""
|
||||
logo_img_recid = ""
|
||||
# Recuperation des image 'logo' et 'cachet' si le partenaire en a
|
||||
for retVal in MYSY_GV.dbname['mysy_images'].find(qery_images):
|
||||
if ('type_img' in retVal.keys()):
|
||||
if (retVal['type_img'] == "user"):
|
||||
logo_img = retVal['img'].decode()
|
||||
logo_img_recid = retVal['recid']
|
||||
|
||||
#print(" IMAGEEEEEEEE trouvééé logo_img === ", logo_img)
|
||||
|
||||
val['logo_img'] = logo_img
|
||||
val['logo_img_recid'] = logo_img_recid
|
||||
RetObject.append(mycommon.JSONEncoder().encode(val))
|
||||
|
||||
|
||||
|
||||
|
||||
#print(" ### RetObject = ", str(RetObject))
|
||||
return True, RetObject
|
||||
|
||||
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 récupérer la liste des stagiaires"
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Cette fonction récupérer la liste des stagiaire d'un partenaire.
|
||||
On y ajoute la formation concernée - version light pour alleger la recherche
|
||||
|
|
|
|||
18391
Log/log_file.log
18391
Log/log_file.log
File diff suppressed because one or more lines are too long
121
class_mgt.py
121
class_mgt.py
|
|
@ -61,7 +61,8 @@ def add_class(diction):
|
|||
'class_level', 'methode_pedagogique', 'condition_handicape', 'suivi_eval', 'class_id',
|
||||
'version', 'categorie', 'recyclage_delai', 'recyclage_periodicite', 'recyclage_alert',
|
||||
'contenu_attestation', 'note_finale_calculation_rule_id', 'referentiel_padagogique_id',
|
||||
'published_catalog_prive', 'is_ftion_initiale', 'inscription_direct', 'duration_operationnelle']
|
||||
'published_catalog_prive', 'is_ftion_initiale', 'inscription_direct', 'duration_operationnelle',
|
||||
'formation_type']
|
||||
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
|
|
@ -605,6 +606,12 @@ def add_class(diction):
|
|||
inscription_direct = diction['inscription_direct']
|
||||
mydata['inscription_direct'] = inscription_direct
|
||||
|
||||
formation_type = ""
|
||||
if ("formation_type" in diction.keys() ):
|
||||
if diction['formation_type'] and str(diction['formation_type']) in MYSY_GV.FORMATION_TYPE :
|
||||
formation_type = diction['formation_type']
|
||||
mydata['formation_type'] = formation_type
|
||||
|
||||
|
||||
|
||||
categorie = ""
|
||||
|
|
@ -865,7 +872,7 @@ def update_class(diction):
|
|||
'condition_handicape', 'suivi_eval', 'class_id', 'version', 'categorie', 'recyclage_delai',
|
||||
'recyclage_periodicite', 'recyclage_alert', 'contenu_attestation',
|
||||
'note_finale_calculation_rule_id', 'referentiel_padagogique_id', 'published_catalog_prive',
|
||||
'is_ftion_initiale', 'inscription_direct', 'duration_operationnelle']
|
||||
'is_ftion_initiale', 'inscription_direct', 'duration_operationnelle', 'formation_type']
|
||||
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
|
|
@ -1135,6 +1142,9 @@ def update_class(diction):
|
|||
if ("inscription_direct" in diction.keys()):
|
||||
mydata['inscription_direct'] = diction['inscription_direct']
|
||||
|
||||
if ("formation_type" in diction.keys()):
|
||||
mydata['formation_type'] = diction['formation_type']
|
||||
|
||||
if ("support" in diction.keys()):
|
||||
mydata['support'] = str(diction['support']).lower().strip()
|
||||
|
||||
|
|
@ -2828,6 +2838,10 @@ def get_class(diction):
|
|||
if ("inscription_direct" not in user.keys()):
|
||||
user['inscription_direct'] = ""
|
||||
|
||||
|
||||
if ("formation_type" not in user.keys() or user['formation_type'] not in MYSY_GV.FORMATION_TYPE):
|
||||
user['formation_type'] = ""
|
||||
|
||||
"""
|
||||
15/09/2024 :
|
||||
Si la formation a des unité d'enseignements rattaché,
|
||||
|
|
@ -3294,6 +3308,9 @@ def get_class_without_marketplace_check(diction):
|
|||
if ("inscription_direct" not in user.keys()):
|
||||
user['inscription_direct'] = ""
|
||||
|
||||
if ("formation_type" not in user.keys() or user['formation_type'] not in MYSY_GV.FORMATION_TYPE):
|
||||
user['formation_type'] = ""
|
||||
|
||||
"""
|
||||
15/09/2024 :
|
||||
Si la formation a des unité d'enseignements rattaché,
|
||||
|
|
@ -3765,6 +3782,10 @@ def get_class_for_partner_catalog(diction):
|
|||
if ("inscription_direct" not in user.keys()):
|
||||
user['inscription_direct'] = ""
|
||||
|
||||
|
||||
if ("formation_type" not in user.keys() or user['formation_type'] not in MYSY_GV.FORMATION_TYPE):
|
||||
user['formation_type'] = ""
|
||||
|
||||
RetObject.append(JSONEncoder().encode(user))
|
||||
|
||||
return True, RetObject
|
||||
|
|
@ -3885,6 +3906,9 @@ def get_class_coup_de_coeur(diction):
|
|||
if ("inscription_direct" not in user.keys()):
|
||||
user['inscription_direct'] = ""
|
||||
|
||||
if ("formation_type" not in user.keys() or user['formation_type'] not in MYSY_GV.FORMATION_TYPE):
|
||||
user['formation_type'] = ""
|
||||
|
||||
RetObject.append(JSONEncoder().encode(user))
|
||||
|
||||
return True, RetObject
|
||||
|
|
@ -4177,9 +4201,14 @@ def get_partner_class(diction):
|
|||
if ("is_ftion_initiale" not in retVal.keys()):
|
||||
retVal['is_ftion_initiale'] = ""
|
||||
|
||||
|
||||
if ("formation_type" not in retVal.keys() or retVal['formation_type'] not in MYSY_GV.FORMATION_TYPE ):
|
||||
retVal['formation_type'] = ""
|
||||
|
||||
# Recuperation des données du formateur
|
||||
formateur_nom_prenom = ""
|
||||
# Si il y a un code formateur_id, alors on va recuperer les nom et prenom du formation
|
||||
is_valide_formateur = "1"
|
||||
if ("formateur_id" in retVal.keys() and retVal['formateur_id']):
|
||||
|
||||
formateur_data = MYSY_GV.dbname['ressource_humaine'].find_one(
|
||||
|
|
@ -4192,11 +4221,18 @@ def get_partner_class(diction):
|
|||
if (formateur_data and "nom" in formateur_data.keys() and "prenom" in formateur_data.keys()):
|
||||
formateur_nom_prenom = str(formateur_data['nom']) + " " + str(formateur_data['prenom'])
|
||||
|
||||
if( not formateur_data or '_id' not in formateur_data.keys()):
|
||||
is_valide_formateur = "0"
|
||||
|
||||
retVal['formateur_nom_prenom'] = formateur_nom_prenom
|
||||
if( is_valide_formateur == "0"):
|
||||
retVal['formateur_id'] = ""
|
||||
|
||||
|
||||
# Recuperation des données du niveau de class
|
||||
class_level_description = ""
|
||||
# Si il y a un code class_level, alors on va recuperer la description
|
||||
valide_class_level = "1"
|
||||
if ("class_level" in retVal.keys() and retVal['class_level']):
|
||||
|
||||
|
||||
|
|
@ -4210,7 +4246,15 @@ def get_partner_class(diction):
|
|||
if (class_level_data and "description" in class_level_data.keys()):
|
||||
class_level_description = str(class_level_data['description'])
|
||||
|
||||
if( not class_level_data or "_id" not in class_level_data.keys() ):
|
||||
valide_class_level = "0"
|
||||
|
||||
|
||||
retVal['class_level_description'] = class_level_description
|
||||
if( valide_class_level == "0"):
|
||||
retVal['class_level'] = ""
|
||||
|
||||
|
||||
|
||||
# Recuperer le nombre de session pour cette formation
|
||||
nb_session_formation_count = MYSY_GV.dbname['session_formation'].count_documents({'class_internal_url':str(retVal['internal_url']),
|
||||
|
|
@ -4245,6 +4289,47 @@ def get_partner_class(diction):
|
|||
|
||||
user['currency'] = currency
|
||||
|
||||
"""
|
||||
Si la domaine n'existe pas, vider le champ domaine
|
||||
"""
|
||||
if ("domaine" in user.keys() and user['domaine']):
|
||||
is_valide_domaine_count = MYSY_GV.dbname['class_domaine'].count_documents(
|
||||
{'_id': ObjectId(str(user['domaine'])),
|
||||
'partner_owner_recid': str(my_partner['recid']),
|
||||
'valide': '1',
|
||||
'locked': '0'})
|
||||
|
||||
if (is_valide_domaine_count != 1):
|
||||
user['domaine'] = ""
|
||||
|
||||
"""
|
||||
Si la categorie n'existe pas, vider le champ domaine
|
||||
"""
|
||||
if ("categorie" in user.keys() and user['categorie']):
|
||||
is_valide_categorie_count = MYSY_GV.dbname['class_categorie'].count_documents(
|
||||
{'_id': ObjectId(str(user['categorie'])),
|
||||
'partner_owner_recid': str(my_partner['recid']),
|
||||
'valide': '1',
|
||||
'locked': '0'})
|
||||
|
||||
if (is_valide_categorie_count != 1):
|
||||
user['categorie'] = ""
|
||||
|
||||
"""
|
||||
Si la metier n'existe pas, vider le champ domaine
|
||||
"""
|
||||
if ("metier" in user.keys() and user['metier']):
|
||||
is_valide_metier_count = MYSY_GV.dbname['class_metier'].count_documents(
|
||||
{'_id': ObjectId(str(user['metier'])),
|
||||
'partner_owner_recid': str(my_partner['recid']),
|
||||
'valide': '1',
|
||||
'locked': '0'})
|
||||
|
||||
if (is_valide_metier_count != 1):
|
||||
user['metier'] = ""
|
||||
|
||||
|
||||
|
||||
RetObject.append(JSONEncoder().encode(user))
|
||||
val_tmp = val_tmp + 1
|
||||
|
||||
|
|
@ -4490,6 +4575,9 @@ def get_partner_class_Without_Scope_Action(diction):
|
|||
if ("note_finale_calculation_rule_id" not in retVal.keys()):
|
||||
retVal['note_finale_calculation_rule_id'] = ""
|
||||
|
||||
if ("formation_type" not in retVal.keys() or retVal['formation_type'] not in MYSY_GV.FORMATION_TYPE):
|
||||
retVal['formation_type'] = ""
|
||||
|
||||
# Recuperation des données du formateur
|
||||
formateur_nom_prenom = ""
|
||||
# Si il y a un code formateur_id, alors on va recuperer les nom et prenom du formation
|
||||
|
|
@ -4840,6 +4928,10 @@ def find_partner_class_like(diction):
|
|||
if ("note_finale_calculation_rule_id" not in retVal.keys()):
|
||||
retVal['note_finale_calculation_rule_id'] = ""
|
||||
|
||||
|
||||
if ("formation_type" not in retVal.keys() or retVal['formation_type'] not in MYSY_GV.FORMATION_TYPE):
|
||||
retVal['formation_type'] = ""
|
||||
|
||||
# Recuperer le nombre de session pour cette formation
|
||||
nb_session_formation_count = MYSY_GV.dbname['session_formation'].count_documents(
|
||||
{'class_internal_url': str(retVal['internal_url']),
|
||||
|
|
@ -4888,7 +4980,7 @@ def find_partner_class_like(diction):
|
|||
user['domaine'] = ""
|
||||
|
||||
"""
|
||||
Si la domaine n'existe pas, vider le champ domaine
|
||||
Si la categorie n'existe pas, vider le champ domaine
|
||||
"""
|
||||
if ("categorie" in user.keys() and user['categorie']):
|
||||
is_valide_categorie_count = MYSY_GV.dbname['class_categorie'].count_documents(
|
||||
|
|
@ -4900,7 +4992,18 @@ def find_partner_class_like(diction):
|
|||
if (is_valide_categorie_count != 1):
|
||||
user['categorie'] = ""
|
||||
|
||||
"""
|
||||
Si la metier n'existe pas, vider le champ domaine
|
||||
"""
|
||||
if ("metier" in user.keys() and user['metier']):
|
||||
is_valide_metier_count = MYSY_GV.dbname['class_metier'].count_documents(
|
||||
{'_id': ObjectId(str(user['metier'])),
|
||||
'partner_owner_recid': str(my_partner['recid']),
|
||||
'valide': '1',
|
||||
'locked': '0'})
|
||||
|
||||
if (is_valide_metier_count != 1):
|
||||
user['metier'] = ""
|
||||
|
||||
|
||||
RetObject.append(JSONEncoder().encode(user))
|
||||
|
|
@ -5164,6 +5267,9 @@ def get_partner_class_external_code(diction):
|
|||
if ("inscription_direct" not in user.keys()):
|
||||
user['inscription_direct'] = ""
|
||||
|
||||
if ("formation_type" not in user.keys() or user['formation_type'] not in MYSY_GV.FORMATION_TYPE):
|
||||
user['formation_type'] = ""
|
||||
|
||||
user['id'] = str(val_tmp)
|
||||
|
||||
'''
|
||||
|
|
@ -6508,6 +6614,9 @@ def get_class_by_metier(diction):
|
|||
if ("inscription_direct" not in user.keys()):
|
||||
user['inscription_direct'] = ""
|
||||
|
||||
if ("formation_type" not in user.keys() or user['formation_type'] not in MYSY_GV.FORMATION_TYPE):
|
||||
user['formation_type'] = ""
|
||||
|
||||
"""
|
||||
07/05/2026 - recuperer le code du domaine
|
||||
"""
|
||||
|
|
@ -7341,6 +7450,9 @@ def get_Class_From_Internal_Url(diction):
|
|||
if ("inscription_direct" not in user.keys()):
|
||||
user['inscription_direct'] = ""
|
||||
|
||||
if ("formation_type" not in user.keys() or user['formation_type'] not in MYSY_GV.FORMATION_TYPE):
|
||||
user['formation_type'] = ""
|
||||
|
||||
|
||||
val_tmp = val_tmp + 1
|
||||
RetObject.append(mycommon.JSONEncoder().encode(user))
|
||||
|
|
@ -7425,6 +7537,9 @@ def get_Class_From_Url(diction):
|
|||
if ("inscription_direct" not in user.keys()):
|
||||
user['inscription_direct'] = ""
|
||||
|
||||
if ("formation_type" not in user.keys() or user['formation_type'] not in MYSY_GV.FORMATION_TYPE):
|
||||
user['formation_type'] = ""
|
||||
|
||||
|
||||
user['id'] = str(val_tmp)
|
||||
val_tmp = val_tmp + 1
|
||||
|
|
|
|||
135
email_mgt.py
135
email_mgt.py
|
|
@ -2921,6 +2921,102 @@ def ManualSendInvoiceEmailRIB_CIC_France_Active(diction):
|
|||
return False, " impossible d'envoyer la facure"
|
||||
|
||||
|
||||
"""
|
||||
Creation manuelle d'une facture avec RIB CIC pour France Active - pour la gestion des évènements/ateliers
|
||||
"""
|
||||
def ManualSendInvoiceEmailRIB_CIC_France_Active_Event_Atelier(diction):
|
||||
try:
|
||||
'''
|
||||
Verification des données obligatoires
|
||||
'''
|
||||
'''
|
||||
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
|
||||
'''
|
||||
|
||||
tomorrow = datetime.date.today() + datetime.timedelta(days=1)
|
||||
tomorrow_day = tomorrow.strftime("%A")
|
||||
|
||||
print("debut envoi mail de test ")
|
||||
# on rentre les renseignements pris sur le site du fournisseur
|
||||
|
||||
#smtpserver = smtplib.SMTP(MYSY_GV.O365_SMTP_COUNT_smtpsrv, MYSY_GV.O365_SMTP_COUNT_port)
|
||||
|
||||
# msg = MIMEMultipart("alternative")
|
||||
#msg = EmailMessage()
|
||||
|
||||
# JINJA2
|
||||
templateLoader = jinja2.FileSystemLoader(searchpath="./")
|
||||
templateEnv = jinja2.Environment(loader=templateLoader)
|
||||
TEMPLATE_FILE = "Template/MySy_Invoice_RIB_PortCities_Perso_tpl.html"
|
||||
template = templateEnv.get_template(TEMPLATE_FILE)
|
||||
body = {
|
||||
"params": {"order_id": "MTT/2025_N°0013/FRANCEACTIVE",
|
||||
"date_order": ": 01/06/2026",
|
||||
"periode":"01/07/2026 au 30/06/2027",
|
||||
"total_ht": "333",
|
||||
"tva": "66,6",
|
||||
"total_ttc": "399,6",
|
||||
"client_name": "FRANCE ACTIVE SEINE-ET-MARNE ESSONNE",
|
||||
"client_address": "29 ALLEE JEAN ROSTAND",
|
||||
"client_zip_ville": "91000 EVRY-COURCOURONNES",
|
||||
"client_pays": "France",
|
||||
"packs": "ELYOS - Gestion des évènements/ateliers ",
|
||||
"detail_packs": "Publication sur catalogue privé, inscriptions et relances automatisées",
|
||||
"qty": "1",
|
||||
"unit_price": "399,6 €",
|
||||
"montant": "399,6 €",
|
||||
|
||||
|
||||
"invoice_id": "FACT_20260725",
|
||||
"invoice_date": "11/07/2026",
|
||||
"due_date": "11/07/2026",
|
||||
"orign_order": "Contrat MTT/2025_N°0013/FRANCEACTIVE",
|
||||
}
|
||||
}
|
||||
|
||||
#print(" ### body 1 = ", body)
|
||||
sourceHtml = template.render(params=body["params"])
|
||||
|
||||
|
||||
#print(" Email envoyé " + str(val))
|
||||
|
||||
### CREATION DE LA FACTION PDF
|
||||
templateLoader = jinja2.FileSystemLoader(searchpath="./")
|
||||
templateEnv = jinja2.Environment(loader=templateLoader)
|
||||
#TEMPLATE_FILE = "Template/MySy_Invoice_RIB_tpl.html"
|
||||
TEMPLATE_FILE = "Template/invoice_RIB_PortCities_perso_tpl.html"
|
||||
|
||||
template = templateEnv.get_template(TEMPLATE_FILE)
|
||||
# This data can come from database query
|
||||
|
||||
#print(" ### body 22 = ", body)
|
||||
|
||||
sourceHtml = template.render(json_data=body["params"])
|
||||
orig_file_name = "invoice_FACT_20260725.pdf"
|
||||
outputFilename = str(MYSY_GV.INVOICE_DIRECTORY) + str(orig_file_name)
|
||||
|
||||
# open output file for writing (truncated binary)
|
||||
resultFile = open(outputFilename, "w+b")
|
||||
|
||||
# convert HTML to PDF
|
||||
pisaStatus = pisa.CreatePDF(
|
||||
src=sourceHtml, # the HTML to convert
|
||||
dest=resultFile) # file handle to receive result
|
||||
|
||||
# close output file
|
||||
resultFile.close()
|
||||
|
||||
return True, " facture envoyée"
|
||||
|
||||
|
||||
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, " impossible d'envoyer la facure"
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Creation manuelle d'une facture avec RIB CIC pour Bureau Vallé - perso
|
||||
"""
|
||||
|
|
@ -4367,13 +4463,19 @@ def send_invidual_email(diction):
|
|||
|
||||
# Recuperer les données tuteurs
|
||||
|
||||
tab_inscrit_tel_for_sms = []
|
||||
|
||||
if(related_collection == "inscription" ):
|
||||
|
||||
|
||||
inscription_data = MYSY_GV.dbname['inscription'].find_one({'_id':ObjectId(str(inscription_id)),
|
||||
'partner_owner_recid':str(partner_owner_recid)},
|
||||
)
|
||||
|
||||
if ( inscription_data and "telephone" in inscription_data.keys() and inscription_data['telephone']):
|
||||
tab_inscrit_tel_for_sms.append(str(inscription_data['telephone']))
|
||||
|
||||
|
||||
if( include_client == "1" and inscription_data and "client_rattachement_id" in inscription_data.keys() ):
|
||||
|
||||
# Recuperation des contacts de communication du client
|
||||
|
|
@ -4484,6 +4586,37 @@ def send_invidual_email(diction):
|
|||
" WARNING : Impossible d'envoyer l'email de notification -Internal_Email_Send_Notification_to_external_email- ")
|
||||
|
||||
|
||||
"""
|
||||
10/07/2026 - envoyer les sms de notification
|
||||
"""
|
||||
|
||||
partner_sms_base_config = MYSY_GV.dbname['base_partner_setup'].find_one({'config_name':'send_sms', 'partner_owner_recid':str(my_partner['recid']),
|
||||
'valide':'1', 'locked':'0'})
|
||||
|
||||
if( partner_sms_base_config and 'config_value' in partner_sms_base_config.keys() and partner_sms_base_config['config_value'] == "1"):
|
||||
|
||||
nom_etablissement_for_sms = ""
|
||||
my_company_data_for_sms = MYSY_GV.dbname['partnair_account'].find_one(
|
||||
{'recid': str(my_partner['recid']), 'is_partner_admin_account': '1', 'active': '1',
|
||||
'locked': '0'},
|
||||
{'_id': 1, 'nom': 1})
|
||||
|
||||
if (my_company_data_for_sms and "nom" in my_company_data_for_sms.keys() and my_company_data_for_sms['nom']):
|
||||
nom_etablissement_for_sms = my_company_data_for_sms['nom']
|
||||
|
||||
for sms_tel in tab_inscrit_tel_for_sms :
|
||||
if( sms_tel ):
|
||||
diction_sms = {}
|
||||
diction_sms['phone_number'] = str(sms_tel)
|
||||
diction_sms['message'] = "Bonjour, vous avez reçu un e-mail de la part de l’établissement de formation " + str(nom_etablissement_for_sms).upper() + ". Pensez à vérifier votre dossier « Courriers indésirables »."
|
||||
status_send_sms, retval_send_sms = mycommon.EySy_OVH_Send_Sms(diction_sms)
|
||||
|
||||
if (status_send_sms is False):
|
||||
mycommon.myprint(
|
||||
" WARNING : Impossible d'envoyer le sms de notification d'ouverture du compte pour : " + str(
|
||||
diction['rh_id']))
|
||||
|
||||
|
||||
return True, " Les emails ont été correctement envoyés"
|
||||
|
||||
except Exception as e:
|
||||
|
|
@ -4647,7 +4780,7 @@ def Individual_Mail_Store_Queu_And_Internal_Mail(diction):
|
|||
"""
|
||||
Cette fonction permet d'envoyer une notification d'expédition de mail interne
|
||||
|
||||
c'est a dire, quand un utilisateur envoie un mail depuis Elyos, le système va notifer
|
||||
c'est a dire, quand un utilisateur envoie un mail depuis Elyos, le système va notifie
|
||||
au destinataire de mail dans sa boite externe qu'il a un mail Elyos, il n'y a qu'a
|
||||
ce connecter pour lire le contenu, un peu comme le font les banques
|
||||
|
||||
|
|
|
|||
44
main.py
44
main.py
|
|
@ -3461,6 +3461,23 @@ def ManualSendInvoiceEmailRIB_CIC_France_Active():
|
|||
|
||||
|
||||
|
||||
"""
|
||||
API Creation manuelle d'une facture avec RIB CIC pour France Active - pour la gestion des évènements/ateliers
|
||||
"""
|
||||
@app.route('/myclass/api/ManualSendInvoiceEmailRIB_CIC_France_Active_Event_Atelier/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def ManualSendInvoiceEmailRIB_CIC_France_Active_Event_Atelier():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### ManualSendInvoiceEmailRIB_CIC_France_Active_Event_Atelier : payload = ",str(payload))
|
||||
localStatus, message= emails.ManualSendInvoiceEmailRIB_CIC_France_Active_Event_Atelier(payload)
|
||||
return jsonify(status=localStatus, message=message )
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
"""
|
||||
API Creation manuelle d'une facture avec RIB CIC pour Bureau Vallée - perso
|
||||
|
|
@ -5696,6 +5713,21 @@ def Get_Statgaire_List_Partner_with_filter_uptimized():
|
|||
|
||||
|
||||
|
||||
"""
|
||||
API qui recupere la liste complete des stagaire d'un partener UPTIMIZED avec la photo de l'inscrit
|
||||
pour le trombinoscope
|
||||
"""
|
||||
@app.route('/myclass/api/Get_Statgaire_List_Partner_with_filter_uptimized_With_Img/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Get_Statgaire_List_Partner_with_filter_uptimized_With_Img():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Get_Statgaire_List_Partner_with_filter_uptimized_With_Img payload = ",payload)
|
||||
status, retval = inscription.Get_Statgaire_List_Partner_with_filter_uptimized_With_Img(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
|
||||
|
||||
"""
|
||||
API qui recupere la liste complete des stagaire d'un partener - version light pour alleger la recherche
|
||||
|
|
@ -16975,6 +17007,18 @@ def Candidat_Inscrire_To_Session():
|
|||
|
||||
|
||||
|
||||
"""
|
||||
API permet d'importer en masse des candidats a une session d'admission
|
||||
"""
|
||||
@app.route('/myclass/api/Add_Admission_Candidat_mass_for_One_Session/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Add_Admission_Candidat_mass_for_One_Session():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Add_Admission_Candidat_mass_for_One_Session payload = ", payload)
|
||||
status, retval = session_admission_fi.Add_Admission_Candidat_mass_for_One_Session(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -4008,7 +4008,7 @@ def Get_List_Apprenant_Notes_With_Filter(diction):
|
|||
for val in MYSY_GV.dbname['note_evaluation'].find({'class_eu_id': {'$in': tab_my_ue_ids},
|
||||
'valide': '1',
|
||||
'locked': '0',
|
||||
'partner_owner_recid': str(my_partner['partner_owner_recid'])}):
|
||||
'partner_owner_recid': str(my_partner['recid'])}):
|
||||
|
||||
concerned_tab_evaluation_id.append((str(val['_id'])))
|
||||
|
||||
|
|
@ -4025,14 +4025,14 @@ def Get_List_Apprenant_Notes_With_Filter(diction):
|
|||
for val in MYSY_GV.dbname['note_evaluation'].find({'class_eu_id': {'$in': tab_my_session_ids},
|
||||
'valide': '1',
|
||||
'locked': '0',
|
||||
'partner_owner_recid': str(my_partner['partner_owner_recid'])}):
|
||||
'partner_owner_recid': str(my_partner['recid'])}):
|
||||
concerned_tab_session_id.append((str(val['_id'])))
|
||||
|
||||
if (len(concerned_tab_session_id) > 0):
|
||||
filt_concerned_tab_session_id = {"evaluation_id": {"$in": concerned_tab_session_id}}
|
||||
|
||||
|
||||
qery_match = {'$and': [{"partner_owner_recid": str(my_partner['partner_owner_recid'])},
|
||||
qery_match = {'$and': [{"partner_owner_recid": str(my_partner['recid'])},
|
||||
{"valide": '1'},
|
||||
{"locked": '0'},
|
||||
filt_concerned_tab_inscription_id,
|
||||
|
|
@ -4120,7 +4120,7 @@ def Get_List_Apprenant_Notes_With_Filter(diction):
|
|||
'valide': '1',
|
||||
'locked': '0',
|
||||
'partner_owner_recid': str(
|
||||
my_partner['partner_owner_recid'])})
|
||||
my_partner['recid'])})
|
||||
if ("code" in ue_data.keys()):
|
||||
class_ue_code = str(ue_data['code'])
|
||||
if ("titre" in ue_data.keys()):
|
||||
|
|
@ -4134,7 +4134,7 @@ def Get_List_Apprenant_Notes_With_Filter(diction):
|
|||
'valide': '1',
|
||||
'locked': '0',
|
||||
'partner_owner_recid': str(
|
||||
my_partner['partner_owner_recid'])})
|
||||
my_partner['recid'])})
|
||||
if (type_eval_data and 'code' in type_eval_data.keys()):
|
||||
user['type_eval_code'] = type_eval_data['code']
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -8629,12 +8629,6 @@ def Push_Document_To_ENT_For_Inscrit(tab_files, Folder, diction):
|
|||
return False, "L'adresse email '" + str(email_dest) + "' est invalide"
|
||||
|
||||
|
||||
print(" ### qryy exist = ",{"email": str(email_dest),
|
||||
'valide': '1',
|
||||
'session_id':str(diction['session_id']),
|
||||
local_partner_owner_recid: str(my_partner['recid']),
|
||||
'email': str(email_dest)
|
||||
} )
|
||||
|
||||
|
||||
is_valide_email_in_related_collection = MYSY_GV.dbname[str(related_collection)].count_documents(
|
||||
|
|
@ -8769,6 +8763,14 @@ def Push_Document_To_ENT_For_Inscrit(tab_files, Folder, diction):
|
|||
convention_dictionnary_data['partner_ent_student_url'] = config_partner_catalog_data['partner_ent_student_url']
|
||||
|
||||
|
||||
nom_etablissement_for_sms = ""
|
||||
my_company_data_for_sms = MYSY_GV.dbname['partnair_account'].find_one(
|
||||
{'recid': str(my_partner['recid']), 'is_partner_admin_account': '1', 'active': '1',
|
||||
'locked': '0'},
|
||||
{'_id': 1, 'nom': 1})
|
||||
|
||||
if (my_company_data_for_sms and "nom" in my_company_data_for_sms.keys() and my_company_data_for_sms['nom']):
|
||||
nom_etablissement_for_sms = my_company_data_for_sms['nom']
|
||||
|
||||
|
||||
for user_id in tab_related_collection_id:
|
||||
|
|
@ -8778,11 +8780,12 @@ def Push_Document_To_ENT_For_Inscrit(tab_files, Folder, diction):
|
|||
'valide': '1',
|
||||
'session_id': str(diction['session_id']),
|
||||
local_partner_owner_recid: str(my_partner['recid'])
|
||||
}, {'_id': 1, 'email': 1, 'nom': 1, 'prenom': 1})
|
||||
}, {'_id': 1, 'email': 1, 'nom': 1, 'prenom': 1, 'telephone':1})
|
||||
|
||||
nom = ""
|
||||
prenom = ""
|
||||
email = ""
|
||||
tel_for_sms = ""
|
||||
|
||||
if ("nom" in user_related_collection_data.keys()):
|
||||
nom = user_related_collection_data['nom']
|
||||
|
|
@ -8793,6 +8796,9 @@ def Push_Document_To_ENT_For_Inscrit(tab_files, Folder, diction):
|
|||
if ("email" in user_related_collection_data.keys()):
|
||||
email = user_related_collection_data['email']
|
||||
|
||||
if ("telephone" in user_related_collection_data.keys()):
|
||||
tel_for_sms = user_related_collection_data['telephone']
|
||||
|
||||
|
||||
|
||||
node = {}
|
||||
|
|
@ -8835,6 +8841,8 @@ def Push_Document_To_ENT_For_Inscrit(tab_files, Folder, diction):
|
|||
# Creation de l'email à enoyer
|
||||
msg = MIMEMultipart("alternative")
|
||||
|
||||
#print(" ## partner_own_smtp_valuepartner_own_smtp_value = ", partner_own_smtp_value)
|
||||
|
||||
if (str(partner_own_smtp_value) == "1"):
|
||||
msg.attach(html_mime)
|
||||
msg['From'] = partner_SMTP_COUNT_From_User
|
||||
|
|
@ -8876,7 +8884,30 @@ def Push_Document_To_ENT_For_Inscrit(tab_files, Folder, diction):
|
|||
|
||||
cpt_email_envoye = cpt_email_envoye + 1
|
||||
|
||||
print(" NB_email envoyé = ", cpt_email_envoye)
|
||||
|
||||
"""
|
||||
10/07/2026 - envoyer les sms de notification
|
||||
"""
|
||||
partner_sms_base_config = MYSY_GV.dbname['base_partner_setup'].find_one(
|
||||
{'config_name': 'send_sms', 'partner_owner_recid': str(my_partner['recid']),
|
||||
'valide': '1', 'locked': '0'})
|
||||
|
||||
if (partner_sms_base_config and 'config_value' in partner_sms_base_config.keys() and
|
||||
partner_sms_base_config['config_value'] == "1" and tel_for_sms):
|
||||
|
||||
|
||||
diction_sms = {}
|
||||
diction_sms['phone_number'] = str(tel_for_sms)
|
||||
diction_sms['message'] = "Bonjour, vous avez reçu un e-mail de la part de l’établissement de formation "+str(nom_etablissement_for_sms).upper()+". Pensez à vérifier votre dossier « Courriers indésirables »."
|
||||
status_send_sms, retval_send_sms = EySy_OVH_Send_Sms(diction_sms)
|
||||
|
||||
if (status_send_sms is False):
|
||||
myprint(
|
||||
" WARNING : Impossible d'envoyer le sms de notification d'ouverture du compte pour : " + str(
|
||||
diction['rh_id']))
|
||||
|
||||
|
||||
print(" dd NB_email envoyé = ", cpt_email_envoye)
|
||||
smtpserver.close()
|
||||
return True, " Les documents ont été publiés"
|
||||
|
||||
|
|
|
|||
|
|
@ -3340,3 +3340,951 @@ def Candidat_Inscrire_To_Session(diction):
|
|||
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - Line : " + str(exc_tb.tb_lineno))
|
||||
return False, " Impossible d'inscrire les apprenants à la session de formation "
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Cette fonction permet d'importer en masse des candidat à une session d'admission
|
||||
"""
|
||||
|
||||
def Add_Admission_Candidat_mass_for_One_Session(file=None, Folder=None, diction=None):
|
||||
try:
|
||||
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
'''
|
||||
# Verification que les champs reçus dans l'API sont bien dans la liste des champs autorisés
|
||||
# Cela evite le cas ou une entité tierce ajouter les valeurs inconnu dans l'API
|
||||
# Ici on doit mettre tous les champs possible (obligatoire ou non) de la BDD dans la liste
|
||||
# field_list.
|
||||
'''
|
||||
field_list = ['token', 'admission_session_id']
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
if val not in field_list and val.startswith('my_') is False:
|
||||
mycommon.myprint(str(
|
||||
inspect.stack()[0][3]) + " Le champ '" + val + "' n'existe pas, Creation participants annulée")
|
||||
return False, " Verifier votre API"
|
||||
|
||||
'''
|
||||
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 = ['token', 'admission_session_id']
|
||||
|
||||
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 la liste des arguments ")
|
||||
return False, " Verifier votre API, Toutes les informations techniques ne sont pas fournies"
|
||||
|
||||
my_token = ""
|
||||
if ("token" in diction.keys()):
|
||||
if diction['token']:
|
||||
my_token = diction['token']
|
||||
|
||||
# Verifier la validité du token
|
||||
retval = mycommon.check_partner_token_validity("", my_token)
|
||||
if retval is False:
|
||||
return "Err_Connexion", " La session de connexion n'est pas valide"
|
||||
|
||||
partner_recid = mycommon.get_parnter_recid_from_token(my_token)
|
||||
if (partner_recid is False):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " - partner_recid KO : Impossible d'importer la liste des participants ")
|
||||
return False, " Les information de connexion sont incorrectes. Impossible d'importer la liste des participants"
|
||||
|
||||
"""
|
||||
Si le champ 'admission_session_id' est fourni, alors il faut s'assurer que l'import ne se fait exclusivement
|
||||
pour la session indiquée
|
||||
"""
|
||||
admission_session_id = None
|
||||
admission_session_id_data = None
|
||||
|
||||
if ("admission_session_id" in diction.keys() and diction['admission_session_id']):
|
||||
admission_session_id = diction['admission_session_id']
|
||||
admission_session_id_count = MYSY_GV.dbname['session_formation'].count_documents(
|
||||
{'_id': ObjectId(str(admission_session_id)),
|
||||
'valide': '1',
|
||||
'partner_owner_recid': partner_recid})
|
||||
|
||||
if (admission_session_id_count != 1):
|
||||
mycommon.myprint(str(
|
||||
inspect.stack()[0][3]) + " L'identifiant de la session d'admission est invalide ")
|
||||
return False, " L'identifiant de la session d'admission est invalide"
|
||||
|
||||
admission_session_id_data = MYSY_GV.dbname['session_formation'].find_one(
|
||||
{'_id': ObjectId(str(admission_session_id)),
|
||||
'valide': '1',
|
||||
'partner_owner_recid': partner_recid})
|
||||
|
||||
status, saved_file = mycommon.Upload_Save_CSV_File(file, Folder)
|
||||
if (status == False):
|
||||
mycommon.myprint("Impossible de récupérer correctement le fichier à importer")
|
||||
return False, "Impossible d'importer la liste des participants, le nom du fichier est incorrect "
|
||||
|
||||
# " Lecture du fichier "
|
||||
# print(" Lecture du fichier : "+saved_file)
|
||||
nb_line = 0
|
||||
|
||||
""""
|
||||
update du 11/07/26 : Controle de l'integrité du fichier
|
||||
"""
|
||||
local_controle_status, local_controle_message = Controle_Add_Admission_Candidat_mass_for_One_Session(saved_file,
|
||||
Folder,
|
||||
diction)
|
||||
|
||||
if (local_controle_status is False):
|
||||
return local_controle_status, local_controle_message
|
||||
|
||||
print(" #### local_controle_message = ", local_controle_message)
|
||||
|
||||
df = pd.read_csv(saved_file, encoding='utf8', on_bad_lines='skip', sep=';', encoding_errors='ignore',
|
||||
skipinitialspace=True)
|
||||
df = df.fillna('')
|
||||
df = df.applymap(lambda x: x.strip() if isinstance(x, str) else x)
|
||||
|
||||
# Dictionnaire des champs utilisables
|
||||
'''
|
||||
# Verification que les noms des colonne sont bien corrects"
|
||||
'''
|
||||
field_list = ['prenom', 'nom', 'prenom', 'email', 'telephone', 'modefinancement',
|
||||
'session_id', 'employeur', 'status', 'price',
|
||||
'client_rattachement_id', 'adresse', 'code_postal', 'ville', 'pays',
|
||||
'type_apprenant', 'civilite', 'date_naissance', 'memo', 'comment',
|
||||
"num_secu", "is_rgpd", "situation_famille", "piece_identite_type", "piece_identite_num",
|
||||
"type_mobilite", "telephone_bis", "nationalite", "is_handicap", "is_handicap", "is_droit_image",
|
||||
'naissance_lieu', 'naissance_departement', 'naissance_pays', 'session_etape_code', 'ine',
|
||||
'nom_fille']
|
||||
|
||||
# Controle du nombre de lignes dans le fichier.
|
||||
total_rows = len(df)
|
||||
if (total_rows > MYSY_GV.MAX_PARTICIPANT_BY_CSV):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " Le fichier comporte plus de " + str(
|
||||
MYSY_GV.MAX_PARTICIPANT_BY_CSV) + " lignes.")
|
||||
return False, " Le fichier comporte plus de " + str(MYSY_GV.MAX_PARTICIPANT_BY_CSV) + " lignes."
|
||||
|
||||
# print(" ### df.columns = ", df.columns)
|
||||
for val in df.columns:
|
||||
# print(" ### val = ", val)
|
||||
if str(val).lower() not in field_list:
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " : entete du fichier csv. '" + val + "' n'est pas acceptée")
|
||||
return False, " Entete du fichier csv. La Colonne '" + val + "' n'est pas acceptée"
|
||||
|
||||
|
||||
# Verification des champs obligatoires dans le fichier
|
||||
field_list_obligatoire_file = ['nom', 'prenom', 'email', 'telephone']
|
||||
|
||||
for val in field_list_obligatoire_file:
|
||||
if val not in df.columns:
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " : Le champ '" + val + "' n'est pas présent dans le fichier. Il est obligatoire")
|
||||
return False, " Le champ '" + val + "' n'est pas présent dans le fichier. Il est obligatoire "
|
||||
|
||||
|
||||
|
||||
mysession_count_qry = {'_id': ObjectId(str(diction['session_id'])), 'valide': '1',
|
||||
'partner_owner_recid': str(partner_recid), }
|
||||
|
||||
# print(" ### mysession_count_qry = ", mysession_count_qry)
|
||||
|
||||
mysession_count = MYSY_GV.dbname['admission_session'].count_documents(mysession_count_qry)
|
||||
|
||||
if (mysession_count != 1):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " La session d'admission est invalide ")
|
||||
return False, "La session d'admission est invalide "
|
||||
|
||||
mysession_data = MYSY_GV.dbname['session_formation'].find_one(mysession_count_qry)
|
||||
|
||||
x = range(0, total_rows)
|
||||
cpt_valide_row = 0
|
||||
for n in x:
|
||||
if (str(df['prenom'].values[n]) and str(df['nom'].values[n]) and str(df['email'].values[n])):
|
||||
mydata = {}
|
||||
class_external_code = str(df['formation_code_externe'].values[n])
|
||||
# mydata['code_session'] = str(df['code_session'].values[n])
|
||||
mydata['prenom'] = str(df['prenom'].values[n])
|
||||
mydata['nom'] = str(df['nom'].values[n])
|
||||
if (len(str(mydata['nom']).strip()) < 2):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " Le champ 'nom' de la ligne " + str(
|
||||
n + 2) + " doit faire plus de deux caractères.")
|
||||
return False, " Le champ nom de la ligne " + str(
|
||||
n + 2) + " doit faire plus de deux caractères. "
|
||||
|
||||
mydata['telephone'] = str(df['telephone'].values[n])
|
||||
mydata['email'] = str(df['email'].values[n]).strip().lower()
|
||||
# print(" contole du mail = ", mydata['email'])
|
||||
regex = r'\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,7}\b'
|
||||
if (not re.fullmatch(regex, str(mydata['email']))):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + "Ligne : " + str(n + 2) + " : L'adresse email " + str(
|
||||
mydata['email']) + " est invalide")
|
||||
return False, " Ligne : " + str(n + 2) + " : L'adresse email -" + str(
|
||||
mydata['email']) + "- est invalide"
|
||||
|
||||
mydata['token'] = str(my_token)
|
||||
|
||||
"""
|
||||
Verifier qu'il n'y pas un étudiant avec le meme INE (Identifiant National Étudiant)
|
||||
"""
|
||||
local_ine = ""
|
||||
if ("ine" in df.keys()):
|
||||
local_ine = str(df['ine'].values[n])
|
||||
is_exist_ine_count = MYSY_GV.dbname['admission_session_inscrit'].count_documents(
|
||||
{'ine': str(local_ine),
|
||||
'session_id': str(diction['session_id']),
|
||||
'partner_owner_recid': str(partner_recid)
|
||||
})
|
||||
|
||||
if (is_exist_ine_count > 0):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " Ligne : " + str(
|
||||
n + 2) + " : Il y a déjà un candidat avec le même numéro Identifiant National Étudiant (INE) ")
|
||||
return False, " Ligne : " + str(
|
||||
n + 2) + " : Il y a déjà un candidat avec le même numéro Identifiant National Étudiant (INE) "
|
||||
|
||||
mydata['ine'] = str(local_ine)
|
||||
|
||||
|
||||
"""
|
||||
Verifier qu'il n'y pas déjà une presonne inscrite avec le meme email pour la meme session
|
||||
"""
|
||||
local_email = ""
|
||||
if ("email" in df.keys()):
|
||||
local_email = str(df['email'].values[n]).lower()
|
||||
is_inscrit_exist = MYSY_GV.dbname['admission_session_inscrit'].count_documents(
|
||||
{
|
||||
"email": {
|
||||
"$regex": f"^{re.escape(str(local_email))}$",
|
||||
"$options": "i"
|
||||
},
|
||||
'session_id': diction['session_id'],
|
||||
'partner_owner_recid': partner_recid})
|
||||
|
||||
if (is_inscrit_exist > 0):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " Ligne : " + str(
|
||||
n + 2) + " : Une personne est déjà inscrite à cette session avec la même adresse email ")
|
||||
return False, " Ligne : " + str(
|
||||
n + 2) + " : Une personne est déjà inscrite à cette session avec la même adresse email "
|
||||
|
||||
mydata['email'] = str(local_email)
|
||||
|
||||
"""
|
||||
Verifier la validité de l'etape
|
||||
"""
|
||||
local_session_etape_id = ""
|
||||
if ("session_etape_code" in df.keys()):
|
||||
|
||||
local_session_etape = str(df['session_etape'].values[n]).lower().strip()
|
||||
|
||||
session_etape_id = MYSY_GV.dbname['admission_setup_etape'].count_documents(
|
||||
{
|
||||
"code": {
|
||||
"$regex": f"^{re.escape(str(local_session_etape))}$",
|
||||
"$options": "i"
|
||||
},
|
||||
'valide': '1', 'partner_owner_recid': str(partner_recid)})
|
||||
|
||||
if (session_etape_id != 1):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " Ligne : " + str(
|
||||
n + 2) + " : Le code de l'étape est invalide ")
|
||||
return False, " Ligne : " + str(n + 2) + " : Le code de l'étape est invalide "
|
||||
|
||||
session_etape_data = MYSY_GV.dbname['admission_setup_etape'].find_one(
|
||||
{
|
||||
"code": {
|
||||
"$regex": f"^{re.escape(str(local_session_etape))}$",
|
||||
"$options": "i"
|
||||
},
|
||||
'valide': '1', 'partner_owner_recid': str(partner_recid)})
|
||||
|
||||
local_session_etape_id = str(session_etape_data['_id'])
|
||||
mydata['session_etape'] = str(local_session_etape_id)
|
||||
|
||||
|
||||
local_is_handicap = ""
|
||||
if ("is_handicap" in df.keys()):
|
||||
local_is_handicap = str(df['is_handicap'].values[n]).lower().strip()
|
||||
if (local_is_handicap not in ['0', '1', '']):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + "Ligne : " + str(
|
||||
n + 2) + " : Le champ 'is_handicap' est invalide ")
|
||||
return False, "Ligne : " + str(n + 2) + " : Le champ 'is_handicap' est invalide "
|
||||
|
||||
mydata['is_handicap'] = str(local_is_handicap)
|
||||
|
||||
|
||||
local_is_droit_image = ""
|
||||
if ("is_droit_image" in df.keys()):
|
||||
local_is_droit_image = str(df['is_droit_image'].values[n]).lower().strip()
|
||||
if (local_is_droit_image not in ['0', '1', '']):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + "Ligne : " + str(
|
||||
n + 2) + " : Le champ 'is_droit_image' est invalide ")
|
||||
return False, "Ligne : " + str(n + 2) + " : Le champ 'is_droit_image' est invalide "
|
||||
mydata['is_droit_image'] = str(local_is_droit_image)
|
||||
|
||||
|
||||
local_is_rgpd = ""
|
||||
if ("is_rgpd" in df.keys()):
|
||||
local_is_rgpd = str(df['is_rgpd'].values[n]).lower().strip()
|
||||
if (local_is_rgpd not in ['0', '1', '']):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + "Ligne : " + str(
|
||||
n + 2) + " : Le champ 'is_rgpd' est invalide ")
|
||||
return False, "Ligne : " + str(n + 2) + " : Le champ 'is_rgpd' est invalide "
|
||||
mydata['is_rgpd'] = str(local_is_rgpd)
|
||||
|
||||
|
||||
local_date_naissance = "01/01/1900"
|
||||
if ("date_naissance" in df.keys()):
|
||||
local_date_naissance = str(df['date_naissance'].values[n]).strip().split(" ")[0]
|
||||
if (local_date_naissance):
|
||||
local_status = mycommon.CheckisDate(local_date_naissance)
|
||||
if (local_status is False):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " La date de naissance à ligne " + str(
|
||||
n + 2) + " n'est pas au format 'jj/mm/aaaa' .")
|
||||
|
||||
return False, " La date de naissance à ligne " + str(
|
||||
n + 2) + " n'est pas au format 'jj/mm/aaaa' "
|
||||
|
||||
mydata['date_naissance'] = str(local_date_naissance)
|
||||
|
||||
|
||||
adresse = ""
|
||||
if ("adresse" in df.keys()):
|
||||
if (str(df['adresse'].values[n])):
|
||||
adresse = str(df['adresse'].values[n])
|
||||
mydata['adresse'] = adresse
|
||||
|
||||
code_postal = ""
|
||||
if ("code_postal" in df.keys()):
|
||||
if (str(df['code_postal'].values[n])):
|
||||
code_postal = str(df['code_postal'].values[n])
|
||||
mydata['code_postal'] = code_postal
|
||||
|
||||
ville = ""
|
||||
if ("ville" in df.keys()):
|
||||
if (str(df['ville'].values[n])):
|
||||
ville = str(df['ville'].values[n])
|
||||
mydata['ville'] = ville
|
||||
|
||||
pays = ""
|
||||
if ("pays" in df.keys()):
|
||||
if (str(df['pays'].values[n])):
|
||||
pays = str(df['pays'].values[n])
|
||||
mydata['pays'] = pays
|
||||
|
||||
civilite = ""
|
||||
if ("civilite" in df.keys()):
|
||||
if (str(df['civilite'].values[n])):
|
||||
civilite = str(df['civilite'].values[n]).lower()
|
||||
mydata['civilite'] = str(civilite).lower()
|
||||
|
||||
if (str(civilite).strip() == ""):
|
||||
mydata['civilite'] = "neutre"
|
||||
|
||||
if (civilite not in MYSY_GV.CIVILITE):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " Ligne : " + str(
|
||||
n + 2) + ". La civilité :" + str(
|
||||
civilite) + " est invalide. Les valeurs acceptées sont : " + str(MYSY_GV.CIVILITE))
|
||||
return False, " Ligne : " + str(
|
||||
n + 2) + ". La civilité :" + str(
|
||||
civilite) + " est invalide. Les valeurs acceptées sont : " + str(MYSY_GV.CIVILITE)
|
||||
|
||||
""""
|
||||
Gestion du client de rattachement/
|
||||
Avec l'email et le nom, on va aller récupérer l'_id du client
|
||||
"""
|
||||
client_rattachement_email = ""
|
||||
if ("client_rattachement_email" in df.keys()):
|
||||
if (str(df['client_rattachement_email'].values[n]) and str(
|
||||
df['client_rattachement_email'].values[n]) != "nan"):
|
||||
client_rattachement_email = str(df['client_rattachement_email'].values[n]).strip()
|
||||
|
||||
client_rattachement_nom = ""
|
||||
if ("client_rattachement_nom" in df.keys()):
|
||||
if (str(df['client_rattachement_nom'].values[n]) and str(
|
||||
df['client_rattachement_nom'].values[n]) != "nan"):
|
||||
client_rattachement_nom = str(df['client_rattachement_nom'].values[n]).strip()
|
||||
if (client_rattachement_email and client_rattachement_nom):
|
||||
local_client_retval_qry = {'email': str(client_rattachement_email),
|
||||
'nom': str(client_rattachement_nom),
|
||||
'valide': '1', 'locked': '0', 'partner_owner_recid': str(partner_recid)}
|
||||
|
||||
print(" ### local_client_retval_qry = ", local_client_retval_qry)
|
||||
local_client_retval_count = MYSY_GV.dbname['partner_client'].count_documents(
|
||||
local_client_retval_qry)
|
||||
|
||||
if (local_client_retval_count > 1):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + "Ligne : " + str(
|
||||
n + 2) + ". Plusieurs clients correspondent aux critère de nom :" + str(
|
||||
client_rattachement_nom) + " et email : " + str(client_rattachement_email))
|
||||
return False, "Ligne : " + str(
|
||||
n + 2) + ". Plusieurs clients correspondent aux critère de nom :" + str(
|
||||
client_rattachement_nom) + " et email : " + str(client_rattachement_email)
|
||||
|
||||
if (local_client_retval_count < 1):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + "Ligne : " + str(
|
||||
n + 2) + ". Aucun client ne repond aux critères de nom :" + str(
|
||||
client_rattachement_nom) + " et email : " + str(client_rattachement_email))
|
||||
return False, "Ligne : " + str(
|
||||
n + 2) + ". Aucun client ne repond aux critères de nom :" + str(
|
||||
client_rattachement_nom) + " et email : " + str(client_rattachement_email)
|
||||
|
||||
local_client_retval_data = MYSY_GV.dbname['partner_client'].find_one(local_client_retval_qry)
|
||||
if (local_client_retval_data is not None):
|
||||
mydata['client_rattachement_id'] = str(local_client_retval_data['_id'])
|
||||
|
||||
""""
|
||||
Gestion du client dà facturer/
|
||||
Avec l'email et le nom, on va aller récupérer l'_id du client
|
||||
"""
|
||||
facture_client_rattachement_email = ""
|
||||
if ("facture_client_rattachement_email" in df.keys()):
|
||||
if (str(df['facture_client_rattachement_email'].values[n]) and str(
|
||||
df['facture_client_rattachement_email'].values[n]) != "nan"):
|
||||
facture_client_rattachement_email = str(
|
||||
df['facture_client_rattachement_email'].values[n]).strip()
|
||||
|
||||
facture_client_rattachement_nom = ""
|
||||
if ("facture_client_rattachement_nom" in df.keys()):
|
||||
if (str(df['facture_client_rattachement_nom'].values[n]) and str(
|
||||
df['facture_client_rattachement_nom'].values[n]) != "nan"):
|
||||
facture_client_rattachement_nom = str(df['facture_client_rattachement_nom'].values[n]).strip()
|
||||
|
||||
if (facture_client_rattachement_email and facture_client_rattachement_nom):
|
||||
local_client_retval_qry = {'email': str(facture_client_rattachement_email),
|
||||
'nom': str(facture_client_rattachement_nom),
|
||||
'valide': '1', 'locked': '0', 'partner_owner_recid': str(partner_recid)}
|
||||
|
||||
print(" ### local_client_retval_qry = ", local_client_retval_qry)
|
||||
local_client_retval_count = MYSY_GV.dbname['partner_client'].count_documents(
|
||||
local_client_retval_qry)
|
||||
|
||||
if (local_client_retval_count > 1):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + "Ligne : " + str(
|
||||
n + 2) + ". Plusieurs entités de facturation correspondent aux critères de nom :" + str(
|
||||
facture_client_rattachement_nom) + " et email : " + str(
|
||||
facture_client_rattachement_email))
|
||||
return False, "Ligne : " + str(
|
||||
n + 2) + ". Plusieurs entités de facturation correspondent aux critères de nom :" + str(
|
||||
facture_client_rattachement_nom) + " et email : " + str(facture_client_rattachement_email)
|
||||
|
||||
if (local_client_retval_count < 1):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + "Ligne : " + str(
|
||||
n + 2) + ". Aucune entité de facturation ne repond aux critères de nom :" + str(
|
||||
facture_client_rattachement_nom) + " et email : " + str(
|
||||
facture_client_rattachement_email))
|
||||
return False, "Ligne : " + str(
|
||||
n + 2) + ". Aucune entité de facturation ne repond aux critères de nom :" + str(
|
||||
facture_client_rattachement_nom) + " et email : " + str(facture_client_rattachement_email)
|
||||
|
||||
local_client_retval_data = MYSY_GV.dbname['partner_client'].find_one(local_client_retval_qry)
|
||||
if (local_client_retval_data is not None):
|
||||
mydata['facture_client_rattachement_id'] = str(local_client_retval_data['_id'])
|
||||
|
||||
mydata['status'] = str(df['status'].values[n]).strip()
|
||||
mystatus = mycommon.tryInt(str(mydata['status']))
|
||||
|
||||
if (str(mystatus) != "0" and str(mystatus) != "1" and str(mystatus) != "2"):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " Le champ 'status' de la ligne " + str(
|
||||
n) + " est incorrecte. Valeurs acceptées : 0,1,2")
|
||||
return False, " Le champ status de la ligne " + str(
|
||||
n) + " est incorrecte. Valeurs acceptées : 0,1,2"
|
||||
|
||||
if (str(mystatus).strip() == "1"):
|
||||
mydata['inscription_validation_date'] = str(datetime.now().strftime("%d/%m/%Y %H:%M:%S"))
|
||||
|
||||
local_price = str(df['prix'].values[n]).strip()
|
||||
local_status, new_price = mycommon.IsFloat(local_price)
|
||||
if (local_status is False):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " Le champ 'prix' de la ligne " + str(n + 2) + " est incorrecte.")
|
||||
return False, " Le champ prix de la ligne " + str(n + 2) + " est incorrecte. "
|
||||
|
||||
mydata['price'] = local_price
|
||||
|
||||
type_apprenant = "0"
|
||||
if ("type_apprenant" in df.keys()):
|
||||
if (str(df['type_apprenant'].values[n])):
|
||||
type_apprenant = str(df['type_apprenant'].values[n]).strip()
|
||||
type_apprenant = str(mycommon.tryInt(type_apprenant))
|
||||
|
||||
if (type_apprenant not in MYSY_GV.INSCRIPTION_TYPE_APPRENANT):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + "Ligne : " + str(
|
||||
n + 2) + ". Le type apprenant doit etre l'une des valeurs suivantes :" + str(
|
||||
MYSY_GV.INSCRIPTION_TYPE_APPRENANT))
|
||||
return False, "Ligne : " + str(
|
||||
n + 2) + ". Le type apprenant doit etre l'une des valeurs suivantes :" + str(
|
||||
MYSY_GV.INSCRIPTION_TYPE_APPRENANT)
|
||||
|
||||
mydata['type_apprenant'] = type_apprenant
|
||||
|
||||
cpt_valide_row = cpt_valide_row + 1
|
||||
|
||||
clean_dict = {k: mydata[k] for k in mydata if (str(mydata[k]) != "nan")}
|
||||
|
||||
print( "#### clean_dict ", clean_dict)
|
||||
status, retval = Add_Stagiaire_To_Admission_Session(clean_dict)
|
||||
if (status is False):
|
||||
return status, retval
|
||||
|
||||
|
||||
|
||||
print(str(cpt_valide_row) + " candidat ont été insérés")
|
||||
|
||||
return True, str(cpt_valide_row) + " participants ont été inserés / Mises à jour"
|
||||
|
||||
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))
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Fonction de controle du fichier
|
||||
"""
|
||||
def Controle_Add_Admission_Candidat_mass_for_One_Session(saved_file=None, Folder=None, diction=None):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
'''
|
||||
# Verification que les champs reçus dans l'API sont bien dans la liste des champs autorisés
|
||||
# Cela evite le cas ou une entité tierce ajouter les valeurs inconnu dans l'API
|
||||
# Ici on doit mettre tous les champs possible (obligatoire ou non) de la BDD dans la liste
|
||||
# field_list.
|
||||
'''
|
||||
field_list = ['token','session_id']
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
if val not in field_list and val.startswith('my_') is False:
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " Le champ '" + val + "' n'existe pas, Creation participants annulée")
|
||||
return False, " Verifier votre API"
|
||||
|
||||
'''
|
||||
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 = ['token', ]
|
||||
|
||||
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 la liste des arguments ")
|
||||
return False, " Verifier votre API, Toutes les informations techniques ne sont pas fournies"
|
||||
|
||||
my_token = ""
|
||||
if ("token" in diction.keys()):
|
||||
if diction['token']:
|
||||
my_token = diction['token']
|
||||
|
||||
# Verifier la validité du token
|
||||
retval = mycommon.check_partner_token_validity("", my_token)
|
||||
if retval is False:
|
||||
return "Err_Connexion", " La session de connexion n'est pas valide"
|
||||
|
||||
|
||||
|
||||
partner_recid = mycommon.get_parnter_recid_from_token(my_token)
|
||||
if (partner_recid is False):
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - partner_recid KO : Impossible d'importer la liste des participants ")
|
||||
return False, " Les information de connexion sont incorrectes. Impossible d'importer la liste des participants"
|
||||
|
||||
|
||||
|
||||
df = pd.read_csv(saved_file, encoding='utf8', on_bad_lines='skip', sep=';', encoding_errors='ignore', skipinitialspace=True)
|
||||
df = df.fillna('')
|
||||
df = df.applymap(lambda x: x.strip() if isinstance(x, str) else x)
|
||||
|
||||
|
||||
# Dictionnaire des champs utilisables
|
||||
'''
|
||||
# Verification que les noms des colonne sont bien corrects"
|
||||
'''
|
||||
field_list = [ 'prenom', 'nom', 'prenom', 'email', 'telephone', 'modefinancement',
|
||||
'session_id', 'employeur', 'status', 'price',
|
||||
'client_rattachement_id', 'adresse', 'code_postal', 'ville', 'pays',
|
||||
'type_apprenant', 'civilite', 'date_naissance', 'memo', 'comment',
|
||||
"num_secu", "is_rgpd", "situation_famille", "piece_identite_type", "piece_identite_num",
|
||||
"type_mobilite", "telephone_bis", "nationalite", "is_handicap", "is_handicap", "is_droit_image",
|
||||
'naissance_lieu', 'naissance_departement', 'naissance_pays', 'session_etape_code', 'ine', 'nom_fille']
|
||||
|
||||
|
||||
# Controle du nombre de lignes dans le fichier.
|
||||
total_rows = len(df)
|
||||
if( total_rows > MYSY_GV.MAX_PARTICIPANT_BY_CSV ):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " Le fichier comporte plus de "+str(MYSY_GV.MAX_PARTICIPANT_BY_CSV)+" lignes.")
|
||||
return False, " Le fichier comporte plus de "+str(MYSY_GV.MAX_PARTICIPANT_BY_CSV)+" lignes."
|
||||
|
||||
|
||||
#print(" ### df.columns = ", df.columns)
|
||||
for val in df.columns:
|
||||
#print(" ### val = ", val)
|
||||
if str(val).lower() not in field_list:
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3])+" : entete du fichier csv. '" + val + "' n'est pas acceptée")
|
||||
return False, " Entete du fichier csv. La Colonne '" + val + "' n'est pas acceptée"
|
||||
|
||||
|
||||
# Verification des champs obligatoires dans le fichier
|
||||
field_list_obligatoire_file = ['nom', 'prenom', 'email', 'telephone',
|
||||
'session_id', 'token']
|
||||
|
||||
for val in field_list_obligatoire_file:
|
||||
if val not in df.columns:
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " : Le champ '" + val + "' n'est pas présent dans le fichier. Il est obligatoire")
|
||||
return False, " Le champ '" + val + "' n'est pas présent dans le fichier. Il est obligatoire "
|
||||
|
||||
|
||||
|
||||
"""
|
||||
# Recuperation des info de la session.
|
||||
session_data = MYSY_GV.dbname['session_formation'].find_one({'formation_session_id':str(session_id)})
|
||||
if( session_data is None ):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " La session de formation n'existe pas : Impossible d'importer la liste des participants ")
|
||||
return False, "la session de formation n'existe pas. Impossible d'importer la liste des participants"
|
||||
|
||||
#print(" #### session_data = ",session_data)
|
||||
"""
|
||||
|
||||
mysession_count_qry = {'_id': ObjectId(str(diction['session_id'])), 'valide': '1',
|
||||
'partner_owner_recid': str(partner_recid), }
|
||||
|
||||
# print(" ### mysession_count_qry = ", mysession_count_qry)
|
||||
|
||||
mysession_count = MYSY_GV.dbname['admission_session'].count_documents(mysession_count_qry)
|
||||
|
||||
if (mysession_count != 1):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " La session d'admission est invalide ")
|
||||
return False, "La session d'admission est invalide "
|
||||
|
||||
mysession_data = MYSY_GV.dbname['session_formation'].find_one(mysession_count_qry)
|
||||
|
||||
|
||||
x = range(0, total_rows)
|
||||
cpt_valide_row = 0
|
||||
for n in x:
|
||||
if( str(df['prenom'].values[n]) and str(df['nom'].values[n]) and str(df['email'].values[n]) ) :
|
||||
mydata = {}
|
||||
class_external_code = str(df['formation_code_externe'].values[n])
|
||||
#mydata['code_session'] = str(df['code_session'].values[n])
|
||||
mydata['prenom'] = str(df['prenom'].values[n])
|
||||
mydata['nom'] = str(df['nom'].values[n])
|
||||
if (len(str(mydata['nom']).strip()) < 2):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " Le champ 'nom' de la ligne " + str(
|
||||
n + 2) + " doit faire plus de deux caractères.")
|
||||
return False, " Le champ nom de la ligne " + str(
|
||||
n + 2) + " doit faire plus de deux caractères. "
|
||||
|
||||
|
||||
mydata['telephone'] = str(df['telephone'].values[n])
|
||||
mydata['email'] = str(df['email'].values[n]).strip().lower()
|
||||
#print(" contole du mail = ", mydata['email'])
|
||||
regex = r'\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,7}\b'
|
||||
if (not re.fullmatch(regex, str( mydata['email']) )):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + "Ligne : "+str(n+2) +" : L'adresse email " + str(mydata['email']) + " est invalide")
|
||||
return False, " Ligne : "+str(n+2) +" : L'adresse email -" + str(mydata['email']) + "- est invalide"
|
||||
|
||||
mydata['token'] = str(my_token)
|
||||
|
||||
"""
|
||||
Verifier qu'il n'y pas un étudiant avec le meme INE (Identifiant National Étudiant)
|
||||
"""
|
||||
if ("ine" in df.keys() ):
|
||||
local_ine = str(df['ine'].values[n])
|
||||
is_exist_ine_count = MYSY_GV.dbname['admission_session_inscrit'].count_documents(
|
||||
{'ine': str(local_ine),
|
||||
'session_id': str(diction['session_id']),
|
||||
'partner_owner_recid': str(partner_recid)
|
||||
})
|
||||
|
||||
if (is_exist_ine_count > 0):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " Ligne : "+str(n+2) +" : Il y a déjà un candidat avec le même numéro Identifiant National Étudiant (INE) ")
|
||||
return False, " Ligne : "+str(n+2) +" : Il y a déjà un candidat avec le même numéro Identifiant National Étudiant (INE) "
|
||||
|
||||
"""
|
||||
Verifier qu'il n'y pas déjà une presonne inscrite avec le meme email pour la meme session
|
||||
"""
|
||||
if ("email" in df.keys()):
|
||||
local_email = str(df['email'].values[n]).lower()
|
||||
is_inscrit_exist = MYSY_GV.dbname['admission_session_inscrit'].count_documents(
|
||||
{
|
||||
"email": {
|
||||
"$regex": f"^{re.escape(str(local_email))}$",
|
||||
"$options": "i"
|
||||
},
|
||||
'session_id': diction['session_id'],
|
||||
'partner_owner_recid': partner_recid})
|
||||
|
||||
if (is_inscrit_exist > 0):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " Ligne : "+str(n+2) +" : Une personne est déjà inscrite à cette session avec la même adresse email ")
|
||||
return False, " Ligne : "+str(n+2) +" : Une personne est déjà inscrite à cette session avec la même adresse email "
|
||||
|
||||
"""
|
||||
Verifier la validité de l'etape
|
||||
"""
|
||||
if ("session_etape_code" in df.keys()):
|
||||
local_session_etape = str(df['session_etape'].values[n]).lower().strip()
|
||||
|
||||
session_etape_id = MYSY_GV.dbname['admission_setup_etape'].count_documents(
|
||||
{
|
||||
"code": {
|
||||
"$regex": f"^{re.escape(str(local_session_etape))}$",
|
||||
"$options": "i"
|
||||
},
|
||||
'valide': '1', 'partner_owner_recid': str(partner_recid)})
|
||||
|
||||
if (session_etape_id != 1):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " Ligne : "+str(n+2) +" : Le code de l'étape est invalide ")
|
||||
return False, " Ligne : "+str(n+2) +" : Le code de l'étape est invalide "
|
||||
|
||||
if ("is_handicap" in df.keys() ):
|
||||
local_is_handicap = str(df['is_handicap'].values[n]).lower().strip()
|
||||
if( local_is_handicap not in ['0', '1', '']):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + "Ligne : "+str(n+2) +" : Le champ 'is_handicap' est invalide ")
|
||||
return False, "Ligne : "+str(n+2) +" : Le champ 'is_handicap' est invalide "
|
||||
|
||||
if ("is_droit_image" in df.keys() ):
|
||||
local_is_droit_image = str(df['is_droit_image'].values[n]).lower().strip()
|
||||
if( local_is_droit_image not in ['0', '1', '']):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + "Ligne : "+str(n+2) +" : Le champ 'is_droit_image' est invalide ")
|
||||
return False, "Ligne : "+str(n+2) +" : Le champ 'is_droit_image' est invalide "
|
||||
|
||||
|
||||
if ("is_rgpd" in df.keys() ):
|
||||
local_is_rgpd = str(df['is_rgpd'].values[n]).lower().strip()
|
||||
if( local_is_rgpd not in ['0', '1', '']):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + "Ligne : "+str(n+2) +" : Le champ 'is_rgpd' est invalide ")
|
||||
return False, "Ligne : "+str(n+2) +" : Le champ 'is_rgpd' est invalide "
|
||||
|
||||
|
||||
|
||||
if ("date_naissance" in df.keys()):
|
||||
mydata['date_naissance'] = str(df['date_naissance'].values[n]).strip().split(" ")[0]
|
||||
if( mydata['date_naissance'] ) :
|
||||
local_status = mycommon.CheckisDate(mydata['date_naissance'])
|
||||
if (local_status is False):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " La date de naissance à ligne " + str(
|
||||
n + 2) + " n'est pas au format 'jj/mm/aaaa' .")
|
||||
|
||||
return False, " La date de naissance à ligne " + str(n + 2) + " n'est pas au format 'jj/mm/aaaa' "
|
||||
|
||||
mydata['session_id'] = str(mysession_data['_id'])
|
||||
mydata['class_internal_url'] = str(mysession_data['class_internal_url'])
|
||||
|
||||
|
||||
|
||||
adresse = ""
|
||||
if ("adresse" in df.keys()):
|
||||
if (str(df['adresse'].values[n])):
|
||||
adresse = str(df['adresse'].values[n])
|
||||
mydata['adresse'] = adresse
|
||||
|
||||
code_postal = ""
|
||||
if ("code_postal" in df.keys()):
|
||||
if (str(df['code_postal'].values[n])):
|
||||
code_postal = str(df['code_postal'].values[n])
|
||||
mydata['code_postal'] = code_postal
|
||||
|
||||
ville = ""
|
||||
if ("ville" in df.keys()):
|
||||
if (str(df['ville'].values[n])):
|
||||
ville = str(df['ville'].values[n])
|
||||
mydata['ville'] = ville
|
||||
|
||||
pays = ""
|
||||
if ("pays" in df.keys()):
|
||||
if (str(df['pays'].values[n])):
|
||||
pays = str(df['pays'].values[n])
|
||||
mydata['pays'] = pays
|
||||
|
||||
civilite = ""
|
||||
if ("civilite" in df.keys()):
|
||||
if (str(df['civilite'].values[n])):
|
||||
civilite = str(df['civilite'].values[n]).lower()
|
||||
mydata['civilite'] = str(civilite).lower()
|
||||
|
||||
if( str(civilite).strip() == ""):
|
||||
mydata['civilite'] = "neutre"
|
||||
|
||||
if( civilite not in MYSY_GV.CIVILITE):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " Ligne : " + str(
|
||||
n + 2) + ". La civilité :" + str(
|
||||
civilite) + " est invalide. Les valeurs acceptées sont : "+str(MYSY_GV.CIVILITE))
|
||||
return False, " Ligne : " + str(
|
||||
n + 2) + ". La civilité :" + str(
|
||||
civilite) + " est invalide. Les valeurs acceptées sont : "+str(MYSY_GV.CIVILITE)
|
||||
|
||||
""""
|
||||
Gestion du client de rattachement/
|
||||
Avec l'email et le nom, on va aller récupérer l'_id du client
|
||||
"""
|
||||
client_rattachement_email = ""
|
||||
if ("client_rattachement_email" in df.keys()):
|
||||
if (str(df['client_rattachement_email'].values[n]) and str(df['client_rattachement_email'].values[n]) != "nan"):
|
||||
client_rattachement_email = str(df['client_rattachement_email'].values[n]).strip()
|
||||
|
||||
|
||||
client_rattachement_nom = ""
|
||||
if ("client_rattachement_nom" in df.keys()):
|
||||
if (str(df['client_rattachement_nom'].values[n]) and str(df['client_rattachement_nom'].values[n]) != "nan" ):
|
||||
client_rattachement_nom = str(df['client_rattachement_nom'].values[n]).strip()
|
||||
if (client_rattachement_email and client_rattachement_nom):
|
||||
local_client_retval_qry = {'email':str(client_rattachement_email), 'nom':str(client_rattachement_nom),
|
||||
'valide':'1', 'locked':'0', 'partner_owner_recid' :str(partner_recid)}
|
||||
|
||||
print(" ### local_client_retval_qry = ", local_client_retval_qry)
|
||||
local_client_retval_count = MYSY_GV.dbname['partner_client'].count_documents(local_client_retval_qry)
|
||||
|
||||
if( local_client_retval_count > 1 ):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) +"Ligne : "+str(n+2) +". Plusieurs clients correspondent aux critère de nom :"+str(client_rattachement_nom)+" et email : "+str(client_rattachement_email))
|
||||
return False, "Ligne : "+str(n+2) +". Plusieurs clients correspondent aux critère de nom :"+str(client_rattachement_nom)+" et email : "+str(client_rattachement_email)
|
||||
|
||||
if (local_client_retval_count < 1):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + "Ligne : "+str(n+2) +". Aucun client ne repond aux critères de nom :" + str(
|
||||
client_rattachement_nom) + " et email : " + str(client_rattachement_email))
|
||||
return False, "Ligne : "+str(n+2) +". Aucun client ne repond aux critères de nom :" + str(
|
||||
client_rattachement_nom) + " et email : " + str(client_rattachement_email)
|
||||
|
||||
local_client_retval_data = MYSY_GV.dbname['partner_client'].find_one(local_client_retval_qry)
|
||||
if( local_client_retval_data is not None ):
|
||||
mydata['client_rattachement_id'] = str(local_client_retval_data['_id'])
|
||||
|
||||
""""
|
||||
Gestion du client dà facturer/
|
||||
Avec l'email et le nom, on va aller récupérer l'_id du client
|
||||
"""
|
||||
facture_client_rattachement_email = ""
|
||||
if ("facture_client_rattachement_email" in df.keys()):
|
||||
if (str(df['facture_client_rattachement_email'].values[n]) and str(
|
||||
df['facture_client_rattachement_email'].values[n]) != "nan"):
|
||||
facture_client_rattachement_email = str(df['facture_client_rattachement_email'].values[n]).strip()
|
||||
|
||||
facture_client_rattachement_nom = ""
|
||||
if ("facture_client_rattachement_nom" in df.keys()):
|
||||
if (str(df['facture_client_rattachement_nom'].values[n]) and str(
|
||||
df['facture_client_rattachement_nom'].values[n]) != "nan"):
|
||||
facture_client_rattachement_nom = str(df['facture_client_rattachement_nom'].values[n]).strip()
|
||||
|
||||
if (facture_client_rattachement_email and facture_client_rattachement_nom):
|
||||
local_client_retval_qry = {'email': str(facture_client_rattachement_email),
|
||||
'nom': str(facture_client_rattachement_nom),
|
||||
'valide': '1', 'locked': '0', 'partner_owner_recid': str(partner_recid)}
|
||||
|
||||
print(" ### local_client_retval_qry = ", local_client_retval_qry)
|
||||
local_client_retval_count = MYSY_GV.dbname['partner_client'].count_documents(local_client_retval_qry)
|
||||
|
||||
if (local_client_retval_count > 1):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + "Ligne : " + str(
|
||||
n + 2) + ". Plusieurs entités de facturation correspondent aux critères de nom :" + str(
|
||||
facture_client_rattachement_nom) + " et email : " + str(facture_client_rattachement_email))
|
||||
return False, "Ligne : " + str(
|
||||
n + 2) + ". Plusieurs entités de facturation correspondent aux critères de nom :" + str(
|
||||
facture_client_rattachement_nom) + " et email : " + str(facture_client_rattachement_email)
|
||||
|
||||
if (local_client_retval_count < 1):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + "Ligne : " + str(
|
||||
n + 2) + ". Aucune entité de facturation ne repond aux critères de nom :" + str(
|
||||
facture_client_rattachement_nom) + " et email : " + str(facture_client_rattachement_email))
|
||||
return False, "Ligne : " + str(
|
||||
n + 2) + ". Aucune entité de facturation ne repond aux critères de nom :" + str(
|
||||
facture_client_rattachement_nom) + " et email : " + str(facture_client_rattachement_email)
|
||||
|
||||
local_client_retval_data = MYSY_GV.dbname['partner_client'].find_one(local_client_retval_qry)
|
||||
if (local_client_retval_data is not None):
|
||||
mydata['facture_client_rattachement_id'] = str(local_client_retval_data['_id'])
|
||||
|
||||
|
||||
mydata['status'] = str(df['status'].values[n]).strip()
|
||||
mystatus = mycommon.tryInt(str(mydata['status']))
|
||||
|
||||
|
||||
if( str(mystatus) != "0" and str(mystatus) != "1" and str(mystatus) != "2"):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " Le champ 'status' de la ligne " + str(n) + " est incorrecte. Valeurs acceptées : 0,1,2")
|
||||
return False, " Le champ status de la ligne " + str(n) + " est incorrecte. Valeurs acceptées : 0,1,2"
|
||||
|
||||
|
||||
if( str(mystatus).strip() == "1"):
|
||||
mydata['inscription_validation_date'] = str(datetime.now().strftime("%d/%m/%Y %H:%M:%S"))
|
||||
|
||||
|
||||
local_price = str(df['prix'].values[n]).strip()
|
||||
local_status, new_price = mycommon.IsFloat(local_price)
|
||||
if( local_status is False ):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][ 3]) + " Le champ 'prix' de la ligne " + str( n+2) + " est incorrecte.")
|
||||
return False, " Le champ prix de la ligne " + str(n+2) + " est incorrecte. "
|
||||
|
||||
mydata['price'] = local_price
|
||||
|
||||
type_apprenant = "0"
|
||||
if ("type_apprenant" in df.keys()):
|
||||
if (str(df['type_apprenant'].values[n])):
|
||||
type_apprenant = str(df['type_apprenant'].values[n]).strip()
|
||||
type_apprenant = str(mycommon.tryInt(type_apprenant))
|
||||
|
||||
if (type_apprenant not in MYSY_GV.INSCRIPTION_TYPE_APPRENANT):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + "Ligne : " + str(
|
||||
n + 2) + ". Le type apprenant doit etre l'une des valeurs suivantes :" + str(
|
||||
MYSY_GV.INSCRIPTION_TYPE_APPRENANT))
|
||||
return False, "Ligne : " + str(
|
||||
n + 2) + ". Le type apprenant doit etre l'une des valeurs suivantes :" + str(
|
||||
MYSY_GV.INSCRIPTION_TYPE_APPRENANT)
|
||||
|
||||
mydata['type_apprenant'] = type_apprenant
|
||||
|
||||
cpt_valide_row = cpt_valide_row + 1
|
||||
|
||||
|
||||
clean_dict = {k: mydata[k] for k in mydata if ( str(mydata[k]) != "nan") }
|
||||
|
||||
#print( "#### clean_dict ", clean_dict)
|
||||
|
||||
|
||||
return True, str(cpt_valide_row)+" candidats dans le fichier"
|
||||
|
||||
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 controler le fichier des candidat a importer en masse "
|
||||
|
|
|
|||
298
wrapper.py
298
wrapper.py
|
|
@ -386,17 +386,14 @@ retourne les formation avec un recid donnée
|
|||
on ne retourne que les formation dont published_catalog_prive != 0
|
||||
"""
|
||||
|
||||
|
||||
|
||||
|
||||
def get_all_class_Given_partner_owner_recid_No_Login_With_Valide_Session(diction):
|
||||
def get_all_class_Given_partner_owner_recid_No_Login(diction):
|
||||
try:
|
||||
|
||||
# Dictionnaire des champs utilisables
|
||||
field_list = ['token', 'user_ip', 'user_country_code', 'user_country_name', 'user_city',
|
||||
'user_postal', 'user_latitude', 'user_longitude', 'user_state', 'search_text', 'certif',
|
||||
'support', 'type', 'lang', 'price', 'distance', 'duration', 'cpf', 'connection_type',
|
||||
'partner_owner_recid', 'subdomain']
|
||||
'partner_owner_recid', 'subdomain', 'formation_type']
|
||||
|
||||
incom_keys = diction.keys()
|
||||
|
||||
|
|
@ -535,6 +532,10 @@ def get_all_class_Given_partner_owner_recid_No_Login_With_Valide_Session(diction
|
|||
if (str(connection_type).strip() == "partner"):
|
||||
connected_client_recid = user_recid
|
||||
|
||||
filter_formation_type = {'formation_type':{'$ne':'atelier'}}
|
||||
if( "formation_type" in diction.keys() and diction['formation_type'] in MYSY_GV.FORMATION_TYPE):
|
||||
filter_formation_type = {'formation_type':str(diction['formation_type'])}
|
||||
|
||||
pipe = [{'$match':
|
||||
{"$and": [{"$or": [{'valide': '1', 'locked': '0', 'isalaune': '1', },
|
||||
{'coeur': 1, 'published': '1'}]},
|
||||
|
|
@ -542,6 +543,272 @@ def get_all_class_Given_partner_owner_recid_No_Login_With_Valide_Session(diction
|
|||
{'display_rank': {'$nin': []}},
|
||||
{'partner_owner_recid':partner_owner_recid},
|
||||
{'published_catalog_prive': {'$ne': "0"}},
|
||||
filter_formation_type
|
||||
]}
|
||||
},
|
||||
{'$project': {'indexed': 0, 'indexed_desc': 0, 'indexed_obj': 0, "indexed_title": 0,
|
||||
"valide": 0, "locked": 0}},
|
||||
{'$lookup':
|
||||
{
|
||||
'from': 'business_prices',
|
||||
'let': {'partner_owner_recid': "$partner_owner_recid", 'programme': '$programme'},
|
||||
|
||||
'pipeline': [
|
||||
{'$match':
|
||||
{'$expr':
|
||||
{'$and':
|
||||
[
|
||||
{'$eq': ["$partner_recid", "$$partner_owner_recid"]},
|
||||
{'$eq': ["$client_recid", connected_client_recid]},
|
||||
{'$eq': ["$valide", "1"]}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
],
|
||||
'as': 'business_prices'
|
||||
}
|
||||
},
|
||||
{'$sort': {"display_rank": pymongo.DESCENDING, "price": pymongo.ASCENDING,
|
||||
"date_update": pymongo.DESCENDING}},
|
||||
{'$limit': nb_formation_a_jouter},
|
||||
]
|
||||
|
||||
mytoday = datetime.today()
|
||||
#print(" ### get_all_class_Given_partner_owner_recid_No_Login pipe = ", pipe)
|
||||
for x in MYSY_GV.dbname['myclass'].aggregate(pipe):
|
||||
"""
|
||||
24/10/2025 - Pour verifie si le prix est HT ou TTC du PRORITAIRE DE LA FORMATION
|
||||
on va aller chercher la valeur de TVA dans la collecion :'base_partner_setup'
|
||||
"""
|
||||
partnaire_tva = ""
|
||||
partner_tva_retval = mycommon.Get_Class_Owner_class(str(x['partner_owner_recid']))
|
||||
if (partner_tva_retval is False):
|
||||
partnaire_tva = ""
|
||||
else:
|
||||
partnaire_tva = partner_tva_retval
|
||||
|
||||
x['partnaire_tva'] = str(partnaire_tva)
|
||||
|
||||
# print("AVANT ==> "+str(x['description']))
|
||||
if ("description" in x.keys()):
|
||||
val = x['description']
|
||||
no_html = mycommon.cleanhtml(x['description'])
|
||||
if (len(no_html) > MYSY_GV.MAX_CARACT):
|
||||
x['description'] = no_html[:MYSY_GV.MAX_CARACT] + " ..."
|
||||
|
||||
else:
|
||||
x['description'] = no_html
|
||||
|
||||
# mycommon.myprint("APRES ==> " + str(x['description']))
|
||||
|
||||
tab_selected_business_prices = []
|
||||
if ("business_prices" in x.keys()):
|
||||
|
||||
for local_business_prices in x['business_prices']:
|
||||
|
||||
if ("date_du" in local_business_prices.keys() and "date_au" in local_business_prices.keys()
|
||||
and mycommon.CheckisDate(local_business_prices['date_du']) and mycommon.CheckisDate(
|
||||
local_business_prices['date_au'])):
|
||||
|
||||
local_date_du = datetime.strptime(str(local_business_prices['date_du']).strip(), '%d/%m/%Y')
|
||||
local_date_au = datetime.strptime(str(local_business_prices['date_au']).strip(), '%d/%m/%Y')
|
||||
|
||||
if (local_date_du <= mytoday and mytoday <= local_date_au):
|
||||
local_discount = mycommon.tryFloat(str(local_business_prices['discount']))
|
||||
local_initial_price = mycommon.tryFloat(str(x['price']))
|
||||
local_discounted_price = round(
|
||||
local_initial_price - (local_initial_price * (local_discount / 100)), 2)
|
||||
x['business_prices'][0]['discounted_price'] = str(local_discounted_price)
|
||||
local_business_prices['discounted_price'] = str(local_discounted_price)
|
||||
tab_selected_business_prices.append(local_business_prices)
|
||||
|
||||
user = x
|
||||
user['id'] = str(val_tmp)
|
||||
user['business_prices'] = tab_selected_business_prices
|
||||
|
||||
insertObject.append(JSONEncoder().encode(user))
|
||||
|
||||
# print(" 1111111 ")
|
||||
# print(str(x))
|
||||
mycommon.InsertStatistic(x, "summary", mydata)
|
||||
|
||||
tab_training_inzone.append(JSONEncoder().encode(user))
|
||||
val_tmp = val_tmp + 1
|
||||
|
||||
# print(" ### insertObject = ", str(tab_training_inzone))
|
||||
# return True, insertObject
|
||||
return True, tab_training_inzone
|
||||
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 récupérer les formations"
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Icion va chercher les formaton aves les sessions valides
|
||||
"""
|
||||
def get_all_class_Given_partner_owner_recid_No_Login_With_Valide_Session(diction):
|
||||
try:
|
||||
|
||||
# Dictionnaire des champs utilisables
|
||||
field_list = ['token', 'user_ip', 'user_country_code', 'user_country_name', 'user_city',
|
||||
'user_postal', 'user_latitude', 'user_longitude', 'user_state', 'search_text', 'certif',
|
||||
'support', 'type', 'lang', 'price', 'distance', 'duration', 'cpf', 'connection_type',
|
||||
'partner_owner_recid', 'subdomain', 'formation_type']
|
||||
|
||||
incom_keys = diction.keys()
|
||||
|
||||
'''
|
||||
# Verification que les champs reçus dans l'API sont bien dans la liste des champs autorisés
|
||||
# Cela evite le cas ou une entité tierce ajouter les valeurs inconnu dans l'API
|
||||
# Ici on doit mettre tous les champs possible (obligatoire ou non) de la BDD dans la liste
|
||||
# field_list.
|
||||
'''
|
||||
for val in incom_keys:
|
||||
if str(val).lower() not in str(field_list).lower():
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " Le champ '" + val + "' n'est pas autorisé")
|
||||
return False, " Recherche impossible"
|
||||
|
||||
# Recuperation des parametres
|
||||
mydata = {}
|
||||
if ("user_ip" in diction.keys()):
|
||||
if diction['user_ip']:
|
||||
mydata['user_ip'] = diction['user_ip']
|
||||
|
||||
if ("user_country_code" in diction.keys()):
|
||||
if diction['user_country_code']:
|
||||
mydata['user_country_code'] = diction['user_country_code']
|
||||
|
||||
if ("user_country_name" in diction.keys()):
|
||||
if diction['user_country_name']:
|
||||
mydata['user_country_name'] = diction['user_country_name']
|
||||
|
||||
if ("user_city" in diction.keys()):
|
||||
if diction['user_city']:
|
||||
mydata['user_city'] = diction['user_city']
|
||||
|
||||
if ("user_postal" in diction.keys()):
|
||||
if diction['user_postal']:
|
||||
mydata['user_postal'] = diction['user_postal']
|
||||
|
||||
if ("user_latitude" in diction.keys()):
|
||||
if diction['user_latitude']:
|
||||
mydata['user_latitude'] = diction['user_latitude']
|
||||
|
||||
if ("user_longitude" in diction.keys()):
|
||||
if diction['user_longitude']:
|
||||
mydata['user_longitude'] = diction['user_longitude']
|
||||
|
||||
if ("user_state" in diction.keys()):
|
||||
if diction['user_state']:
|
||||
mydata['user_state'] = diction['user_state']
|
||||
|
||||
connection_type = ""
|
||||
if ("connection_type" in diction.keys()):
|
||||
if diction['connection_type']:
|
||||
connection_type = diction['connection_type']
|
||||
|
||||
token = ""
|
||||
if ("token" in diction.keys()):
|
||||
if diction['token']:
|
||||
token = diction['token']
|
||||
|
||||
# print(" My Data ="+str(mydata))
|
||||
|
||||
partner_owner_recid = ""
|
||||
if( "subdomain" in diction.keys() and diction['subdomain']):
|
||||
partnair_data_count = MYSY_GV.dbname['partnair_account'].count_documents({'subdomaine_catalog_pub': diction['subdomain'],
|
||||
'active': '1',
|
||||
'locked': '0',
|
||||
'firstconnexion': '0',
|
||||
'is_partner_admin_account': '1'
|
||||
})
|
||||
|
||||
if (partnair_data_count == 1):
|
||||
partnair_data = MYSY_GV.dbname['partnair_account'].find_one({'subdomaine_catalog_pub': diction['subdomain'],
|
||||
'active': '1',
|
||||
'locked': '0',
|
||||
'firstconnexion': '0',
|
||||
'is_partner_admin_account': '1'
|
||||
}, {'_id': 1, 'recid': 1, 'nom': 1})
|
||||
|
||||
if( partnair_data and 'recid' in partnair_data.keys() ):
|
||||
partner_owner_recid = partnair_data['recid']
|
||||
|
||||
|
||||
status, tab_training_inzone = get_training_in_user_zone(diction)
|
||||
|
||||
nb_formation_a_jouter = MYSY_GV.MAINPAGE_QUERY_LIMIT_ROW - len(tab_training_inzone)
|
||||
|
||||
# print(" #### get_all_class : nb_formation_a_jouter "+str(nb_formation_a_jouter)+" "
|
||||
# "MYSY_GV.MAINPAGE_QUERY_LIMIT_ROW = "+str(MYSY_GV.MAINPAGE_QUERY_LIMIT_ROW)+" len(tab_training_inzone) = "+
|
||||
# str(len(tab_training_inzone) ))
|
||||
|
||||
alread_found = []
|
||||
# print(str(tab_training_inzone))
|
||||
for val in tab_training_inzone:
|
||||
stud_obj = json.loads(val)
|
||||
json_obj = json.dumps(stud_obj)
|
||||
if (stud_obj['external_code']):
|
||||
alread_found.append(str(stud_obj['external_code']))
|
||||
# print(" stud_obj = "+str(stud_obj['external_code']))
|
||||
|
||||
user_recid = "None"
|
||||
# Verification de la validité du token/mail dans le cas des partner en mode connecté
|
||||
if (len(str(token)) > 0 and str(connection_type).strip() == "partner"):
|
||||
retval = mycommon.check_partner_token_validity("", token)
|
||||
|
||||
if retval is False:
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - La session de connexion n'est pas valide")
|
||||
return "Err_Connexion", "La session de connexion n'est pas valide"
|
||||
|
||||
# Recuperation du recid de l'utilisateur
|
||||
user_recid = mycommon.get_parnter_recid_from_token(token)
|
||||
if user_recid is False:
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " - Impossible de récupérer le token de l'utilisateur")
|
||||
return False, " Impossible de récupérer le token de l'utilisateur"
|
||||
|
||||
"""
|
||||
Travail à faire :
|
||||
le bug actuel vient du fait que la 2ieme requete ci-dessous qui complete la liste des formation
|
||||
ajoute les formations deja trouvée dans la requete d'en haute.
|
||||
|
||||
A faire : faire en sorte que la requete d'en dessous exclus les elements deja trouvée dans lreque en dessus.
|
||||
|
||||
|
||||
"""
|
||||
print(" alread_found = " + str(alread_found))
|
||||
coll_name = MYSY_GV.dbname['myclass']
|
||||
|
||||
val_tmp = len(tab_training_inzone)
|
||||
insertObject = []
|
||||
"""
|
||||
ORIG FOR
|
||||
for x in coll_name.find({ "$or": [ {'valide':'1', 'locked':'0', 'isalaune':'1', 'published':'1'}, { 'coeur': 1, 'published':'1' } ] },
|
||||
{"_id": 0, "indexed": 0, "indexed_desc": 0, "indexed_obj": 0, "indexed_title": 0,
|
||||
"valide": 0, "locked": 0, }).\
|
||||
"""
|
||||
connected_client_recid = ""
|
||||
if (str(connection_type).strip() == "partner"):
|
||||
connected_client_recid = user_recid
|
||||
|
||||
filter_formation_type = {'formation_type':{'$ne':'atelier'}}
|
||||
if ("formation_type" in diction.keys() and diction['formation_type'] in MYSY_GV.FORMATION_TYPE):
|
||||
filter_formation_type = {'formation_type': str(diction['formation_type'])}
|
||||
|
||||
|
||||
pipe = [{'$match':
|
||||
{"$and": [{"$or": [{'valide': '1', 'locked': '0', 'isalaune': '1', },
|
||||
{'coeur': 1, 'published': '1'}]},
|
||||
{'external_code': {'$nin': alread_found}},
|
||||
{'display_rank': {'$nin': []}},
|
||||
{'partner_owner_recid':partner_owner_recid},
|
||||
{'published_catalog_prive': {'$ne': "0"}},
|
||||
filter_formation_type
|
||||
|
||||
]}
|
||||
},
|
||||
|
|
@ -648,6 +915,7 @@ def get_all_class_Given_partner_owner_recid_No_Login_With_Valide_Session(diction
|
|||
"code_session": 1,
|
||||
"date_debut": 1,
|
||||
"date_fin": 1,
|
||||
"titre":1,
|
||||
"ville": 1,
|
||||
"adresse": 1,
|
||||
"code_postal": 1,
|
||||
|
|
@ -667,6 +935,7 @@ def get_all_class_Given_partner_owner_recid_No_Login_With_Valide_Session(diction
|
|||
#print(" ### pipeline_session_valide QRY = ", pipeline_session_valide)
|
||||
|
||||
tab_session = []
|
||||
user = {}
|
||||
for local_session in MYSY_GV.dbname['session_formation'].aggregate(pipeline_session_valide):
|
||||
|
||||
"""
|
||||
|
|
@ -683,6 +952,8 @@ def get_all_class_Given_partner_owner_recid_No_Login_With_Valide_Session(diction
|
|||
x['partnaire_tva'] = str(partnaire_tva)
|
||||
local_session['partnaire_tva'] = str(partnaire_tva)
|
||||
|
||||
|
||||
|
||||
# print("AVANT ==> "+str(x['description']))
|
||||
if ("description" in x.keys()):
|
||||
val = x['description']
|
||||
|
|
@ -772,6 +1043,12 @@ def get_all_class_Given_partner_owner_recid_No_Login_With_Valide_Session(diction
|
|||
user['class_img'] = class_img
|
||||
|
||||
|
||||
if ("inscription_direct" in user.keys()):
|
||||
local_session['class_inscription_direct'] = user['inscription_direct']
|
||||
else:
|
||||
local_session['class_inscription_direct'] = "0"
|
||||
|
||||
|
||||
if ("metier" in user.keys()):
|
||||
local_session['metier'] = user['metier']
|
||||
|
||||
|
|
@ -787,19 +1064,20 @@ def get_all_class_Given_partner_owner_recid_No_Login_With_Valide_Session(diction
|
|||
if ("inscription_direct" in user.keys()):
|
||||
local_session['inscription_direct'] = user['inscription_direct']
|
||||
|
||||
print(" SESSS ion local_session = ", local_session)
|
||||
#print(" SESSS ion local_session = ", local_session)
|
||||
tab_session.append(local_session)
|
||||
|
||||
user['tab_session'] = tab_session
|
||||
|
||||
|
||||
print(" V2222 user = ", user)
|
||||
#print(" V2222 user = ", user)
|
||||
insertObject.append(JSONEncoder().encode(user))
|
||||
|
||||
# print(" 1111111 ")
|
||||
# print(str(x))
|
||||
mycommon.InsertStatistic(x, "summary", mydata)
|
||||
|
||||
if(user and '_id' in user.keys()):
|
||||
tab_training_inzone.append(JSONEncoder().encode(user))
|
||||
val_tmp = val_tmp + 1
|
||||
|
||||
|
|
@ -838,7 +1116,7 @@ def get_training_in_user_zone(diction):
|
|||
field_list = ['token', 'user_ip', 'user_country_code', 'user_country_name', 'user_city',
|
||||
'user_postal', 'user_latitude', 'user_longitude', 'user_state', 'search_text', 'certif',
|
||||
'support', 'type', 'lang', 'price', 'distance', 'duration', 'cpf', 'connection_type',
|
||||
'partner_owner_recid', 'subdomain']
|
||||
'partner_owner_recid', 'subdomain', 'formation_type']
|
||||
|
||||
incom_keys = diction.keys()
|
||||
|
||||
|
|
@ -895,7 +1173,7 @@ def get_training_in_user_zone(diction):
|
|||
|
||||
|
||||
#print(" ########## critère de recherche : user_country_code = "+str(mydata['user_country_code']).lower()+" ---- user_city = "+str(mydata['user_city']).lower())
|
||||
for x in coll_name.find({ "$or": [ {'valide':'1', 'locked':'0', 'isalaune':'1','published':'1', "zone_diffusion.country":str(mydata['user_country_code']).lower()},
|
||||
for x in MYSY_GV.dbname['myclass'].find({ "$or": [ {'valide':'1', 'locked':'0', 'isalaune':'1','published':'1', "zone_diffusion.country":str(mydata['user_country_code']).lower()},
|
||||
{'valide':'1', 'locked':'0', 'isalaune':'1', 'published':'1', "zone_diffusion.city":str(mydata['user_city']).lower()} ] },
|
||||
{"_id": 0, "indexed": 0, "indexed_desc": 0, "indexed_obj": 0, "indexed_title": 0,
|
||||
"valide": 0, "locked": 0, }).\
|
||||
|
|
@ -1138,7 +1416,7 @@ def recherche_text_simple(diction):
|
|||
#print(str(inspect.stack()[0][3]) + " ENREG DES RESULT :"+str(store_recherche_Id)+" --- "+str(final_message2))
|
||||
|
||||
|
||||
ret_val_user_rech = coll_name.find_one_and_update(
|
||||
ret_val_user_rech = MYSY_GV.dbname['myclass'].find_one_and_update(
|
||||
{'_id': ObjectId(store_recherche_Id)},
|
||||
{"$set": find_result},
|
||||
return_document=ReturnDocument.AFTER
|
||||
|
|
|
|||
Loading…
Reference in New Issue