29/12/2023- 12h

master
cherif 2023-12-29 12:22:36 +01:00
parent 153c981df1
commit 25db380749
5 changed files with 4024 additions and 101 deletions

View File

@ -1,13 +1,11 @@
<?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="27/12/2023 - 23h">
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="28/12/2023- 19h">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" 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$/apprenant_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/apprenant_mgt.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/class_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/class_mgt.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/email_inscription_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/email_inscription_mgt.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/prj_common.py" beforeDir="false" afterPath="$PROJECT_DIR$/prj_common.py" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
@ -78,13 +76,6 @@
<option name="presentableId" value="Default" />
<updated>1680804787304</updated>
</task>
<task id="LOCAL-00133" summary="22/10/2023 - 12h">
<created>1697981083215</created>
<option name="number" value="00133" />
<option name="presentableId" value="LOCAL-00133" />
<option name="project" value="LOCAL" />
<updated>1697981083215</updated>
</task>
<task id="LOCAL-00134" summary="22/10/2023 - 18h00">
<created>1697992615131</created>
<option name="number" value="00134" />
@ -421,7 +412,14 @@
<option name="project" value="LOCAL" />
<updated>1703715749036</updated>
</task>
<option name="localTasksCounter" value="182" />
<task id="LOCAL-00182" summary="28/12/2023- 19h">
<created>1703784242480</created>
<option name="number" value="00182" />
<option name="presentableId" value="LOCAL-00182" />
<option name="project" value="LOCAL" />
<updated>1703784242481</updated>
</task>
<option name="localTasksCounter" value="183" />
<servers />
</component>
<component name="Vcs.Log.Tabs.Properties">
@ -436,7 +434,6 @@
</option>
</component>
<component name="VcsManagerConfiguration">
<MESSAGE value="23/11/23 - 13:30" />
<MESSAGE value="23/11/2023 - 21h30" />
<MESSAGE value="24/11/2023 - 18h30" />
<MESSAGE value="30/11/2023 - 21h" />
@ -461,6 +458,7 @@
<MESSAGE value="20/12/2023 - 18h" />
<MESSAGE value="27/12/2023 - 13h" />
<MESSAGE value="27/12/2023 - 23h" />
<option name="LAST_COMMIT_MESSAGE" value="27/12/2023 - 23h" />
<MESSAGE value="28/12/2023- 19h" />
<option name="LAST_COMMIT_MESSAGE" value="28/12/2023- 19h" />
</component>
</project>

View File

