21/08/23 - 15h
parent
2add31c414
commit
2f8f09607b
|
@ -1,8 +1,10 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="19/08/23 - 20h30">
|
||||
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="20/08/23 - 23h30">
|
||||
<change afterPath="$PROJECT_DIR$/ressources_humaines.js.py" afterDir="false" />
|
||||
<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$/Session_Formation.py" beforeDir="false" afterPath="$PROJECT_DIR$/Session_Formation.py" afterDir="false" />
|
||||
|
@ -70,13 +72,6 @@
|
|||
<option name="presentableId" value="Default" />
|
||||
<updated>1680804787304</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00027" summary="25/05/23 - 17h">
|
||||
<created>1685028085742</created>
|
||||
<option name="number" value="00027" />
|
||||
<option name="presentableId" value="LOCAL-00027" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1685028085742</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00028" summary="28/05/23 - 15h">
|
||||
<created>1685281037292</created>
|
||||
<option name="number" value="00028" />
|
||||
|
@ -413,7 +408,14 @@
|
|||
<option name="project" value="LOCAL" />
|
||||
<updated>1692470299774</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="76" />
|
||||
<task id="LOCAL-00076" summary="20/08/23 - 23h30">
|
||||
<created>1692568622854</created>
|
||||
<option name="number" value="00076" />
|
||||
<option name="presentableId" value="LOCAL-00076" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1692568622855</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="77" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="Vcs.Log.Tabs.Properties">
|
||||
|
@ -428,7 +430,6 @@
|
|||
</option>
|
||||
</component>
|
||||
<component name="VcsManagerConfiguration">
|
||||
<MESSAGE value="25/07/23 - 21h" />
|
||||
<MESSAGE value="26/07/23 - 23h" />
|
||||
<MESSAGE value="27/07/23 - 23h" />
|
||||
<MESSAGE value="28/07/23 - 19h" />
|
||||
|
@ -453,6 +454,7 @@
|
|||
<MESSAGE value="18/08/23 - 17h30" />
|
||||
<MESSAGE value="19/08/23 - 15h30" />
|
||||
<MESSAGE value="19/08/23 - 20h30" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="19/08/23 - 20h30" />
|
||||
<MESSAGE value="20/08/23 - 23h30" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="20/08/23 - 23h30" />
|
||||
</component>
|
||||
</project>
|
|
@ -461,6 +461,8 @@ Pour les session, on definit les étapes suivantes :
|
|||
SESSION_ETAPE = ['-1', '0', '1', '2', '3', '4', '5']
|
||||
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Les profils des ressources humaines autorisé
|
||||
"""
|
||||
RESSOURCE_PROFIL = ['enseignant', 'cadre', 'employe', 'autre']
|
||||
|
||||
|
|
|
@ -51,6 +51,7 @@ def AddStagiairetoClass(diction):
|
|||
'class_internal_url', 'session_id', 'employeur', 'status', 'price',
|
||||
'inscription_validation_date', 'token', 'client_rattachement_id',
|
||||
'adresse', 'code_postal', 'ville', 'pays', ]
|
||||
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
if val not in field_list:
|
||||
|
@ -162,7 +163,7 @@ def AddStagiairetoClass(diction):
|
|||
if ("email" in diction.keys()):
|
||||
if diction['email']:
|
||||
mydata['email'] = str(diction['email']).strip()
|
||||
regex = r'\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b'
|
||||
regex = r'\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,7}\b'
|
||||
if (not re.fullmatch(regex, str(diction['email']) ) ):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " l'adresse email "+str(diction['email'])+" est invalide")
|
||||
|
@ -732,7 +733,7 @@ def GetAllClassStagiaire(diction):
|
|||
RetObject = []
|
||||
val_tmp = 0
|
||||
|
||||
print(" #### myquery 01= "+str(myquery))
|
||||
print(" #### myquery 01111 = "+str(myquery))
|
||||
|
||||
|
||||
for retval in coll_session.find(myquery):
|
||||
|
@ -1624,6 +1625,13 @@ def AddStagiairetoClass_mass(file=None, Folder=None, diction=None):
|
|||
mydata['employeur'] = str(df['employeur'].values[n])
|
||||
mydata['telephone'] = str(df['telephone'].values[n])
|
||||
mydata['email'] = str(df['email'].values[n])
|
||||
regex = r'\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,7}\b'
|
||||
if (not re.fullmatch(regex, str(df['email'].values[n]))):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " l'adresse email " + str(df['email'].values[n]) + " est invalide")
|
||||
return False, " l'adresse email -" + str(df['email'].values[n]) + "- est invalide"
|
||||
|
||||
|
||||
mydata['session_id'] = str(session_data['_id'])
|
||||
mydata['token'] = str(my_token)
|
||||
|
||||
|
@ -1752,6 +1760,12 @@ Cette fonction permet d'importer un fichier excel pour les stagiaire de plusieur
|
|||
/!\ : Controle session : on va utiliser les colonne : formation code externe et le code de la session
|
||||
/!\ : controle du client : on va utiliser le mail et le nom du client pour voir si ca concorde.
|
||||
|
||||
update du 21/08/23 :
|
||||
Pour eviter les imports partiels du fichier, on va créer une fonction qui va faire les controles.
|
||||
Si cette fonction est ok, alors on lance la fonction d'import.
|
||||
|
||||
Elle fera a peu pret les meme controle qui existe dans la fonction d'import actuelle.
|
||||
|
||||
"""
|
||||
def AddStagiairetoClass_mass_for_many_session(file=None, Folder=None, diction=None):
|
||||
try:
|
||||
|
@ -1797,6 +1811,9 @@ def AddStagiairetoClass_mass_for_many_session(file=None, Folder=None, diction=No
|
|||
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"
|
||||
|
||||
|
||||
|
||||
|
||||
status, saved_file = mycommon.Upload_Save_CSV_File(file, Folder)
|
||||
if (status == False):
|
||||
mycommon.myprint("Impossible de recuperer correctement le fichier à importer")
|
||||
|
@ -1806,6 +1823,18 @@ def AddStagiairetoClass_mass_for_many_session(file=None, Folder=None, diction=No
|
|||
#print(" Lecture du fichier : "+saved_file)
|
||||
nb_line = 0
|
||||
|
||||
""""
|
||||
update du 21/08/23 : Controle de l'integrité du fichier
|
||||
"""
|
||||
local_controle_status, local_controle_message = Controle_AddStagiairetoClass_mass_for_many_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')
|
||||
|
||||
# Dictionnaire des champs utilisables
|
||||
|
@ -1863,6 +1892,11 @@ def AddStagiairetoClass_mass_for_many_session(file=None, Folder=None, diction=No
|
|||
mydata['employeur'] = str(df['employeur'].values[n])
|
||||
mydata['telephone'] = str(df['telephone'].values[n])
|
||||
mydata['email'] = str(df['email'].values[n])
|
||||
regex = r'\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,7}\b'
|
||||
if (not re.fullmatch(regex, str(df['email'].values[n]))):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " l'adresse email " + str(df['email'].values[n]) + " est invalide")
|
||||
return False, " l'adresse email -" + str(df['email'].values[n]) + "- est invalide"
|
||||
|
||||
mydata['token'] = str(my_token)
|
||||
|
||||
|
@ -1871,7 +1905,7 @@ def AddStagiairetoClass_mass_for_many_session(file=None, Folder=None, diction=No
|
|||
- formation code externe
|
||||
- partner_owner_recid
|
||||
"""
|
||||
qry = {'external_code':str(class_external_code), 'valide':'-51', 'locked':'0', 'partner_owner_recid':str(partner_recid)}
|
||||
qry = {'external_code':str(class_external_code), 'valide':'1', 'locked':'0', 'partner_owner_recid':str(partner_recid)}
|
||||
print(" ### qry = ", qry)
|
||||
myclass_data_count = MYSY_GV.dbname['myclass'].count_documents({'external_code':str(class_external_code), 'valide':'1', 'locked':'0',
|
||||
'partner_owner_recid':str(partner_recid)})
|
||||
|
@ -2068,6 +2102,286 @@ def AddStagiairetoClass_mass_for_many_session(file=None, Folder=None, diction=No
|
|||
|
||||
|
||||
|
||||
"""
|
||||
Fonction de controle du fichier
|
||||
"""
|
||||
def Controle_AddStagiairetoClass_mass_for_many_session(saved_file=None, Folder=None, diction=None):
|
||||
try:
|
||||
|
||||
'''
|
||||
# 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',]
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
if val not in field_list:
|
||||
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 liste ")
|
||||
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')
|
||||
|
||||
# Dictionnaire des champs utilisables
|
||||
'''
|
||||
# Verification que les noms des colonne sont bien corrects"
|
||||
'''
|
||||
field_list = ['formation_code_externe', 'code_session', 'prenom', 'nom', 'employeur',
|
||||
'telephone', 'email', 'modefinancement', 'opco', 'status', 'prix', 'adresse', 'code_postal',
|
||||
'ville', 'pays', 'client_rattachement_email', 'client_rattachement_nom']
|
||||
|
||||
|
||||
# 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)
|
||||
for val in df.columns:
|
||||
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. '" + val + "' n'est pas acceptée"
|
||||
|
||||
# Verification des champs obligatoires dans le fichier
|
||||
field_list_obligatoire_file = ['prenom', 'nom', 'email', 'modefinancement', 'status', 'prix']
|
||||
|
||||
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)
|
||||
"""
|
||||
|
||||
x = range(0, total_rows)
|
||||
for n in x:
|
||||
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])
|
||||
mydata['employeur'] = str(df['employeur'].values[n])
|
||||
mydata['telephone'] = str(df['telephone'].values[n])
|
||||
mydata['email'] = str(df['email'].values[n])
|
||||
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]) + " l'adresse email " + str(mydata['email']) + " est invalide")
|
||||
return False, " l'adresse email -" + str(mydata['email']) + "- est invalide"
|
||||
|
||||
mydata['token'] = str(my_token)
|
||||
|
||||
"""
|
||||
Recuperation de l'internal url de la formation a partir de la cle
|
||||
- formation code externe
|
||||
- partner_owner_recid
|
||||
"""
|
||||
qry = {'external_code':str(class_external_code), 'valide':'1', 'locked':'0', 'partner_owner_recid':str(partner_recid)}
|
||||
print(" ### qry = ", qry)
|
||||
myclass_data_count = MYSY_GV.dbname['myclass'].count_documents({'external_code':str(class_external_code), 'valide':'1', 'locked':'0',
|
||||
'partner_owner_recid':str(partner_recid)})
|
||||
|
||||
if( myclass_data_count != 1 ):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + "Ligne : " + str(
|
||||
n + 2) + ": Le code externe de la formation et le code de la session ne correspondent pas .")
|
||||
return False, "Ligne : " + str(
|
||||
n + 2) + ": Le code externe de la formation et le code de la session ne correspondent pas."
|
||||
|
||||
|
||||
myclass_data = MYSY_GV.dbname['myclass'].find_one({'external_code':str(class_external_code), 'valide':'1', 'locked':'0',
|
||||
'partner_owner_recid':str(partner_recid)})
|
||||
|
||||
mysession_count_qry = {'class_internal_url': str(myclass_data['internal_url']), 'valide': '1',
|
||||
'partner_owner_recid': str(partner_recid), 'code_session':str(df['code_session'].values[n]) }
|
||||
|
||||
print(" ### mysession_count_qry = ", qry)
|
||||
|
||||
mysession_count = MYSY_GV.dbname['session_formation'].count_documents(mysession_count_qry)
|
||||
|
||||
if( mysession_count != 1):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + "Ligne : " + str(
|
||||
n + 2) + ": Le code externe de la formation et le code de la session ne correspondent pas (2).")
|
||||
return False, "Ligne : " + str(
|
||||
n + 2) + ": Le code externe de la formation et le code de la session ne correspondent pas (2)."
|
||||
|
||||
mysession_data = MYSY_GV.dbname['session_formation'].find_one(mysession_count_qry)
|
||||
|
||||
|
||||
|
||||
mydata['session_id'] = str(mysession_data['_id'])
|
||||
mydata['class_internal_url'] = str(mysession_data['class_internal_url'])
|
||||
|
||||
"""
|
||||
Recuperation de l''_id' de la session à partir de la clé
|
||||
- formation code externe
|
||||
- code_session
|
||||
- partner_owner_recid
|
||||
"""
|
||||
|
||||
"""
|
||||
On verifie que le code de le session et le l'external class code correspondent.
|
||||
En gros : que la formation en question a bien une session du meme code
|
||||
"""
|
||||
|
||||
|
||||
|
||||
|
||||
modefinancement = ""
|
||||
if ("modefinancement" in df.keys()):
|
||||
if (str(df['modefinancement'].values[n])):
|
||||
modefinancement = str(df['modefinancement'].values[n])
|
||||
mydata['modefinancement'] = modefinancement
|
||||
|
||||
|
||||
opco = ""
|
||||
if ("opco" in df.keys()):
|
||||
if (str(df['opco'].values[n])):
|
||||
opco = str(df['opco'].values[n])
|
||||
mydata['opco'] = opco
|
||||
|
||||
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
|
||||
|
||||
|
||||
""""
|
||||
Gestion du client de rattachement/
|
||||
Avec l'email et le nom, on va aller recuperer 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])
|
||||
|
||||
|
||||
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])
|
||||
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_recid' :str(partner_recid)}
|
||||
|
||||
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'] = local_client_retval_data['_id']
|
||||
|
||||
|
||||
mydata['status'] = str(df['status'].values[n]).strip()
|
||||
if( str(mydata['status']) != "0" and str(mydata['status']) != "1" and str(mydata['status']) != "2"):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " Le champs 'status' de ligne " + str(n) + " est incorrecte. Valeurs acceptées : 0,1,2")
|
||||
return False, " Le champs status de la ligne " + str(n) + " est incorrecte. Valeurs acceptées : 0,1,2"
|
||||
|
||||
|
||||
if( str(df['status'].values[n]).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 champs 'prix' de ligne " + str( n) + " est incorrecte.")
|
||||
return False, " Le champs prix de ligne " + str(n) + " est incorrecte. "
|
||||
|
||||
mydata['price'] = local_price
|
||||
|
||||
|
||||
clean_dict = {k: mydata[k] for k in mydata if ( str(mydata[k]) != "nan") }
|
||||
|
||||
print( "#### clean_dict ", clean_dict)
|
||||
|
||||
|
||||
return True, str(total_rows)+" participants 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 participants a importer en masse "
|
||||
|
||||
|
||||
|
||||
|
@ -3604,7 +3918,7 @@ def Update_Stagiaire_Image(file_img=None, Folder=None, diction=None):
|
|||
local_retval = MYSY_GV.dbname['inscription'].find_one({'class_internal_url':str(class_internal_url),
|
||||
'session_id':str(session_id), 'email':str(email) })
|
||||
if( local_retval is None):
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " : Le stagiaire "+str(email)+" n'est pas reconnu pour la session "+str(str(session_id)) )
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " : Le stagiaire "+str(email)+" n'est pas reconnu pour la session bb"+str(str(session_id)) )
|
||||
return False, " Le stagiaire n'est pas reconnu "
|
||||
|
||||
|
||||
|
@ -3685,7 +3999,7 @@ def getRecodedStagiaireImage_from_front(diction=None):
|
|||
'email': str(email)})
|
||||
if (local_retval is None):
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " : Le stagiaire " + str(
|
||||
email) + " n'est pas reconnu pour la session " + str(str(session_id)))
|
||||
email) + " n'est pas reconnu pour la session aa" + str(str(session_id)))
|
||||
return False, " Le stagiaire n'est pas reconnu "
|
||||
|
||||
|
||||
|
@ -3792,7 +4106,7 @@ On y ajoute la formation concernée
|
|||
"""
|
||||
def Get_Statgaire_List_Partner_with_filter(diction):
|
||||
try:
|
||||
field_list = ['token', 'class_internal_url', 'session_id', 'status', 'email', 'nom', 'class_title']
|
||||
field_list = ['token', 'class_internal_url', 'code_session', 'status', 'email', 'nom', 'class_title', 'code_session']
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
if val not in field_list:
|
||||
|
@ -3830,6 +4144,35 @@ def Get_Statgaire_List_Partner_with_filter(diction):
|
|||
|
||||
|
||||
|
||||
"""
|
||||
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_id = {}
|
||||
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_id = {'session_id': {'$in': list_session_id, }}
|
||||
|
||||
filt_class_title = {}
|
||||
if ("class_title" in diction.keys()):
|
||||
filt_class_title = {'title': {'$regex': str(diction['class_title']), "$options": "i"}}
|
||||
|
@ -3839,10 +4182,6 @@ def Get_Statgaire_List_Partner_with_filter(diction):
|
|||
filt_class_internal_url = {
|
||||
'class_internal_url': {'$regex': str(diction['class_internal_url']), "$options": "i"}}
|
||||
|
||||
filt_session_id= {}
|
||||
if ("session_id" in diction.keys()):
|
||||
filt_session_id = {'session_id': {'$regex': str(diction['session_id']), "$options": "i"}}
|
||||
|
||||
filt_email = {}
|
||||
if ("email" in diction.keys()):
|
||||
filt_email = {'email': {'$regex': str(diction['email']), "$options": "i"}}
|
||||
|
@ -3883,6 +4222,7 @@ def Get_Statgaire_List_Partner_with_filter(diction):
|
|||
|
||||
val['email'] = retVal['email']
|
||||
|
||||
|
||||
if( "modefinancement" in retVal.keys()):
|
||||
val['modefinancement'] = retVal['modefinancement']
|
||||
else:
|
||||
|
@ -3894,7 +4234,6 @@ def Get_Statgaire_List_Partner_with_filter(diction):
|
|||
val['opco'] = ""
|
||||
|
||||
|
||||
|
||||
if ("employeur" in retVal.keys()):
|
||||
val['employeur'] = retVal['employeur']
|
||||
else:
|
||||
|
@ -3917,6 +4256,7 @@ def Get_Statgaire_List_Partner_with_filter(diction):
|
|||
|
||||
count_session = MYSY_GV.dbname['session_formation'].count_documents(local_qry)
|
||||
|
||||
|
||||
client_rattachement_id = ""
|
||||
client_rattachement_nom = ""
|
||||
# Si il a un client rattacher, recuperation des information du client
|
||||
|
@ -3947,6 +4287,11 @@ def Get_Statgaire_List_Partner_with_filter(diction):
|
|||
#print(" ### qry 2 =", qry2)
|
||||
session_retval = MYSY_GV.dbname['session_formation'].find_one({'_id':ObjectId(str(retVal['session_id'])), 'valide':'1'})
|
||||
|
||||
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]
|
||||
|
|
2801
Log/log_file.log
2801
Log/log_file.log
File diff suppressed because one or more lines are too long
|
@ -383,7 +383,7 @@ si le result > 1 une session, alors erreur d'inchorence d'info.
|
|||
def GetSessionFormation(diction):
|
||||
try:
|
||||
|
||||
field_list = ['token', 'class_internal_url', 'code_session', ]
|
||||
field_list = ['token', 'class_internal_url', 'session_id', ]
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
if val not in field_list:
|
||||
|
@ -394,7 +394,7 @@ def GetSessionFormation(diction):
|
|||
"""
|
||||
Verification de la liste des champs obligatoires
|
||||
"""
|
||||
field_list_obligatoire = ['token', 'class_internal_url', 'code_session', ]
|
||||
field_list_obligatoire = ['token', 'class_internal_url', 'session_id', ]
|
||||
for val in field_list_obligatoire:
|
||||
if val not in diction:
|
||||
mycommon.myprint(
|
||||
|
@ -423,14 +423,17 @@ def GetSessionFormation(diction):
|
|||
if diction['class_internal_url']:
|
||||
class_internal_url = diction['class_internal_url']
|
||||
|
||||
code_session = ""
|
||||
if ("code_session" in diction.keys()):
|
||||
if diction['code_session']:
|
||||
code_session = diction['code_session']
|
||||
session_id = ""
|
||||
if ("session_id" in diction.keys()):
|
||||
if diction['session_id']:
|
||||
session_id = diction['session_id']
|
||||
|
||||
if(str(session_id).strip() == ""):
|
||||
return True, []
|
||||
|
||||
coll_session = MYSY_GV.dbname['session_formation']
|
||||
|
||||
myquery = [{'$match':{'code_session':code_session, 'class_internal_url':class_internal_url, 'partner_owner_recid':str(partner_recid)}},
|
||||
myquery = [{'$match':{'_id':ObjectId(str(session_id)), 'class_internal_url':class_internal_url, 'partner_owner_recid':str(partner_recid)}},
|
||||
{'$lookup':
|
||||
{
|
||||
'from': 'myclass',
|
||||
|
@ -456,7 +459,7 @@ def GetSessionFormation(diction):
|
|||
# Si le nombre de session trouvé est > 1 alors incohérence, retourner une message d'erreur
|
||||
if( nb_val > 1 ):
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - la query "+str(myquery)+" retourne "+str(nb_val)+" session. ceci n'est pas normal. il ne doit pas y avoir plus 1 session")
|
||||
return False, " Les informations de la session "+str(code_session)+" sont incohérentes. Merci de contacter le support"
|
||||
return False, " Les informations de la session "+str(session_id)+" sont incohérentes. Merci de contacter le support"
|
||||
|
||||
return True, RetObject
|
||||
|
||||
|
@ -590,7 +593,7 @@ def GetAllValideSessionFormation_List(diction):
|
|||
myquery['partner_owner_recid'] = str(my_partner['recid'])
|
||||
myquery['valide'] = "1"
|
||||
|
||||
#print(" ##### myquery = "+str(myquery))
|
||||
print(" ##### myquery tt = "+str(myquery))
|
||||
RetObject = []
|
||||
|
||||
for retval in coll_session.find(myquery):
|
||||
|
|
|
@ -2877,8 +2877,7 @@ def GetAttendeeDetail_perSession(diction):
|
|||
|
||||
RetObject = []
|
||||
|
||||
qry_filter = {'session_id':str(diction['session_id']),'email':str(diction['attendee_email']),
|
||||
'class_internal_url':str(diction['internal_url']),}
|
||||
qry_filter = {'session_id':str(diction['session_id']),'email':str(diction['attendee_email']),}
|
||||
|
||||
""""
|
||||
Verification qu'il n'y a q'une seule inscription pour ce critère
|
||||
|
@ -3362,12 +3361,25 @@ def RemoveAllNonAlphaNumeric(sentence):
|
|||
"""
|
||||
Cette fonction nettoie un dictionnaire python :
|
||||
Pour chaque mot, il va supprimer les espaces en debut et en fin de mot.
|
||||
supprime les mots "nan" et "undefined"
|
||||
"""
|
||||
def strip_dictionary(d):
|
||||
"""
|
||||
Strip all leading and trailing whitespace in dictionary keys and values.
|
||||
"""
|
||||
return dict((k.strip(), v.strip()) for k, v in d.items())
|
||||
def strip_dictionary(orig_diction):
|
||||
try:
|
||||
|
||||
for key in orig_diction:
|
||||
if type(orig_diction[key]) == str:
|
||||
if( orig_diction[key].strip() == "nan" or orig_diction[key].strip() == "undefined"):
|
||||
orig_diction[key] = ""
|
||||
else :
|
||||
orig_diction[key] = orig_diction[key].strip()
|
||||
|
||||
return orig_diction
|
||||
|
||||
|
||||
except Exception as e:
|
||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||
myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
|
||||
return False
|
||||
|
||||
|
||||
"""
|
||||
|
|
|
@ -0,0 +1,272 @@
|
|||
"""
|
||||
Ce fichier permet de gerer de tout ce qui a atrait aux ressources humaines.
|
||||
c'est dire :
|
||||
- enseignent
|
||||
- cadre administratif
|
||||
- employés,
|
||||
etc
|
||||
|
||||
Une ressource humaine a toujours un profil (enseignant, cadre admin) et une fonction.
|
||||
"""
|
||||
|
||||
import pymongo
|
||||
from pymongo import MongoClient
|
||||
import json
|
||||
from bson import ObjectId
|
||||
import re
|
||||
from datetime import datetime
|
||||
import prj_common as mycommon
|
||||
import secrets
|
||||
import inspect
|
||||
import sys, os
|
||||
import csv
|
||||
import pandas as pd
|
||||
from pymongo import ReturnDocument
|
||||
import GlobalVariable as MYSY_GV
|
||||
from math import isnan
|
||||
import GlobalVariable as MYSY_GV
|
||||
import ela_index_bdd_classes as eibdd
|
||||
import email_mgt as email
|
||||
|
||||
|
||||
|
||||
def Add_Ressource_Humaine(diction):
|
||||
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', "raison_sociale", "nom", "siret", "tva", "email",
|
||||
"telephone", "website", "comment",'adr_adresse', 'adr_code_postal',
|
||||
'adr_ville', 'adr_pays', 'profil', 'telephone_mobile', 'linkedin',
|
||||
'facebook', 'twitter',
|
||||
'prenom', 'fonction', 'civilite']
|
||||
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
if val not in field_list:
|
||||
mycommon.myprint(str(
|
||||
inspect.stack()[0][3]) + " Le champ '" + val + "' n'existe pas")
|
||||
return False, " Les informations fournies sont incorrectes",
|
||||
|
||||
"""
|
||||
Verification des champs obligatoires
|
||||
"""
|
||||
field_list_obligatoire = ['token', "email", 'related_collection', 'related_collection_owner_email',]
|
||||
|
||||
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 liste ")
|
||||
return False, " Les informations fournies sont incorrectes",
|
||||
|
||||
"""
|
||||
Verification de l'identité et autorisation de l'entité qui
|
||||
appelle cette API
|
||||
"""
|
||||
token = ""
|
||||
if ("token" in diction.keys()):
|
||||
if diction['token']:
|
||||
token = diction['token']
|
||||
|
||||
# Verifier la validité du token
|
||||
retval = mycommon.check_partner_token_validity("", token)
|
||||
|
||||
if retval is False:
|
||||
return "Err_Connexion", " La session de connexion n'est pas valide"
|
||||
|
||||
partner_recid = mycommon.get_parnter_recid_from_token(token)
|
||||
if (partner_recid is False):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " - partner_recid est KO. Les données de connexion sont incorrectes ")
|
||||
return False, " Vous n'etes pas autorisé à utiliser cette API "
|
||||
|
||||
# Recuperation des données du partenaire
|
||||
local_status, my_partner = mycommon.get_partner_data_from_recid(partner_recid)
|
||||
if (local_status is False):
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - impossible de recuperer les données du partenaire")
|
||||
return False, str(inspect.stack()[0][3]) + " - impossible de recuperer les données du partenaire. "
|
||||
|
||||
|
||||
"""
|
||||
Verification s'il n'existe pas un cient du partenaire qui porte la meme adresse email
|
||||
"""
|
||||
|
||||
|
||||
tmp_count = MYSY_GV.dbname['ressource_humaine'].count_documents({'email': str(diction['email']),
|
||||
'valide': '1', 'partner_recid': my_partner['recid']})
|
||||
if (tmp_count > 0):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " - Il existe déjà un contact qui porte le même email principal = " +str(diction['email']))
|
||||
|
||||
return False, " - Vous avez déjà un contact qui a le même email principal "
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Recuperation des données fournies en entrée
|
||||
"""
|
||||
data = {}
|
||||
data['partner_recid'] = my_partner['recid']
|
||||
|
||||
raison_sociale = ""
|
||||
if ("raison_sociale" in diction.keys()):
|
||||
if diction['raison_sociale']:
|
||||
raison_sociale = diction['raison_sociale']
|
||||
data['raison_sociale'] = diction['raison_sociale']
|
||||
|
||||
nom = ""
|
||||
if ("nom" in diction.keys()):
|
||||
if diction['nom']:
|
||||
nom = diction['nom']
|
||||
data['nom'] = diction['nom']
|
||||
|
||||
siret = ""
|
||||
if ("siret" in diction.keys()):
|
||||
if diction['siret']:
|
||||
siret = diction['siret']
|
||||
data['siret'] = diction['siret']
|
||||
|
||||
prenom = ""
|
||||
if ("prenom" in diction.keys()):
|
||||
if diction['prenom']:
|
||||
prenom = diction['prenom']
|
||||
data['prenom'] = diction['prenom']
|
||||
|
||||
fonction = ""
|
||||
if ("fonction" in diction.keys()):
|
||||
if diction['fonction']:
|
||||
fonction = diction['fonction']
|
||||
data['fonction'] = diction['fonction']
|
||||
|
||||
civilite = ""
|
||||
if ("civilite" in diction.keys()):
|
||||
if diction['civilite']:
|
||||
civilite = diction['civilite']
|
||||
data['civilite'] = diction['civilite']
|
||||
|
||||
|
||||
|
||||
adr_adresse = ""
|
||||
if ("adr_adresse" in diction.keys()):
|
||||
if diction['adr_adresse']:
|
||||
adr_adresse = diction['adr_adresse']
|
||||
data['adr_adresse'] = diction['adr_adresse']
|
||||
|
||||
adr_code_postal = ""
|
||||
if ("adr_code_postal" in diction.keys()):
|
||||
if diction['adr_code_postal']:
|
||||
adr_code_postal = diction['adr_code_postal']
|
||||
data['adr_code_postal'] = diction['adr_code_postal']
|
||||
|
||||
adr_ville = ""
|
||||
if ("adr_ville" in diction.keys()):
|
||||
if diction['adr_ville']:
|
||||
adr_ville = diction['adr_ville']
|
||||
data['adr_ville'] = diction['adr_ville']
|
||||
|
||||
adr_pays = ""
|
||||
if ("adr_pays" in diction.keys()):
|
||||
if diction['adr_pays']:
|
||||
adr_pays = diction['siret']
|
||||
data['adr_pays'] = diction['adr_pays']
|
||||
|
||||
tva = ""
|
||||
if ("tva" in diction.keys()):
|
||||
if diction['tva']:
|
||||
tva = diction['tva']
|
||||
data['tva'] = diction['tva']
|
||||
|
||||
email = ""
|
||||
if ("email" in diction.keys()):
|
||||
if diction['email']:
|
||||
email = diction['email']
|
||||
data['email'] = diction['email']
|
||||
if( mycommon.isEmailValide(email) is False):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " - L'adresse email "+str(email)+" n'est pas valide")
|
||||
|
||||
return False, " - - L'adresse email "+str(email)+" n'est pas valide "
|
||||
|
||||
|
||||
telephone = ""
|
||||
if ("telephone" in diction.keys()):
|
||||
if diction['telephone']:
|
||||
telephone = diction['telephone']
|
||||
data['telephone'] = diction['telephone']
|
||||
|
||||
telephone_mobile = ""
|
||||
if ("telephone_mobile" in diction.keys()):
|
||||
if diction['telephone_mobile']:
|
||||
telephone_mobile = diction['telephone_mobile']
|
||||
data['telephone_mobile'] = diction['telephone_mobile']
|
||||
|
||||
|
||||
website = ""
|
||||
if ("website" in diction.keys()):
|
||||
if diction['website']:
|
||||
website = diction['website']
|
||||
data['website'] = diction['website']
|
||||
|
||||
comment = ""
|
||||
if ("comment" in diction.keys()):
|
||||
if diction['comment']:
|
||||
comment = diction['comment']
|
||||
data['comment'] = diction['comment']
|
||||
|
||||
linkedin = ""
|
||||
if ("linkedin" in diction.keys()):
|
||||
if diction['linkedin']:
|
||||
linkedin = diction['linkedin']
|
||||
data['linkedin'] = diction['linkedin']
|
||||
|
||||
facebook = ""
|
||||
if ("facebook" in diction.keys()):
|
||||
if diction['facebook']:
|
||||
facebook = diction['facebook']
|
||||
data['facebook'] = diction['facebook']
|
||||
|
||||
twitter = ""
|
||||
if ("twitter" in diction.keys()):
|
||||
if diction['twitter']:
|
||||
twitter = diction['twitter']
|
||||
data['twitter'] = diction['twitter']
|
||||
|
||||
|
||||
profil = ""
|
||||
if ("profil" in diction.keys()):
|
||||
if diction['profil']:
|
||||
profil = diction['profil']
|
||||
data['profil'] = diction['profil']
|
||||
if( type not in MYSY_GV.RESSOURCE_PROFIL):
|
||||
mycommon.myprint(
|
||||
"- Le type de contact "+str(type)+" n'est pas autorisé")
|
||||
return False, "- Le type de contact "+str(type)+" n'est pas autorisé"
|
||||
|
||||
|
||||
data['valide'] = '1'
|
||||
data['locked'] = '0'
|
||||
data['date_update'] = str(datetime.now())
|
||||
|
||||
# Creation du RecId
|
||||
data['recid'] = mycommon.create_user_recid()
|
||||
|
||||
|
||||
inserted_id = ""
|
||||
inserted_id = MYSY_GV.dbname['ressource_humaine'].insert_one(data).inserted_id
|
||||
if (not inserted_id):
|
||||
mycommon.myprint(
|
||||
" Impossible de créer le contact ")
|
||||
return False, " Impossible de créer la ressource "
|
||||
|
||||
|
||||
return True, " Le contact a été correctement créé"
|
||||
|
||||
except Exception as e:
|
||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - Line : " + str(exc_tb.tb_lineno))
|
||||
return False, " Impossible d'ajouter la ressource "
|
Loading…
Reference in New Issue