02/08/2024 - 17h
parent
aa98cff87d
commit
1ab5634961
|
@ -1,11 +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="01/08/2024 - 17h30">
|
||||
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="02/08/2024 - 12h">
|
||||
<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$/Session_Formation.py" beforeDir="false" afterPath="$PROJECT_DIR$/Session_Formation.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/unite_enseignement_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/unite_enseignement_mgt.py" 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" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
|
@ -460,7 +460,6 @@
|
|||
</option>
|
||||
</component>
|
||||
<component name="VcsManagerConfiguration">
|
||||
<MESSAGE value="21/06/24 - 22h30" />
|
||||
<MESSAGE value="22/06/24 - 17h30" />
|
||||
<MESSAGE value="qsds" />
|
||||
<MESSAGE value="26/06/2024 - 19h30" />
|
||||
|
@ -485,6 +484,7 @@
|
|||
<MESSAGE value="30/07/2024 - 12h" />
|
||||
<MESSAGE value="31/07/2024 - 17h30" />
|
||||
<MESSAGE value="01/08/2024 - 17h30" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="01/08/2024 - 17h30" />
|
||||
<MESSAGE value="02/08/2024 - 12h" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="02/08/2024 - 12h" />
|
||||
</component>
|
||||
</project>
|
1140
Log/log_file.log
1140
Log/log_file.log
File diff suppressed because it is too large
Load Diff
|
@ -40,6 +40,7 @@ from email.mime.multipart import MIMEMultipart
|
|||
from email.mime.text import MIMEText
|
||||
from email.mime.base import MIMEBase
|
||||
from email import encoders
|
||||
import random
|
||||
|
||||
"""
|
||||
Ajout d'un groupe.
|
||||
|
@ -241,7 +242,7 @@ def Update_Groupe_Inscrit(diction):
|
|||
|
||||
}
|
||||
|
||||
print(" ### qry = ", qry)
|
||||
#print(" ### qry = ", qry)
|
||||
|
||||
# Verifier que ce code n'existe pas déjà pour un autre groupe
|
||||
if( "code" in diction.keys() ):
|
||||
|
@ -386,42 +387,54 @@ def Delete_Groupe_Inscrit(diction):
|
|||
if (local_status is not True):
|
||||
return local_status, my_partner
|
||||
|
||||
tab_groupe_ids = ""
|
||||
if ("_id" in diction.keys()):
|
||||
if diction['_id']:
|
||||
tab_groupe_ids = diction['_id']
|
||||
|
||||
# Verifier que la codition de paiement existe
|
||||
is_existe_groupe = MYSY_GV.dbname['groupe_inscription'].count_documents(
|
||||
{'_id': ObjectId(str(diction['_id'])),
|
||||
'valide': '1',
|
||||
'partner_owner_recid': str(my_partner['recid'])})
|
||||
tab_groupe_ids_splited = str(tab_groupe_ids).split(",")
|
||||
|
||||
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_groupe_ids_splited_obj = []
|
||||
for tmp in tab_groupe_ids_splited:
|
||||
tab_groupe_ids_splited_obj.append(ObjectId(str(tmp)))
|
||||
|
||||
|
||||
"""
|
||||
Verifier que le groupe n'est pas utilisé dans la collection 'groupe_inscription_membre'
|
||||
"""
|
||||
is_groupe_has_members = MYSY_GV.dbname['groupe_inscription_membre'].count_documents({'partner_owner_recid':my_partner['recid'],
|
||||
'valide':'1',
|
||||
'groupe_inscription_id':str(diction['_id'])})
|
||||
# Verifier que le groupe existe
|
||||
for groupe_id in tab_groupe_ids_splited :
|
||||
is_existe_groupe = MYSY_GV.dbname['groupe_inscription'].count_documents(
|
||||
{'_id': ObjectId(str(groupe_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 "+str(groupe_id))
|
||||
return False, " L'identifiant du groupe est invalide "+str(groupe_id)
|
||||
|
||||
|
||||
if( is_groupe_has_members > 0 ):
|
||||
mycommon.myprint(
|
||||
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. "
|
||||
"""
|
||||
Verifier que le groupe n'est pas utilisé dans la collection 'groupe_inscription_membre'
|
||||
"""
|
||||
is_groupe_has_members = MYSY_GV.dbname['groupe_inscription_membre'].count_documents({'partner_owner_recid':my_partner['recid'],
|
||||
'valide':'1',
|
||||
'groupe_inscription_id':str(groupe_id)})
|
||||
|
||||
|
||||
if( is_groupe_has_members > 0 ):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " Impossible de supprimer de le groupe. Ce groupe "+str(groupe_id)+" a "+str(is_groupe_has_members)+" membres ")
|
||||
return False, " Impossible de supprimer de le groupe. Ce groupe "+str(groupe_id)+" a "+str(is_groupe_has_members)+" membres. "
|
||||
|
||||
|
||||
|
||||
|
||||
delete = MYSY_GV.dbname['groupe_inscription'].delete_one({'_id': ObjectId(str(diction['_id'])),
|
||||
delete = MYSY_GV.dbname['groupe_inscription'].delete_many({'_id': {'$in': tab_groupe_ids_splited_obj },
|
||||
'partner_owner_recid': str(my_partner['recid']),
|
||||
}, )
|
||||
|
||||
|
||||
|
||||
return True, " Le groupe a été correctement supprimé"
|
||||
return True, " Groupe(s) supprimé(s)"
|
||||
|
||||
except Exception as e:
|
||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||
|
@ -1336,3 +1349,229 @@ def Export_To_Excel_List_Groupe_Membres(diction):
|
|||
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - Line : " + str(exc_tb.tb_lineno))
|
||||
return False, " Impossible de générer l'export "
|
||||
|
||||
|
||||
"""
|
||||
Cette fonction crée automatiquement des groupes et inscrit automatiquement les membres
|
||||
d'incrits avec comme argument :
|
||||
- la formation
|
||||
- la classe
|
||||
- type de groupe
|
||||
- type partage (par nom inscrit, aleatoire)
|
||||
- le nombre de groupe
|
||||
|
||||
La fonction crée les groupe et insc
|
||||
"""
|
||||
|
||||
def Automatic_Creation_Groupe_Member_Inscrit(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', 'type_groupe_code', 'class_id', 'session_id', 'nb_groupe', 'split_type']
|
||||
|
||||
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', 'type_groupe_code', 'class_id', 'session_id', 'nb_groupe', 'split_type']
|
||||
|
||||
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
|
||||
|
||||
nb_groupe = 0
|
||||
local_status, nb_groupe = mycommon.IsInt(diction['nb_groupe'])
|
||||
if (local_status is False):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " Le champ 'nombre de groupe' est incorrecte.")
|
||||
return False, "Le champ 'nombre de groupe' est incorrecte. "
|
||||
|
||||
|
||||
"""
|
||||
type de split :
|
||||
- 0 : Ordre Alphabétique par nom d'inscrit
|
||||
- 1 : Aleatoire
|
||||
"""
|
||||
split_type = str(diction['split_type'])
|
||||
if( split_type not in ['0', '1']):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " Le champ 'groupe par' est incorrecte.")
|
||||
return False, " Le champ 'groupe par' est incorrecte. "
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Verifier que la session est valide
|
||||
"""
|
||||
is_session_valide = MYSY_GV.dbname['session_formation'].count_documents({'_id':ObjectId(str(diction['session_id'])),
|
||||
'valide':'1',
|
||||
'partner_owner_recid':str(my_partner['recid'])})
|
||||
|
||||
if( is_session_valide != 1):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " L'identifiant de classe est invalide ")
|
||||
return False, " L'identifiant de classe est invalide "
|
||||
|
||||
"""
|
||||
Verifier qu'il y des inscrits valides : On ne prend que les inscriptions validée (status = 1)
|
||||
"""
|
||||
is_incription_valide = MYSY_GV.dbname['inscription'].count_documents({'session_id':str(diction['session_id']),
|
||||
'valide':'1',
|
||||
'locked':'0',
|
||||
'status':'1'})
|
||||
|
||||
if( is_incription_valide <= 0 ):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " Aucune inscription valide pour cette formation ")
|
||||
return False, " Aucune inscription valide pour cette formation "
|
||||
|
||||
"""
|
||||
Mettre les _id des inscrits dans une table
|
||||
"""
|
||||
tab_inscription_id = []
|
||||
for tmp in MYSY_GV.dbname['inscription'].find({'session_id': str(diction['session_id']),
|
||||
'valide': '1',
|
||||
'locked': '0',
|
||||
'status': '1'}):
|
||||
tab_inscription_id.append(str(tmp['_id']))
|
||||
|
||||
|
||||
|
||||
|
||||
nb_inscrit = is_incription_valide
|
||||
|
||||
|
||||
"""
|
||||
Creation de la table des groupes
|
||||
"""
|
||||
global_tab_groupe = []
|
||||
cpt = 0
|
||||
|
||||
curr_dt = datetime.now()
|
||||
suff_curr_timestamp = str(round(curr_dt.timestamp()))[-3:]
|
||||
|
||||
while ( cpt < nb_groupe ):
|
||||
cpt = cpt +1
|
||||
local_node = {}
|
||||
local_node['code'] = suff_curr_timestamp+"_Auto_Gr_"+str(cpt)
|
||||
local_node['nom'] = suff_curr_timestamp+" Grp_" + str(cpt)
|
||||
local_node['description'] = suff_curr_timestamp+" Description Grp_" + str(cpt)
|
||||
local_node['type_groupe_code'] = str(diction['type_groupe_code'])
|
||||
local_node['class_id'] = str(diction['class_id'])
|
||||
local_node['session_id'] = str(diction['session_id'])
|
||||
local_node['liste_inscrit'] = []
|
||||
global_tab_groupe.append(local_node)
|
||||
|
||||
|
||||
|
||||
if( split_type == "0"):
|
||||
# On fait une repartition des participant par Ordre Alphabétique par nom d'inscrit
|
||||
nb_inscrit_par_groupe = (nb_inscrit/nb_groupe)+1 # On met le +1 pour couvrir les eventuels modulo
|
||||
|
||||
while(len(tab_inscription_id) > 0 ):
|
||||
i = 0
|
||||
while( i < nb_groupe and len(tab_inscription_id) > 0):
|
||||
i2 = 0
|
||||
while( i2 < nb_inscrit_par_groupe and len(tab_inscription_id) > 0):
|
||||
i2 = i2 +1
|
||||
global_tab_groupe[i]['liste_inscrit'].append(tab_inscription_id[0])
|
||||
|
||||
del tab_inscription_id[0]
|
||||
i = i + 1
|
||||
|
||||
|
||||
elif( split_type == "1"):
|
||||
# On fait une repartition des participant Aleatoire
|
||||
nb_inscrit_par_groupe = (nb_inscrit / nb_groupe) + 1 # On met le +1 pour couvrir les eventuels modulo
|
||||
|
||||
while (len(tab_inscription_id) > 0):
|
||||
i = 0
|
||||
while (i < nb_groupe and len(tab_inscription_id) > 0):
|
||||
curr_dt = datetime.now()
|
||||
curr_timestamp = int(round(curr_dt.timestamp()))
|
||||
|
||||
random_val = random.randint(0,curr_timestamp )%len(tab_inscription_id)
|
||||
global_tab_groupe[i]['liste_inscrit'].append(tab_inscription_id[random_val])
|
||||
del tab_inscription_id[random_val]
|
||||
i = i + 1
|
||||
|
||||
print(" ### les groupes à créer sont : ")
|
||||
for val in global_tab_groupe:
|
||||
print(" ### grp = ", val)
|
||||
|
||||
## Creation du groupe
|
||||
new_data = {}
|
||||
|
||||
new_data['code'] = str(val['code'])
|
||||
new_data['nom'] = str(val['nom'])
|
||||
new_data['description'] = str(val['description'])
|
||||
new_data['type_groupe_code'] = str(diction['type_groupe_code'])
|
||||
new_data['class_id'] = str(diction['class_id'])
|
||||
new_data['session_id'] = str(diction['session_id'])
|
||||
|
||||
|
||||
new_data['valide'] = "1"
|
||||
new_data['locked'] = "0"
|
||||
|
||||
new_data['date_update'] = str(datetime.now())
|
||||
new_data['update_by'] = str(my_partner['_id'])
|
||||
new_data['partner_owner_recid'] = str(my_partner['recid'])
|
||||
|
||||
inserted_grp_id = MYSY_GV.dbname['groupe_inscription'].insert_one(new_data).inserted_id
|
||||
|
||||
for my_inscription in val['liste_inscrit']:
|
||||
new_data = {}
|
||||
new_data['groupe_inscription_id'] = str(inserted_grp_id)
|
||||
new_data['inscription_id'] = str(my_inscription)
|
||||
|
||||
now = str(datetime.now())
|
||||
new_data['date_update'] = now
|
||||
new_data['valide'] = "1"
|
||||
new_data['locked'] = "0"
|
||||
new_data['partner_owner_recid'] = str(my_partner['recid'])
|
||||
new_data['update_by'] = str(my_partner['_id'])
|
||||
|
||||
data_cle = {}
|
||||
data_cle['partner_owner_recid'] = str(my_partner['recid'])
|
||||
data_cle['groupe_inscription_id'] = str(inserted_grp_id)
|
||||
data_cle['inscription_id'] = str(my_inscription)
|
||||
data_cle['valide'] = "1"
|
||||
data_cle['locked'] = "0"
|
||||
|
||||
result = MYSY_GV.dbname['groupe_inscription_membre'].find_one_and_update(
|
||||
data_cle,
|
||||
{"$set": new_data},
|
||||
upsert=True,
|
||||
return_document=ReturnDocument.AFTER
|
||||
)
|
||||
|
||||
|
||||
return True, " Le groupe a été correctement mis à jour"
|
||||
|
||||
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 mettre à jour le groupe "
|
||||
|
|
15
main.py
15
main.py
|
@ -10577,6 +10577,21 @@ def Prepare_and_Send_Email_From_Front_For_Unknown_Contact():
|
|||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
"""
|
||||
API pour partager automatiquement les membres d'une formation (session) en groupe
|
||||
"""
|
||||
@app.route('/myclass/api/Automatic_Creation_Groupe_Member_Inscrit/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Automatic_Creation_Groupe_Member_Inscrit():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Automatic_Creation_Groupe_Member_Inscrit payload = ",payload)
|
||||
status, retval = groupe_inscrit_mgt.Automatic_Creation_Groupe_Member_Inscrit(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
print(" debut api")
|
||||
context = SSL.Context(SSL.SSLv23_METHOD)
|
||||
|
|
Loading…
Reference in New Issue