11/08/2024 - 12h32s

master
cherif 2024-08-11 12:13:34 +02:00
parent 280c351e12
commit 62cc5aad4b
4 changed files with 3295 additions and 12 deletions

View File

@ -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="08/08/2024 - 20h32s">
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="10/08/2024 - 20h32s">
<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_Sequence.py" beforeDir="false" afterPath="$PROJECT_DIR$/Session_Formation_Sequence.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" />
@ -75,13 +75,6 @@
<option name="presentableId" value="Default" />
<updated>1680804787304</updated>
</task>
<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>
<task id="LOCAL-00320" summary="01/06/2024 - 14h30">
<created>1717245781084</created>
<option name="number" value="00320" />
@ -418,7 +411,14 @@
<option name="project" value="LOCAL" />
<updated>1723210885743</updated>
</task>
<option name="localTasksCounter" value="368" />
<task id="LOCAL-00368" summary="10/08/2024 - 20h32s">
<created>1723319219142</created>
<option name="number" value="00368" />
<option name="presentableId" value="LOCAL-00368" />
<option name="project" value="LOCAL" />
<updated>1723319219157</updated>
</task>
<option name="localTasksCounter" value="369" />
<servers />
</component>
<component name="Vcs.Log.Tabs.Properties">
@ -460,7 +460,6 @@
</option>
</component>
<component name="VcsManagerConfiguration">
<MESSAGE value="wwssd" />
<MESSAGE value="wwssdss" />
<MESSAGE value="wwssdssd" />
<MESSAGE value="wwssdssddd" />
@ -485,6 +484,7 @@
<MESSAGE value="08/08/2024 - 20h30" />
<MESSAGE value="08/08/2024 - 20h32" />
<MESSAGE value="08/08/2024 - 20h32s" />
<option name="LAST_COMMIT_MESSAGE" value="08/08/2024 - 20h32s" />
<MESSAGE value="10/08/2024 - 20h32s" />
<option name="LAST_COMMIT_MESSAGE" value="10/08/2024 - 20h32s" />
</component>
</project>

File diff suppressed because it is too large Load Diff

View File