@ -428,6 +428,86 @@ def AddStagiairetoClass(diction):
str(inspect.stack()[0][3]) + " - ret_val.inserted_id is null ")
return False, "Impossible de créer le stagiaire"
"""
29/12/2023 : La creation s'est bien passée, si c'est une inscription definitive du premier cout,
c'est a dire que str(new_status) = 1 => Inscription (validée) alors fait la creation ou une mise à jour
du dossier apprenant en meme tps
"""
if (new_status == "1"):
local_apprenant_id = ""
is_apprenant_existe_count = MYSY_GV.dbname['apprenant'].count_documents(
{'email': str(diction['email']),
'partner_owner_recid': str(my_partner['recid']),
'valide': '1',
'locked': '0'})
if (is_apprenant_existe_count > 0):
# Il faut mettre à jour un dossier apprenant
is_apprenant_existe = MYSY_GV.dbname['apprenant'].find_one(
{'email': str(diction['email']),
'partner_owner_recid': str(my_partner['recid']),
'valide': '1',
'locked': '0'}, {'_id': 1})
new_apprenant_diction = diction
champ_to_delete = ['class_internal_url', 'session_id', 'inscription_validation_date', 'apprenant_id',
'status', 'modefinancement', 'type_apprenant']
for val in champ_to_delete:
if (val in new_apprenant_diction.keys()):
del new_apprenant_diction[str(val)]
new_apprenant_diction['_id'] = str(is_apprenant_existe['_id'])
local_apprenant_id = str(is_apprenant_existe['_id'])
local_status, local_retval = apprenant_mgt.Update_Apprenant(new_apprenant_diction)
if (local_status is False):
return local_status, local_retval
else:
new_apprenant_diction = diction
champ_to_delete = [ 'class_internal_url', 'session_id', 'inscription_validation_date', 'apprenant_id', 'status', 'modefinancement', 'type_apprenant']
for val in champ_to_delete:
if( val in new_apprenant_diction.keys()):
del new_apprenant_diction[str(val)]
local_status, local_retval = apprenant_mgt.Add_Apprenant(new_apprenant_diction)
if (local_status is False):
return local_status, local_retval
"""
recuperation de l'id du dossier qui vient d'etre créer
"""
apprenant_data = MYSY_GV.dbname['apprenant'].find_one({'email': str(diction['email']),
'valide': '1',
'locked': '0',
'partner_owner_recid': str(my_partner['recid'])},
{'_id': 1})
if (apprenant_data is None):
mycommon.myprint(str(
inspect.stack()[0][3]) + " Impossible de récuperer l'identifiant du dossier créé ")
return False, " Impossible de récuperer l'identifiant du dossier créé "
local_apprenant_id = str(apprenant_data['_id'])
"""
Apres la creation du dossier on met à jour l'inscription en rajoutant l'apprenant_id
"""
ret_val2 = MYSY_GV.dbname['inscription'].find_one_and_update(
{'_id': ObjectId(str(inserted_id)), 'email': str(diction['email']),
'partner_owner_recid': str(my_partner['recid'])},
{"$set": {'apprenant_id': str(local_apprenant_id), 'date_update': str(datetime.now()),
'update_by': str(my_partner['_id'])}},
return_document=ReturnDocument.AFTER,
upsert=False,
)
"""
# Ajout de l'evenement dans l'historique
"""
@ -435,7 +515,7 @@ def AddStagiairetoClass(diction):
#print(" ####### laaaa diction = ", diction)
history_event_dict = {}
history_event_dict['token'] = diction['token']
history_event_dict['token'] = mytoken
history_event_dict['related_collection'] = "inscription"
history_event_dict['related_collection_recid'] = str(inserted_id)
history_event_dict['action_date'] = str(now)
@ -1127,6 +1207,25 @@ def GetAllClassStagiaire(diction):
val_tmp = val_tmp + 1
user = retval
user['id'] = str(val_tmp)
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']
user['client_rattachement_id'] = client_rattachement_id
user['client_rattachement_nom'] = client_rattachement_nom
RetObject.append(mycommon.JSONEncoder().encode(user))
return True, RetObject
@ -6406,6 +6505,89 @@ def Get_List_Conventions_Stagiaire(diction):
return False, " Impossible de récupérer la liste des conventions"
"""
Recuperatin des convention SEULEMENT Individuelles
"""
def Get_List_Conventions_Stagiaire_Individuelles(diction):
try:
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, " La valeur '" + val + "' n'est pas presente dans liste"
my_token = ""
if ("token" in diction.keys()):
if diction['token']:
my_token = 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
RetObject = []
val_tmp = 0
"""
# Recuperation des documents (collection : courrier_template) de ce partenaire avec 'ref_interne' = 'CONVENTION_STAGIAIRE'
1 - On regarde le partenaire à des conventions qui sont personnalisées, si non
2 - On va sortir les conventions par defaut de MySy.
/!\ : On ne melange pas les 2. c'est l'un ou l'autre
"""
for retval in MYSY_GV.dbname['courrier_template'].find({"$or": [
{
'ref_interne': 'CONVENTION_STAGIAIRE',
'valide': '1',
'locked': '0',
'edit_by_client':'0',
'partner_owner_recid': str(my_partner['recid'])
},
{
'ref_interne': 'CONVENTION_STAGIAIRE',
'valide': '1',
'locked': '0',
'edit_by_client': {'$exists': False},
'partner_owner_recid': str(my_partner['recid'])
}
]}):
user = retval
val_tmp = val_tmp + 1
RetObject.append(mycommon.JSONEncoder().encode(user))
# Si aucune convention personnalisée, on va chercher les conventions mysy
if (val_tmp == 0):
for retval in MYSY_GV.dbname['courrier_template'].find({"$or": [
{'ref_interne': 'CONVENTION_STAGIAIRE',
'valide': '1',
'locked': '0',
'edit_by_client': '0',
'partner_owner_recid': 'default'},
{'ref_interne': 'CONVENTION_STAGIAIRE',
'valide': '1',
'locked': '0',
'edit_by_client': {'$exists': False},
'partner_owner_recid': 'default'
}]}):
user = retval
val_tmp = val_tmp + 1
RetObject.append(mycommon.JSONEncoder().encode(user))
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) + " - Line : " + str(exc_tb.tb_lineno))
return False, " Impossible de récupérer la liste des conventions"
"""
Cette fonction envoie une convention de stage par email
elle prend :

File diff suppressed because one or more lines are too long

46
main.py
View File

@ -2787,6 +2787,21 @@ def get_List_domaine_formation():
return jsonify(status=localStatus, message=message )
"""
API de recuperation de liste des liste_domaine_metier en JSON
"""
@app.route('/myclass/api/get_List_domaine_formation_JSON/', methods=['POST','GET'])
@crossdomain(origin='*')
def get_List_domaine_formation_JSON():
# On recupere le corps (payload) de la requete
payload = mycommon.strip_dictionary (request.form.to_dict())
print(" ### get_List_domaine_formation_JSON : payload = ",str(payload))
localStatus, message= mycommon.get_List_domaine_formation_JSON()
return jsonify(status=localStatus, message=message )
"""
Recuperation de la liste des domaines et metier
"""
@ -2812,6 +2827,21 @@ def get_List_metier_formation():
return jsonify(status=localStatus, message=message )
"""
Cette API retour la liste distinct des metiers en mode JSON
"""
@app.route('/myclass/api/get_List_metier_formation_JSON/', methods=['POST','GET'])
@crossdomain(origin='*')
def get_List_metier_formation_JSON():
# On recupere le corps (payload) de la requete
payload = mycommon.strip_dictionary (request.form.to_dict())
print(" ### get_List_metier_formation_JSON : payload = ",str(payload))
localStatus, message= mycommon.get_List_metier_formation_JSON()
return jsonify(status=localStatus, message=message )
"""
API de verification de la vlidation d'un email
"""
@ -4187,6 +4217,22 @@ def Get_List_Conventions_Stagiaire():
return jsonify(status=status, message=retval)
"""
API pour recuperer seulement les conventions INDIVIDUELLES
"""
@app.route('/myclass/api/Get_List_Conventions_Stagiaire_Individuelles/', methods=['POST','GET'])
@crossdomain(origin='*')
def Get_List_Conventions_Stagiaire_Individuelles():
# On recupere le corps (payload) de la requete
payload = mycommon.strip_dictionary (request.form.to_dict())
print(" ### Get_List_Conventions_Stagiaire_Individuelles payload = ",payload)
status, retval = inscription.Get_List_Conventions_Stagiaire_Individuelles(payload)
return jsonify(status=status, message=retval)
"""
API qui permet d'envoyer de le convention du stagiaire par email
"""

View File

@ -3491,6 +3491,30 @@ def GetAttendeeDetail_perSession(diction):
de formation
"""
def get_List_domaine_formation():
try:
coll_liste_domaine_metier = MYSY_GV.dbname['liste_domaine_metier']
myquery = {}
myquery['valide'] = "1"
RetObject = []
val_tmp = 1
for retval in coll_liste_domaine_metier.find(myquery).distinct('domaine'):
user = retval
RetObject.append(user)
return True, RetObject
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 de récupérer la liste de domaines de formation"
""" Cette fonction retourne la liste des domaines
de formation en mode JSON
"""
def get_List_domaine_formation_JSON():
try:
coll_liste_domaine_metier = MYSY_GV.dbname['liste_domaine_metier']
myquery = {}
@ -3513,10 +3537,34 @@ def get_List_domaine_formation():
print(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
return False, " Impossible de récupérer la liste de domaines de formation"
"""
Cette fonction retour la liste distinct des metiers
"""
def get_List_metier_formation():
try:
coll_liste_domaine_metier = MYSY_GV.dbname['liste_domaine_metier']
myquery = {}
myquery['valide'] = "1"
RetObject = []
val_tmp = 1
for retval in coll_liste_domaine_metier.find(myquery).distinct('metier'):
user = retval
RetObject.append(user)
return True, RetObject
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 de récupérer la liste des métiers de formation"
"""
Cette fonction retour la liste distinct des metiers en JSON
"""
def get_List_metier_formation_JSON():
try:
coll_liste_domaine_metier = MYSY_GV.dbname['liste_domaine_metier']
myquery = {}
@ -3541,45 +3589,6 @@ def get_List_metier_formation():
"""
Fonction de recuperation de liste des domaines & metiers
"""
def get_List_domaine_metier():
try:
## Recuperation de toutes les stagiaire rattaché à cette session
coll_opco = MYSY_GV.dbname['liste_domaine_metier']
myquery = {}
myquery['valide'] = "1"
myquery['locked'] = "0"
RetObject = []
val_tmp = 1
# print(" #### myquery = "+str(myquery))
for retval in coll_opco.find(myquery, {'valide':0, 'locked':0, '_id':0}).\
sort([("priorite",pymongo.ASCENDING), ]) :
user = retval
"""
user['id'] = str(val_tmp)
local_val = str(retval['metier'])
user['label'] = local_val
user['value'] = local_val
val_tmp = val_tmp + 1
"""
RetObject.append(JSONEncoder().encode(user))
return True, RetObject
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 de récupérer la liste des domaines et metiers"
"""
Cette fonction retourne un texte sans les tag html
"""
@ -4341,71 +4350,72 @@ def Get_Dictionnary_data_For_Template(diction):
Recuperartion des champs des apprenants
"""
list_apprenant_data = []
tab_apprenant_id = diction['list_apprenant_id']
apprenant_liste_champ = ['prenom', 'nom', 'email', 'civilite', 'telephone', 'employeur', 'adresse', 'code_postal', 'ville', 'pays', 'tuteur1_nom', 'tuteur1_prenom', 'tuteur1_email', 'tuteur1_telephone',
'tuteur2_nom', 'tuteur2_prenom', 'tuteur2_email', 'tuteur2_telephone', 'opco', 'tuteur1_adresse', 'tuteur1_cp', 'tuteur1_ville', 'tuteur1_pays', 'tuteur1_include_com', 'tuteur2_adresse',
'tuteur2_cp', 'tuteur2_ville', 'tuteur2_pays', 'tuteur2_include_com', 'client_rattachement_id', 'photo_profil']
if( "list_apprenant_id" in diction.keys()):
tab_apprenant_id = diction['list_apprenant_id']
apprenant_liste_champ = ['prenom', 'nom', 'email', 'civilite', 'telephone', 'employeur', 'adresse', 'code_postal', 'ville', 'pays', 'tuteur1_nom', 'tuteur1_prenom', 'tuteur1_email', 'tuteur1_telephone',
'tuteur2_nom', 'tuteur2_prenom', 'tuteur2_email', 'tuteur2_telephone', 'opco', 'tuteur1_adresse', 'tuteur1_cp', 'tuteur1_ville', 'tuteur1_pays', 'tuteur1_include_com', 'tuteur2_adresse',
'tuteur2_cp', 'tuteur2_ville', 'tuteur2_pays', 'tuteur2_include_com', 'client_rattachement_id', 'photo_profil']
for apprenant_data in MYSY_GV.dbname['apprenant'].find({'_id': {'$in': tab_apprenant_id, },
'valide': '1',
'locked':'0',
'partner_owner_recid': str(my_partner['recid'])
}):
# Récuperation de l'eventuelle photo de l'apprenant
apprenant_img = ""
qry_img = {'related_collection':'apprenant',
'related_collection_recid':str(apprenant_data['_id']),
'valide':'1',
'locked':'0'}
for apprenant_data in MYSY_GV.dbname['apprenant'].find({'_id': {'$in': tab_apprenant_id, },
'valide': '1',
'locked':'0',
'partner_owner_recid': str(my_partner['recid'])
}):
# Récuperation de l'eventuelle photo de l'apprenant
apprenant_img = ""
qry_img = {'related_collection':'apprenant',
'related_collection_recid':str(apprenant_data['_id']),
'valide':'1',
'locked':'0'}
print(" ### qry_img = ", qry_img)
apprenant_photo_data = MYSY_GV.dbname['mysy_images'].find_one({'related_collection':'apprenant',
'related_collection_recid':str(apprenant_data['_id']),
'valide':'1',
'locked':'0'}, {'img':1})
print(" ### qry_img = ", qry_img)
apprenant_photo_data = MYSY_GV.dbname['mysy_images'].find_one({'related_collection':'apprenant',
'related_collection_recid':str(apprenant_data['_id']),
'valide':'1',
'locked':'0'}, {'img':1})
if( apprenant_photo_data and "img" in apprenant_photo_data.keys() and apprenant_photo_data['img']):
apprenant_img = "data:image/png;base64,"+apprenant_photo_data['img'].decode()
if( apprenant_photo_data and "img" in apprenant_photo_data.keys() and apprenant_photo_data['img']):
apprenant_img = "data:image/png;base64,"+apprenant_photo_data['img'].decode()
apprenant_data['photo_profil'] = apprenant_img
apprenant_data['photo_profil'] = apprenant_img
new_apprenant_data = {}
for champ in apprenant_liste_champ:
if (champ in apprenant_data):
# Si on a faire au champ 'client_rattachement_id' avec une valeur, on va aller chercher le nom du clien
if( champ == "client_rattachement_id"):
client_rattachement_nom = "";
if( "client_rattachement_id" in apprenant_data.keys() and apprenant_data['client_rattachement_id'] ) :
client_rattachement_id_data = MYSY_GV.dbname['partner_client'].find_one({'_id':ObjectId(str(apprenant_data['client_rattachement_id'])),
'valide':'1',
'locked':'0',
'partner_recid':str(my_partner['recid'])},
{'nom':1})
new_apprenant_data = {}
for champ in apprenant_liste_champ:
if (champ in apprenant_data):
# Si on a faire au champ 'client_rattachement_id' avec une valeur, on va aller chercher le nom du clien
if( champ == "client_rattachement_id"):
client_rattachement_nom = "";
if( "client_rattachement_id" in apprenant_data.keys() and apprenant_data['client_rattachement_id'] ) :
client_rattachement_id_data = MYSY_GV.dbname['partner_client'].find_one({'_id':ObjectId(str(apprenant_data['client_rattachement_id'])),
'valide':'1',
'locked':'0',
'partner_recid':str(my_partner['recid'])},
{'nom':1})
if(client_rattachement_id_data and "nom" in client_rattachement_id_data.keys() ):
client_rattachement_nom = str(client_rattachement_id_data["nom"])
if(client_rattachement_id_data and "nom" in client_rattachement_id_data.keys() ):
client_rattachement_nom = str(client_rattachement_id_data["nom"])
new_champ_name = "apprenant_client_rattachement_nom"
new_field = {new_champ_name: str(client_rattachement_nom)}
new_apprenant_data.update(new_field)
new_champ_name = "apprenant_client_rattachement_nom"
new_field = {new_champ_name: str(client_rattachement_nom)}
new_apprenant_data.update(new_field)
else :
else :
new_champ_name = "apprenant_" + str(champ)
new_field = {new_champ_name: str(apprenant_data[champ])}
new_apprenant_data.update(new_field)
else:
new_champ_name = "apprenant_" + str(champ)
new_field = {new_champ_name: str(apprenant_data[champ])}
new_field = {new_champ_name: ""}
new_apprenant_data.update(new_field)
else:
new_champ_name = "apprenant_" + str(champ)
new_field = {new_champ_name: ""}
new_apprenant_data.update(new_field)
list_apprenant_data.append(new_apprenant_data)
list_apprenant_data.append(new_apprenant_data)
dictionnary_data['list_apprenant_data'] = list_apprenant_data