01/06/2024 - 14h30
parent
bef4c28807
commit
c91b5b5b16
|
@ -1,12 +1,12 @@
|
|||
<?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="sd">
|
||||
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="sss">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" 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$/groupe_inscrit_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/groupe_inscrit_mgt.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/site_formation.py" beforeDir="false" afterPath="$PROJECT_DIR$/site_formation.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" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
|
@ -76,13 +76,6 @@
|
|||
<option name="presentableId" value="Default" />
|
||||
<updated>1680804787304</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00270" summary="18/04/2024 - 21h50">
|
||||
<created>1713470069720</created>
|
||||
<option name="number" value="00270" />
|
||||
<option name="presentableId" value="LOCAL-00270" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1713470069721</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00271" summary="19/04/2024 - 22h22">
|
||||
<created>1713558162945</created>
|
||||
<option name="number" value="00271" />
|
||||
|
@ -419,7 +412,14 @@
|
|||
<option name="project" value="LOCAL" />
|
||||
<updated>1717150367241</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="319" />
|
||||
<task id="LOCAL-00319" summary="sss">
|
||||
<created>1717159892367</created>
|
||||
<option name="number" value="00319" />
|
||||
<option name="presentableId" value="LOCAL-00319" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1717159892368</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="320" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="Vcs.Log.Tabs.Properties">
|
||||
|
@ -461,7 +461,6 @@
|
|||
</option>
|
||||
</component>
|
||||
<component name="VcsManagerConfiguration">
|
||||
<MESSAGE value="0dfd" />
|
||||
<MESSAGE value="10/05/2024 - 18h30" />
|
||||
<MESSAGE value="gdf" />
|
||||
<MESSAGE value="dd" />
|
||||
|
@ -486,6 +485,7 @@
|
|||
<MESSAGE value="qsdsq" />
|
||||
<MESSAGE value="qsdsqqsdsq" />
|
||||
<MESSAGE value="sd" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="sd" />
|
||||
<MESSAGE value="sss" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="sss" />
|
||||
</component>
|
||||
</project>
|
3171
Log/log_file.log
3171
Log/log_file.log
File diff suppressed because it is too large
Load Diff
|
@ -11,6 +11,7 @@ Ce fichier permet de gérer ces regoupement
|
|||
"""
|
||||
import bson
|
||||
import pymongo
|
||||
import xlsxwriter
|
||||
from pymongo import MongoClient
|
||||
import json
|
||||
from bson import ObjectId
|
||||
|
@ -100,7 +101,7 @@ def Add_Groupe_Inscrit(diction):
|
|||
'partner_owner_recid':str(my_partner['recid'])})
|
||||
|
||||
|
||||
if( is_existe_class_metier != 1 ):
|
||||
if( is_existe_class_metier > 0 ):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " Un groupe avec le code '" + str(diction['code']) + "' existe déjà ")
|
||||
return False, " Un groupe avec le code '" + str(diction['code']) + "' existe déjà "
|
||||
|
@ -166,7 +167,7 @@ def Add_Groupe_Inscrit(diction):
|
|||
return False, " Impossible de créer le groupe (2) "
|
||||
|
||||
|
||||
return True, " La metier a été correctement ajouté "
|
||||
return True, " Le groupe a été correctement ajouté "
|
||||
|
||||
except Exception as e:
|
||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||
|
@ -227,21 +228,32 @@ def Update_Groupe_Inscrit(diction):
|
|||
'valide': '1',
|
||||
'partner_owner_recid': str(my_partner['recid'])})
|
||||
|
||||
if (is_existe_groupe != 0):
|
||||
if (is_existe_groupe != 1):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " L'identifiant du groupe est invalide ")
|
||||
return False, " L'identifiant du groupe est invalide "
|
||||
|
||||
|
||||
qry = {'code':str(diction['code']),
|
||||
'valide':'1',
|
||||
'partner_owner_recid':str(my_partner['recid']),
|
||||
'_id': {'$ne': ObjectId(str(diction['_id']))},
|
||||
|
||||
# Verifier que ce code n'existe pas déjà
|
||||
}
|
||||
|
||||
print(" ### qry = ", qry)
|
||||
|
||||
# Verifier que ce code n'existe pas déjà pour un autre groupe
|
||||
if( "code" in diction.keys() ):
|
||||
is_existe_class_metier = MYSY_GV.dbname['groupe_inscription'].count_documents({'code':str(diction['code']),
|
||||
'valide':'1',
|
||||
'partner_owner_recid':str(my_partner['recid'])})
|
||||
'partner_owner_recid':str(my_partner['recid']),
|
||||
'_id': {'$ne': ObjectId(str(diction['_id']))},
|
||||
|
||||
})
|
||||
|
||||
|
||||
if( is_existe_class_metier != 1 ):
|
||||
if( is_existe_class_metier > 0 ):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " Un groupe avec le code '" + str(diction['code']) + "' existe déjà ")
|
||||
return False, " Un groupe avec le code '" + str(diction['code']) + "' existe déjà "
|
||||
|
@ -397,8 +409,8 @@ def Delete_Groupe_Inscrit(diction):
|
|||
|
||||
if( is_groupe_has_members > 0 ):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " Ce groupe a "+str(is_groupe_has_members)+" membres ")
|
||||
return False, " Ce groupe a "+str(is_groupe_has_members)+" membres "
|
||||
str(inspect.stack()[0][3]) + " Impossible de supprimer de le groupe. Ce groupe a "+str(is_groupe_has_members)+" membres ")
|
||||
return False, " Impossible de supprimer de le groupe. Ce groupe a "+str(is_groupe_has_members)+" membres. "
|
||||
|
||||
|
||||
|
||||
|
@ -432,7 +444,7 @@ def Get_List_Groupe_Inscrit_With_Filter(diction):
|
|||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', 'code', 'nom', 'type_groupe_code', 'class_external_code',
|
||||
'code_session', ]
|
||||
'code_session', 'session_id']
|
||||
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
|
@ -474,6 +486,10 @@ def Get_List_Groupe_Inscrit_With_Filter(diction):
|
|||
filt_ref_interne = {
|
||||
'code': {'$regex': str(diction['code']), "$options": "i"}}
|
||||
|
||||
filt_session_id_on_main_collection = {}
|
||||
if ("session_id" in diction.keys()):
|
||||
filt_session_id_on_main_collection = { 'session_id': str(diction['session_id'])}
|
||||
|
||||
|
||||
filt_session_id = {}
|
||||
list_session_id = []
|
||||
|
@ -525,7 +541,9 @@ def Get_List_Groupe_Inscrit_With_Filter(diction):
|
|||
val_tmp = 0
|
||||
|
||||
find_qry = {'$and': [{'partner_owner_recid': str(my_partner['recid']), 'valide': '1', 'locked': '0'}, filt_class_id,
|
||||
filt_session_id, filt_code, filt_nom]}
|
||||
filt_session_id, filt_code, filt_nom, filt_session_id_on_main_collection]}
|
||||
|
||||
print("### Get_List_Groupe_Inscrit_With_Filter find_qry = ", find_qry)
|
||||
|
||||
for retval in MYSY_GV.dbname['groupe_inscription'].find(find_qry).sort([("_id", pymongo.DESCENDING), ]):
|
||||
user = retval
|
||||
|
@ -552,7 +570,7 @@ def Get_List_Groupe_Inscrit_With_Filter(diction):
|
|||
'valide': '1',})
|
||||
|
||||
if (my_session_formation_data and "code_session" in my_session_formation_data.keys()):
|
||||
user['session_code_session'] = my_class_data['code_session']
|
||||
user['session_code_session'] = my_session_formation_data['code_session']
|
||||
|
||||
|
||||
val_tmp = val_tmp + 1
|
||||
|
@ -719,7 +737,7 @@ def Get_Given_Groupe_Inscrit_With_Membres(diction):
|
|||
Cette fonction permet d'inscrire des 'inscrit_id' a un groupe
|
||||
"""
|
||||
|
||||
def Add_Update_Groupe_Inscrit(diction):
|
||||
def Add_Update_Groupe_Inscrit_Membres(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
|
@ -762,12 +780,19 @@ def Add_Update_Groupe_Inscrit(diction):
|
|||
new_data = diction
|
||||
|
||||
# Verifier que le groupe existe et est valide
|
||||
|
||||
qry = {'_id': ObjectId(str(diction['_id'])),
|
||||
'valide': '1',
|
||||
'partner_owner_recid': str(my_partner['recid'])}
|
||||
|
||||
|
||||
|
||||
is_existe_groupe = MYSY_GV.dbname['groupe_inscription'].count_documents(
|
||||
{'_id': ObjectId(str(diction['_id'])),
|
||||
'valide': '1',
|
||||
'partner_owner_recid': str(my_partner['recid'])})
|
||||
|
||||
if (is_existe_groupe != 0):
|
||||
if (is_existe_groupe != 1):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " L'identifiant du groupe est invalide ")
|
||||
return False, " L'identifiant du groupe est invalide "
|
||||
|
@ -795,7 +820,7 @@ def Add_Update_Groupe_Inscrit(diction):
|
|||
for my_inscription in tab_inscriptions_ids_splited:
|
||||
new_data = {}
|
||||
new_data['groupe_inscription_id'] = str(diction['_id'])
|
||||
new_data['inscription_id'] = str(my_inscription['_id'])
|
||||
new_data['inscription_id'] = str(my_inscription)
|
||||
|
||||
now = str(datetime.now())
|
||||
new_data['date_update'] = now
|
||||
|
@ -807,7 +832,7 @@ def Add_Update_Groupe_Inscrit(diction):
|
|||
data_cle = {}
|
||||
data_cle['partner_owner_recid'] = str(my_partner['recid'])
|
||||
data_cle['groupe_inscription_id'] = str(diction['_id'])
|
||||
data_cle['inscription_id'] = str(my_inscription['_id'])
|
||||
data_cle['inscription_id'] = str(my_inscription)
|
||||
data_cle['valide'] = "1"
|
||||
data_cle['locked'] = "0"
|
||||
|
||||
|
@ -838,9 +863,115 @@ def Add_Update_Groupe_Inscrit(diction):
|
|||
|
||||
|
||||
"""
|
||||
Cette fonction permet de supprimer des inscrits à un groupe
|
||||
Recuperer les membres d'un groupe
|
||||
"""
|
||||
def Get_Given_Groupe_Membres(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', '_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")
|
||||
return False, " Les informations fournies sont incorrectes",
|
||||
|
||||
"""
|
||||
Verification des champs obligatoires
|
||||
"""
|
||||
field_list_obligatoire = ['token', '_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 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']
|
||||
|
||||
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
|
||||
|
||||
for retval in MYSY_GV.dbname['groupe_inscription_membre'].find({'groupe_inscription_id':str(diction['_id']),
|
||||
'valide':'1',
|
||||
'locked':'0',
|
||||
'partner_owner_recid':str(my_partner['recid'])}):
|
||||
user = retval
|
||||
user['id'] = str(val_tmp)
|
||||
val_tmp = val_tmp + 1
|
||||
|
||||
local_new_dict = {}
|
||||
local_new_dict['token'] = diction['token']
|
||||
local_new_dict['inscrit_id'] = retval['inscription_id']
|
||||
|
||||
local_inscrit_data_status, local_inscrit_data_retval = mycommon.Get_Inscrit_And_Apprenant_Data(
|
||||
local_new_dict)
|
||||
if (local_inscrit_data_status is False):
|
||||
return local_inscrit_data_status, local_inscrit_data_retval
|
||||
|
||||
nom = ""
|
||||
prenom = ""
|
||||
email = ""
|
||||
|
||||
|
||||
|
||||
if ("inscrit_data" in local_inscrit_data_retval.keys()):
|
||||
user['inscrit_data'] = local_inscrit_data_retval['inscrit_data']
|
||||
|
||||
nom = local_inscrit_data_retval['inscrit_data']['nom']
|
||||
prenom = local_inscrit_data_retval['inscrit_data']['prenom']
|
||||
email = local_inscrit_data_retval['inscrit_data']['email']
|
||||
|
||||
|
||||
if ("apprenant_data" in local_inscrit_data_retval.keys()):
|
||||
user['apprenant_data'] = local_inscrit_data_retval['apprenant_data']
|
||||
|
||||
# Si on a un dossier apprenant, alors on écrase les variables ci-dessous
|
||||
nom = local_inscrit_data_retval['apprenant_data']['nom']
|
||||
prenom = local_inscrit_data_retval['apprenant_data']['prenom']
|
||||
email = local_inscrit_data_retval['apprenant_data']['email']
|
||||
|
||||
|
||||
user['nom'] = nom
|
||||
user['prenom'] = prenom
|
||||
user['email'] = email
|
||||
|
||||
|
||||
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 membres du groupe "
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Cette fonction permet de supprimer des inscrits à un groupe (membre d'un groupe)
|
||||
"""
|
||||
|
||||
def Delete_Groupe_Inscrit_Membres(diction):
|
||||
try:
|
||||
|
@ -849,7 +980,164 @@ def Delete_Groupe_Inscrit_Membres(diction):
|
|||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', '_id', 'tab_inscriptions_ids']
|
||||
field_list = ['token', 'groupe_inscription_id', 'tab_ids']
|
||||
|
||||
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é")
|
||||
return False, " Les informations fournies sont incorrectes"
|
||||
|
||||
"""
|
||||
Verification des champs obligatoires
|
||||
"""
|
||||
field_list_obligatoire = ['token', 'groupe_inscription_id', 'tab_ids' ]
|
||||
|
||||
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']
|
||||
|
||||
local_status, my_partner = mycommon.Check_Connexion_And_Return_Partner_Data(diction)
|
||||
if (local_status is not True):
|
||||
return local_status, my_partner
|
||||
|
||||
new_data = diction
|
||||
|
||||
# Verifier que le groupe existe et est valide
|
||||
is_existe_groupe = MYSY_GV.dbname['groupe_inscription'].count_documents(
|
||||
{'_id': ObjectId(str(diction['groupe_inscription_id'])),
|
||||
'valide': '1',
|
||||
'partner_owner_recid': str(my_partner['recid'])})
|
||||
|
||||
if (is_existe_groupe != 1):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " L'identifiant du groupe est invalide ")
|
||||
return False, " L'identifiant du groupe est invalide "
|
||||
|
||||
tab_inscriptions_ids = ""
|
||||
if ("tab_ids" in diction.keys()):
|
||||
if diction['tab_ids']:
|
||||
tab_inscriptions_ids = diction['tab_ids']
|
||||
|
||||
tab_inscriptions_ids_splited = str(tab_inscriptions_ids).split(",")
|
||||
|
||||
tab_inscriptions_ids_splited_ObjectID = []
|
||||
for tmp in tab_inscriptions_ids_splited :
|
||||
tab_inscriptions_ids_splited_ObjectID.append(ObjectId(str(tmp)))
|
||||
|
||||
qery_delete = {'_id': {'$in': tab_inscriptions_ids_splited_ObjectID},
|
||||
'groupe_inscription_id':str(diction['groupe_inscription_id']),
|
||||
'partner_owner_recid': str(my_partner['recid']),
|
||||
'locked': '0'}
|
||||
|
||||
#print(" ### qery_delete = ", qery_delete)
|
||||
|
||||
delete = MYSY_GV.dbname['groupe_inscription_membre'].delete_many(qery_delete )
|
||||
|
||||
return True, str(delete.deleted_count) + " Membre(s) désinscrit(s)"
|
||||
|
||||
|
||||
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ésinscrire les personnes au groupe "
|
||||
|
||||
|
||||
"""
|
||||
Recuperer les données d'un groupe donné
|
||||
"""
|
||||
def Get_Type_Groupe_Apprenant(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', ]
|
||||
|
||||
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")
|
||||
return False, " Les informations fournies sont incorrectes",
|
||||
|
||||
"""
|
||||
Verification 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 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']
|
||||
|
||||
local_status, my_partner = mycommon.Check_Connexion_And_Return_Partner_Data(diction)
|
||||
if (local_status is not True):
|
||||
return local_status, my_partner
|
||||
|
||||
"""
|
||||
Clés de mise à jour
|
||||
"""
|
||||
data_cle = {}
|
||||
|
||||
data_cle['valide'] = "1"
|
||||
data_cle['locked'] = "0"
|
||||
|
||||
|
||||
|
||||
RetObject = []
|
||||
val_tmp = 0
|
||||
|
||||
for retval in MYSY_GV.dbname['groupe_inscription_type'].find(data_cle):
|
||||
user = retval
|
||||
user['id'] = str(val_tmp)
|
||||
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 les types de groupe d'apprenants "
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Fonction qui permet d'exporter les membres d'un groupe dans un fichier excel
|
||||
"""
|
||||
|
||||
def Export_To_Excel_List_Groupe_Membres(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', '_id', ]
|
||||
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
|
@ -882,37 +1170,169 @@ def Delete_Groupe_Inscrit_Membres(diction):
|
|||
if (local_status is not True):
|
||||
return local_status, my_partner
|
||||
|
||||
new_data = diction
|
||||
"""
|
||||
Verifier que le group est valide
|
||||
"""
|
||||
is_groupe_valide = MYSY_GV.dbname['groupe_inscription'].count_documents(
|
||||
{"_id": ObjectId(str(diction['_id'])),
|
||||
'valide': '1',
|
||||
'locked': '0',
|
||||
'partner_owner_recid': str(my_partner['recid'])})
|
||||
|
||||
# Verifier que le groupe existe et est valide
|
||||
is_existe_groupe = MYSY_GV.dbname['groupe_inscription'].count_documents(
|
||||
{'_id': ObjectId(str(diction['_id'])),
|
||||
if (is_groupe_valide != 1):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " L'identifiant du groupe est invalide ")
|
||||
return False, " ant du groupe est invalide "
|
||||
|
||||
groupe_data = MYSY_GV.dbname['groupe_inscription'].find_one(
|
||||
{"_id": ObjectId(str(diction['_id'])),
|
||||
'valide': '1',
|
||||
'locked': '0',
|
||||
'partner_owner_recid': str(my_partner['recid'])})
|
||||
|
||||
RetObject = []
|
||||
val_tmp = 0
|
||||
|
||||
ts = datetime.now().timestamp()
|
||||
ts = str(ts).replace(".", "").replace(",", "")[-5:]
|
||||
|
||||
orig_file_name = "Export_Groupe_Membres_" + str(ts) + ".xlsx"
|
||||
outputFilename = str(MYSY_GV.TEMPORARY_DIRECTORY) + "/" + str(orig_file_name)
|
||||
|
||||
tab_exported_fields_header = ["formation", "classe", "Groupe_code","Groupe_Nom", "type_groupe_code", "nom_apprenant",
|
||||
"prenom_apprenant", "email_apprenant", ]
|
||||
|
||||
|
||||
# Create a workbook and add a worksheet.
|
||||
workbook = xlsxwriter.Workbook(outputFilename)
|
||||
worksheet = workbook.add_worksheet()
|
||||
|
||||
nb_val = 0
|
||||
row = 0
|
||||
column = 0
|
||||
|
||||
groupe_formation = ""
|
||||
groupe_code_session = ""
|
||||
|
||||
# Recuperer les données de la formation
|
||||
class_data = MYSY_GV.dbname['myclass'].find_one({'_id': ObjectId(str(groupe_data['class_id'])),
|
||||
'valide': '1', 'locked': '0',
|
||||
'partner_owner_recid': str(my_partner['recid'])})
|
||||
|
||||
if (class_data and "title" in class_data.keys()):
|
||||
groupe_formation = class_data['title']
|
||||
|
||||
|
||||
# Recuperation des données de la session
|
||||
session_data = MYSY_GV.dbname['session_formation'].find_one(
|
||||
{'_id': ObjectId(str(groupe_data['session_id'])),
|
||||
'valide': '1',
|
||||
'partner_owner_recid': str(my_partner['recid'])})
|
||||
|
||||
if (is_existe_groupe != 0):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " L'identifiant du groupe est invalide ")
|
||||
return False, " L'identifiant du groupe est invalide "
|
||||
if (session_data and "code_session" in session_data.keys()):
|
||||
groupe_code_session = session_data['code_session']
|
||||
|
||||
tab_inscriptions_ids = ""
|
||||
if ("tab_inscriptions_ids" in diction.keys()):
|
||||
if diction['tab_inscriptions_ids']:
|
||||
tab_inscriptions_ids = diction['tab_inscriptions_ids']
|
||||
"""
|
||||
Creation de l'entete du fichier excel
|
||||
"""
|
||||
|
||||
tab_inscriptions_ids_splited = str(tab_inscriptions_ids).split(",")
|
||||
for header_item in tab_exported_fields_header:
|
||||
worksheet.write(row, column, header_item)
|
||||
column += 1
|
||||
|
||||
qery_delete = {'inscription_id': {'$in': tab_inscriptions_ids_splited},
|
||||
'groupe_inscription_id':str(diction['_id']),
|
||||
'partner_owner_recid': str(my_partner['recid']),
|
||||
'locked': '0'}
|
||||
"""
|
||||
Creation des data du fichier excel
|
||||
"""
|
||||
for retval in MYSY_GV.dbname['groupe_inscription_membre'].find(
|
||||
{'groupe_inscription_id': str(diction['_id']),
|
||||
'valide': '1',
|
||||
'locked': '0',
|
||||
'partner_owner_recid': str(my_partner['recid']),
|
||||
}):
|
||||
|
||||
delete = MYSY_GV.dbname['groupe_inscription_membre'].delete_many(qery_delete )
|
||||
|
||||
return True, str(delete.deleted_count) + " Membre(s) désinscrit(s)"
|
||||
user = retval
|
||||
nom_apprenant = ""
|
||||
prenom_apprenant = ""
|
||||
email_apprenant = ""
|
||||
groupe = ""
|
||||
|
||||
|
||||
if ("inscription_id" in retval and retval['inscription_id']):
|
||||
# Recuprer les données de l'inscrit
|
||||
inscription_data = MYSY_GV.dbname['inscription'].find_one(
|
||||
{'_id': ObjectId(str(retval['inscription_id']))},
|
||||
{'_id': 1, 'apprenant_id': 1})
|
||||
|
||||
apprenant_data = MYSY_GV.dbname['apprenant'].find_one(
|
||||
{'_id': ObjectId(str(inscription_data['apprenant_id']))},
|
||||
{'_id': 1, 'nom': 1, 'prenom': 1, 'email': 1})
|
||||
|
||||
nom_apprenant = apprenant_data['nom']
|
||||
prenom_apprenant = apprenant_data['prenom']
|
||||
email_apprenant = apprenant_data['email']
|
||||
|
||||
|
||||
|
||||
|
||||
user['nom'] = nom_apprenant
|
||||
user['prenom'] = prenom_apprenant
|
||||
user['email'] = email_apprenant
|
||||
user['id'] = str(nb_val)
|
||||
if ("note" not in retval.keys()):
|
||||
user['note'] = "-1"
|
||||
|
||||
nb_val = nb_val + 1
|
||||
|
||||
column = 0
|
||||
row = row + 1
|
||||
|
||||
# Champ : formation
|
||||
worksheet.write(row, column, groupe_formation)
|
||||
column += 1
|
||||
|
||||
# Champ : classe / code session
|
||||
worksheet.write(row, column, groupe_code_session)
|
||||
column += 1
|
||||
|
||||
# Champ : groupe_code
|
||||
worksheet.write(row, column, str(groupe_data['code']))
|
||||
column += 1
|
||||
|
||||
# Champ : Groupe Nom
|
||||
worksheet.write(row, column, str(groupe_data['nom']))
|
||||
column += 1
|
||||
|
||||
# Champ : Groupe type_groupe_code
|
||||
worksheet.write(row, column, str(groupe_data['type_groupe_code']))
|
||||
column += 1
|
||||
|
||||
|
||||
# Champ : nom
|
||||
worksheet.write(row, column, user['nom'])
|
||||
column += 1
|
||||
|
||||
# Champ : prenom
|
||||
worksheet.write(row, column, user['prenom'])
|
||||
column += 1
|
||||
|
||||
# Champ : email
|
||||
worksheet.write(row, column, user['email'])
|
||||
column += 1
|
||||
|
||||
|
||||
|
||||
workbook.close()
|
||||
if os.path.exists(outputFilename):
|
||||
# print(" ### ok os.path.exists(outputFilename) "+str(outputFilename))
|
||||
return True, send_file(outputFilename, as_attachment=True)
|
||||
|
||||
|
||||
return False, "Impossible de générer l'export (2) "
|
||||
|
||||
|
||||
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ésinscrire les personnes au groupe "
|
||||
return False, " Impossible de générer l'export "
|
||||
|
||||
|
|
68
main.py
68
main.py
|
@ -9695,8 +9695,8 @@ def Add_Groupe_Inscrit():
|
|||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Add_Groupe_Inscrit payload = ",payload)
|
||||
status, retval, avability_check = groupe_inscrit_mgt.Add_Groupe_Inscrit(payload)
|
||||
return jsonify(status=status, message=retval, avability_check=avability_check)
|
||||
status, retval = groupe_inscrit_mgt.Add_Groupe_Inscrit(payload)
|
||||
return jsonify(status=status, message=retval )
|
||||
|
||||
|
||||
"""
|
||||
|
@ -9708,8 +9708,8 @@ def Update_Groupe_Inscrit():
|
|||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Update_Groupe_Inscrit payload = ",payload)
|
||||
status, retval, avability_check = groupe_inscrit_mgt.Update_Groupe_Inscrit(payload)
|
||||
return jsonify(status=status, message=retval, avability_check=avability_check)
|
||||
status, retval = groupe_inscrit_mgt.Update_Groupe_Inscrit(payload)
|
||||
return jsonify(status=status, message=retval )
|
||||
|
||||
|
||||
|
||||
|
@ -9722,8 +9722,8 @@ def Delete_Groupe_Inscrit():
|
|||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Delete_Groupe_Inscrit payload = ",payload)
|
||||
status, retval, avability_check = groupe_inscrit_mgt.Delete_Groupe_Inscrit(payload)
|
||||
return jsonify(status=status, message=retval, avability_check=avability_check)
|
||||
status, retval = groupe_inscrit_mgt.Delete_Groupe_Inscrit(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
"""
|
||||
|
@ -9773,13 +9773,27 @@ def Get_Given_Groupe_Inscrit_With_Membres():
|
|||
"""
|
||||
API pour permettre d'inscrire des 'inscrit_id' a un groupe
|
||||
"""
|
||||
@app.route('/myclass/api/Add_Update_Groupe_Inscrit/', methods=['POST','GET'])
|
||||
@app.route('/myclass/api/Add_Update_Groupe_Inscrit_Membres/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Add_Update_Groupe_Inscrit():
|
||||
def Add_Update_Groupe_Inscrit_Membres():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Add_Update_Groupe_Inscrit payload = ",payload)
|
||||
status, retval = groupe_inscrit_mgt.Add_Update_Groupe_Inscrit(payload)
|
||||
print(" ### Add_Update_Groupe_Inscrit_Membres payload = ",payload)
|
||||
status, retval = groupe_inscrit_mgt.Add_Update_Groupe_Inscrit_Membres(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
|
||||
"""
|
||||
API pour recuperer la liste des membre d'un groupe d'inscrits
|
||||
"""
|
||||
@app.route('/myclass/api/Get_Given_Groupe_Membres/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Get_Given_Groupe_Membres():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Get_Given_Groupe_Membres payload = ",payload)
|
||||
status, retval = groupe_inscrit_mgt.Get_Given_Groupe_Membres(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
|
@ -9799,6 +9813,40 @@ def Delete_Groupe_Inscrit_Membres():
|
|||
|
||||
|
||||
|
||||
"""
|
||||
API pour recuperer les types de groupe d'apprenants (groupe TD, Groupe TP, Groupe projet, etc)
|
||||
"""
|
||||
@app.route('/myclass/api/Get_Type_Groupe_Apprenant/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Get_Type_Groupe_Apprenant():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Get_Type_Groupe_Apprenant payload = ",payload)
|
||||
status, retval = groupe_inscrit_mgt.Get_Type_Groupe_Apprenant(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
|
||||
"""
|
||||
API pour exporter les membres d'un groupe d'inscrits
|
||||
"""
|
||||
@app.route('/myclass/api/Export_To_Excel_List_Groupe_Membres/<token>/<_id>/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Export_To_Excel_List_Groupe_Membres(token, _id):
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
payload = {}
|
||||
payload['token'] = str(token)
|
||||
payload['_id'] = str(_id)
|
||||
|
||||
print(" ### Export_To_Excel_List_Groupe_Membres payload = ",payload)
|
||||
|
||||
status, retval = groupe_inscrit_mgt.Export_To_Excel_List_Groupe_Membres(payload)
|
||||
if(status ):
|
||||
return retval
|
||||
else:
|
||||
return False
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -5866,13 +5866,16 @@ def Get_Inscrit_And_Apprenant_Data(diction):
|
|||
|
||||
|
||||
if( "apprenant_id" in New_retVal.keys() and New_retVal['apprenant_id']):
|
||||
apprenant_data = MYSY_GV.dbname['apprenant'].find_one({'_id': ObjectId(str(diction['apprenant_id'])),
|
||||
'partner_owner_recid': str(
|
||||
my_partner['recid']),
|
||||
'valide': '1',
|
||||
|
||||
|
||||
|
||||
|
||||
apprenant_data = MYSY_GV.dbname['apprenant'].find_one({'_id': ObjectId(str(New_retVal['apprenant_id'])),
|
||||
'partner_owner_recid': str(my_partner['recid']),
|
||||
'valide': '1',
|
||||
'locked': '0'})
|
||||
|
||||
if( apprenant_data and 'id' in apprenant_data.keys() ):
|
||||
if( apprenant_data and '_id' in apprenant_data.keys() ):
|
||||
RetObject['apprenant_data'] = apprenant_data
|
||||
else:
|
||||
RetObject['apprenant_data'] = {}
|
||||
|
|
Loading…
Reference in New Issue