@ -340,7 +340,316 @@ def Add_Session_Sequence(diction):
return False, " Impossible d'ajouter la séquence "
"""
Ajout d'une requence avec retour des données de la sequence ajoutée
"""
def Add_Session_Sequence_Return_New_Seq_Data(diction):
try:
diction = mycommon.strip_dictionary(diction)
"""
Verification des input acceptés
"""
field_list = ['token', 'session_id', 'sequence_title', 'sequence_start', 'sequence_end', 'agenda', 'objectif',
'commentaire', 'check_chevauchement', 'grp_apprenant_id', 'ue_id', 'type', 'ue_planif_line_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'est pas autorisé")
return False, " Les informations fournies sont incorrectes", False
"""
Verification des champs obligatoires
"""
field_list_obligatoire = ['token', 'session_id', 'sequence_title', 'sequence_start', 'sequence_end', ]
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", False
"""
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, False
# Verification de l'existence et de la session
is_existe_valide_session_id = MYSY_GV.dbname["session_formation"].count_documents(
{'_id': ObjectId(str(diction['session_id'])),
'partner_owner_recid': str(my_partner['recid']),
'valide': '1'})
if (is_existe_valide_session_id <= 0):
mycommon.myprint(
str(inspect.stack()[0][3]) + " - L'identifiant de la session n'est pas valide ")
return False, "L'identifiant de la session n'est pas valide ", False
# Recuperation des données de la session
is_existe_valide_session_id_data = MYSY_GV.dbname["session_formation"].find_one(
{'_id': ObjectId(str(diction['session_id'])),
'partner_owner_recid': str(my_partner['recid']),
'valide': '1'})
# Verifier qu'il n'y a pas de chevauchement de date avec une autre sequence de la meme session.
date_debut_seq = ""
if ("sequence_start" in diction.keys()):
if diction['sequence_start']:
date_debut_seq = str(diction['sequence_start'])
local_status = mycommon.CheckisDate_Hours(date_debut_seq)
if (local_status is False):
mycommon.myprint(
str(inspect.stack()[0][
3]) + " La date de debut de séquence " + str(
date_debut_seq) + " n'est pas au format 'jj/mm/aaaa hh:mm' ")
return False, " La date de debut de séquence " + str(
date_debut_seq) + " n'est pas au format 'jj/mm/aaaa hh:mm'", False
date_fin_seq = ""
if ("sequence_end" in diction.keys()):
if diction['sequence_end']:
date_fin_seq = str(diction['sequence_end'])
local_status = mycommon.CheckisDate_Hours(date_fin_seq)
if (local_status is False):
mycommon.myprint(
str(inspect.stack()[0][
3]) + " La date de fin de séquence " + str(
date_fin_seq) + " n'est pas au format 'jj/mm/aaaa hh:mm' ")
return False, " La date de fin de séquence " + str(
date_fin_seq) + " n'est pas au format 'jj/mm/aaaa hh:mm'", False
if (datetime.strptime(str(date_debut_seq), '%d/%m/%Y %H:%M') >= datetime.strptime(str(date_fin_seq),
'%d/%m/%Y %H:%M')):
mycommon.myprint(
str(inspect.stack()[0][
3]) + " La date de fin de séquence " + str(
date_fin_seq) + " doit être postérieure à la date de début de séquence " + str(
date_debut_seq) + " ")
return False, " La date de fin de séquence " + str(
date_fin_seq) + " doit être postérieure à la date de début de séquence " + str(date_debut_seq) + " ", False
"""
04/05/2024 : Controle des chevauchements
Par defaut on fait des controle de chevauchement, sauf si on decide de la desactiver
"""""
check_chevauchement = 1
if ("check_chevauchement" in diction.keys() and diction['check_chevauchement'] == "0"):
check_chevauchement = 0
local_grp_apprenant_id = ""
if ("grp_apprenant_id" in diction.keys()):
local_grp_apprenant_id = diction['grp_apprenant_id']
local_ue_id = ""
if ("ue_id" in diction.keys()):
local_ue_id = diction['ue_id']
if (check_chevauchement == 1 and str(diction['type']) == "planning"):
for retVal in MYSY_GV.dbname['session_formation_sequence'].find({'session_id': str(diction['session_id']),
'partner_owner_recid': str(
my_partner['recid']),
'grp_apprenant_id': str(
local_grp_apprenant_id),
'ue_id': str(local_ue_id),
'valide': '1',
'locked': '0'}):
# print(" #### str(retVal['event_start']) = ", str(retVal['sequence_start']))
# print(" #### str(retVal['event_end']) = ", str(retVal['sequence_end']))
New_retVal_start_date = datetime.strptime(str(retVal['sequence_start']), '%d/%m/%Y %H:%M').strftime(
"%d/%m/%Y %H:%M")
New_retVal_end_date = datetime.strptime(str(retVal['sequence_end']), '%d/%m/%Y %H:%M').strftime(
"%d/%m/%Y %H:%M")
# print(" ### New_retVal_start_date = ", New_retVal_start_date)
# print(" ### New_retVal_end_date = ", New_retVal_end_date)
if (datetime.strptime(str(New_retVal_start_date), '%d/%m/%Y %H:%M') <= datetime.strptime(
str(date_debut_seq), '%d/%m/%Y %H:%M') and
datetime.strptime(str(New_retVal_end_date), '%d/%m/%Y %H:%M') >= datetime.strptime(
str(date_debut_seq), '%d/%m/%Y %H:%M')):
mycommon.myprint(
str(inspect.stack()[0][
3]) + " La date de debut de séquence " + str(
date_debut_seq) + " chevauche une autre séquence ")
return False, " La date de debut de séquence " + str(
date_debut_seq) + " chevauche une autre séquence", False
if (datetime.strptime(str(New_retVal_start_date), '%d/%m/%Y %H:%M') <= datetime.strptime(
str(date_fin_seq), '%d/%m/%Y %H:%M') and
datetime.strptime(str(New_retVal_end_date), '%d/%m/%Y %H:%M') >= datetime.strptime(
str(date_fin_seq), '%d/%m/%Y %H:%M')):
mycommon.myprint(
str(inspect.stack()[0][
3]) + " La date de fin de séquence " + str(
date_debut_seq) + " chevauche une autre séquence ")
return False, " La date de fin de séquence " + str(
date_debut_seq) + " chevauche une autre séquence", False
sequence_type = "planning"
if ("type" in diction.keys()):
sequence_type = str(diction['type'])
sequence_title = ""
if ("sequence_title" in diction.keys()):
sequence_title = str(diction['sequence_title'])
agenda = ""
if ("agenda" in diction.keys()):
agenda = str(diction['agenda'])
objectif = ""
if ("objectif" in diction.keys()):
objectif = str(diction['objectif'])
commentaire = ""
if ("commentaire" in diction.keys()):
commentaire = str(diction['commentaire'])
grp_apprenant_id = ""
if ("grp_apprenant_id" in diction.keys() and diction['grp_apprenant_id']):
grp_apprenant_id = str(diction['grp_apprenant_id'])
is_valide_grp_apprenant_id = MYSY_GV.dbname['groupe_inscription'].count_documents(
{'_id': ObjectId(str(diction['grp_apprenant_id'])),
'valide': '1', 'locked': '0',
'partner_owner_recid': str(my_partner['recid'])})
if (is_valide_grp_apprenant_id != 1):
mycommon.myprint(
str(inspect.stack()[0][3]) + " L'identifiant du groupe est invalide ")
return False, " L'identifiant du groupe est invalide ", False
ue_id = ""
if ("ue_id" in diction.keys() and diction['ue_id']):
ue_id = str(diction['ue_id'])
is_valide_ue_id = MYSY_GV.dbname['unite_enseignement'].count_documents(
{'_id': ObjectId(str(diction['ue_id'])),
'valide': '1', 'locked': '0',
'partner_owner_recid': str(my_partner['recid'])})
if (is_valide_ue_id != 1):
mycommon.myprint(
str(inspect.stack()[0][3]) + " L'identifiant de l'unité d'enseignement est invalide ")
return False, " L'identifiant de l'unité d'enseignement est invalide ", False
new_session_formation_sequence_id = ""
ue_planif_line_id = ""
if ("ue_id" in diction.keys() and diction['ue_id'] and "ue_planif_line_id" in diction.keys() and diction[
'ue_planif_line_id']):
ue_planif_line_id = str(diction['ue_planif_line_id'])
is_valide_unite_enseignement_planif_id = MYSY_GV.dbname['unite_enseignement_planif'].count_documents(
{'_id': ObjectId(str(diction['ue_planif_line_id'])),
'ue_id': str(diction['ue_id']),
'valide': '1', 'locked': '0',
'partner_owner_recid': str(my_partner['recid']),
})
if (is_valide_unite_enseignement_planif_id != 1):
mycommon.myprint(
str(inspect.stack()[0][
3]) + " L'identifiant de la ligne de planification de unité d'enseignement est invalide ")
return False, " L'identifiant de la ligne de planification de unité d'enseignement est invalide ", False
"""
is_valide_unite_enseignement_planif_id_data = MYSY_GV.dbname['unite_enseignement_planif'].find_one(
{'_id': ObjectId(str(diction['ue_planif_line_id'])),
'ue_id': str(diction['ue_id']),
'valide': '1', 'locked': '0',
'partner_owner_recid': str(my_partner['recid']),
})
if(is_valide_unite_enseignement_planif_id_data and "session_formation_sequence_id" in is_valide_unite_enseignement_planif_id_data.keys() and
is_valide_unite_enseignement_planif_id_data['session_formation_sequence_id']):
mycommon.myprint(
str(inspect.stack()[0][
3]) + " La ligne de planification de unité d'enseignement est actuellement utilisé. Impossible d'associer à cette ligne à une nouvelle séquence ")
return False, " La ligne de planification de unité d'enseignement est actuellement utilisé. Impossible d'associer à cette ligne à une nouvelle séquence "
"""
my_data = {}
my_data['session_id'] = str(diction['session_id'])
my_data['type'] = sequence_type
my_data['sequence_title'] = sequence_title
my_data['sequence_start'] = date_debut_seq
my_data['sequence_end'] = date_fin_seq
my_data['agenda'] = agenda
my_data['objectif'] = objectif
my_data['commentaire'] = commentaire
my_data['grp_apprenant_id'] = grp_apprenant_id
my_data['ue_id'] = ue_id
my_data['unite_enseignement_planif_id'] = ue_planif_line_id
my_data['valide'] = "1"
my_data['locked'] = "0"
my_data['partner_owner_recid'] = str(my_partner['recid'])
my_data['update_by'] = str(my_partner['_id'])
local_retval = MYSY_GV.dbname['session_formation_sequence'].insert_one(my_data)
"""
recuperation des données inserées
"""
inserted_seq_data = None
RetObject = []
val_tmp = 0
if( local_retval and local_retval.inserted_id ):
for inserted_seq_data in MYSY_GV.dbname['session_formation_sequence'].find({'_id':ObjectId(str(local_retval.inserted_id)),'partner_owner_recid':str(my_partner['recid'])}):
user = inserted_seq_data
user['id'] = str(inserted_seq_data)
val_tmp = val_tmp + 1
RetObject.append(mycommon.JSONEncoder().encode(user))
else:
return False, "Impossible d'ajouter la séquence (2) ",False
new_session_formation_sequence_id = str(local_retval.inserted_id)
"""
Si la mise à jour fonction et qu'on a bien un update_data['ue_planif_line_id'] = str(diction['ue_planif_line_id'])
alors on met à jour la ligne de la collection : unite_enseignement_planif.
1 - On programme le nouvelle ligne de planification
"""
if (ue_planif_line_id):
# Programmation de la nouvelle
update_data = {}
update_data['date_update'] = str(datetime.now())
update_data['update_by'] = str(my_partner['_id'])
update_data['session_formation_sequence_id'] = str(new_session_formation_sequence_id)
update = MYSY_GV.dbname['unite_enseignement_planif'].update_one(
{'_id': ObjectId(str(ue_planif_line_id)),
'partner_owner_recid': str(
my_partner['recid']),
'valide': '1',
'locked': '0'},
{'$set': update_data}
)
return True, "La séquence a été correctement ajoutée", 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 d'ajouter la séquence ", False
"""

13
main.py
View File

@ -6849,6 +6849,19 @@ def Add_Session_Sequence():
status, retval = Session_Formation_Sequence.Add_Session_Sequence(payload)
return jsonify(status=status, message=retval)
"""
API qui ajoute une sequence à une session de formation avec retour des données de la sequence ajoutée
"""
@app.route('/myclass/api/Add_Session_Sequence_Return_New_Seq_Data/', methods=['POST','GET'])
@crossdomain(origin='*')
def Add_Session_Sequence_Return_New_Seq_Data():
# On recupere le corps (payload) de la requete
payload = mycommon.strip_dictionary (request.form.to_dict())
print(" ### Add_Session_Sequence_Return_New_Seq_Data payload = ",payload)
status, retval, new_sequence_data = Session_Formation_Sequence.Add_Session_Sequence_Return_New_Seq_Data(payload)
return jsonify(status=status, message=retval, new_sequence_data=new_sequence_data)
"""