03/08/2024 - 18h30

master
cherif 2024-08-03 18:36:33 +02:00
parent b5d8267f01
commit 0b5cc35810
4 changed files with 1466 additions and 30 deletions

View File

@ -3,7 +3,6 @@
<component name="ChangeListManager">
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="02/08/2024 - 17h">
<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$/Log/log_file.log" beforeDir="false" afterPath="$PROJECT_DIR$/Log/log_file.log" afterDir="false" />
<change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/unite_enseignement_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/unite_enseignement_mgt.py" afterDir="false" />
@ -76,13 +75,6 @@
<option name="presentableId" value="Default" />
<updated>1680804787304</updated>
</task>
<task id="LOCAL-00316" summary="qsdsq">
<created>1716925262987</created>
<option name="number" value="00316" />
<option name="presentableId" value="LOCAL-00316" />
<option name="project" value="LOCAL" />
<updated>1716925262988</updated>
</task>
<task id="LOCAL-00317" summary="qsdsqqsdsq">
<created>1717062509327</created>
<option name="number" value="00317" />
@ -419,7 +411,14 @@
<option name="project" value="LOCAL" />
<updated>1722612891303</updated>
</task>
<option name="localTasksCounter" value="365" />
<task id="LOCAL-00365" summary="02/08/2024 - 17h">
<created>1722623009656</created>
<option name="number" value="00365" />
<option name="presentableId" value="LOCAL-00365" />
<option name="project" value="LOCAL" />
<updated>1722623009656</updated>
</task>
<option name="localTasksCounter" value="366" />
<servers />
</component>
<component name="Vcs.Log.Tabs.Properties">

File diff suppressed because it is too large Load Diff

View File

@ -10637,7 +10637,7 @@ def Add_Update_Unite_Enseignement_Planif_mass():
if request.method == 'POST':
# Create variable for uploaded file
f = request.files['File']
localStatus, message = SF.Add_Update_Unite_Enseignement_Planif_mass(f, MYSY_GV.TEMPORARY_DIRECTORY_V2, payload)
localStatus, message = unite_enseignement_mgt.Add_Update_Unite_Enseignement_Planif_mass(f, MYSY_GV.TEMPORARY_DIRECTORY_V2, payload)
#status, retval = cm.add_class_mass(f, app.config['UPLOAD_FOLDER'], payload)
return jsonify(status=localStatus, message=message)

View File

@ -534,6 +534,11 @@ def Delete_Given_Unite_Enseignement(diction):
ret_del_competence = MYSY_GV.dbname['unite_enseignement'].delete_many(qry)
"""
On va ensuite supprimer les eventuelles planification de cette UE
"""
ret_del_ue_planif = MYSY_GV.dbname['unite_enseignement_planif'].delete_many({'ue_id':str(diction['_id'])})
return True, "L'UE a été correctement supprimée"
@ -853,7 +858,7 @@ def Add_Update_Unite_Enseignement_Planif(diction):
Verification des input acceptés
"""
field_list = ['token', 'code', 'titre', 'description', 'objectif', 'prerequis', 'volume_horaire',
'ue_id']
'ue_id', 'comment', 'unite_enseignement_planif_id']
incom_keys = diction.keys()
for val in incom_keys:
@ -886,7 +891,19 @@ def Add_Update_Unite_Enseignement_Planif(diction):
if (local_status is not True):
return local_status, my_partner
make_update = "0"
if( "unite_enseignement_planif_id" in diction.keys() and diction['unite_enseignement_planif_id']):
# Il s'agit d'une mise à jour. Verifier que unite_enseignement_planif_id est valide
is_valide_unite_enseignement_planif_id_count = MYSY_GV.dbname['unite_enseignement_planif'].count_documents({'_id':ObjectId(str(diction['unite_enseignement_planif_id'])),
'valide':'1', 'locked':'0',
'partner_owner_recid':str(my_partner['recid'])})
if( is_valide_unite_enseignement_planif_id_count != 1):
mycommon.myprint(
str(inspect.stack()[0][3]) + " L'identifiant de ligne à mettre à jour est invalide ")
return False, " L'identifiant de ligne à mettre à jour est invalide "
make_update = "1"
"""
Verifier que l'UE est valide
@ -929,25 +946,34 @@ def Add_Update_Unite_Enseignement_Planif(diction):
mydata['partner_owner_recid'] = str(my_partner['recid'])
mydata['update_by'] = str(my_partner['_id'])
if( make_update == "1"):
data_cle = {}
data_cle['partner_owner_recid'] = str(my_partner['recid'])
data_cle['ue_id'] = str(diction['ue_id'])
data_cle['_id'] = ObjectId(str(diction['unite_enseignement_planif_id']))
data_cle['valide'] = "1"
data_cle['locked'] = "0"
data_cle = {}
data_cle['partner_owner_recid'] = str(my_partner['recid'])
data_cle['ue_id'] = str(diction['ue_id'])
data_cle['code'] = str(diction['code'])
data_cle['valide'] = "1"
data_cle['locked'] = "0"
result = MYSY_GV.dbname['unite_enseignement_planif'].find_one_and_update(
data_cle,
{"$set": mydata},
upsert=True,
return_document=ReturnDocument.AFTER
)
result = MYSY_GV.dbname['unite_enseignement_planif'].find_one_and_update(
data_cle,
{"$set": mydata},
upsert=True,
return_document=ReturnDocument.AFTER
)
if (result is None or "_id" not in result.keys()):
mycommon.myprint(
" impossible de mettre à jour la planification de l'UE (2) ")
return False, " impossible mettre à jour la planification de l'UE "
else:
inserted_id = ""
inserted_id = MYSY_GV.dbname['unite_enseignement_planif'].insert_one(mydata).inserted_id
if (not inserted_id):
mycommon.myprint(
" Impossible de créer la planification de l'UE (2) ")
return False, " Impossible de créer la planification de l'UE (2) "
if (result is None or "_id" not in result.keys()):
mycommon.myprint(
" mpossible de créer la planification de l'UE (2) ")
return False, " mpossible de créer la planification de l'UE "
return True, "La planification de l'UE a été correctement ajoutée / Mise à jour"
@ -1017,6 +1043,7 @@ def Delete_List_Unite_Enseignement_Planif(diction):
'locked': '0',
}
#print(" ### qery_delete = ", qery_delete)
ret_del_competence = MYSY_GV.dbname['unite_enseignement_planif'].delete_many(qery_delete)
@ -1181,6 +1208,11 @@ def Add_Update_Unite_Enseignement_Planif_mass(file=None, Folder=None, diction=No
mydata['ue_id'] = ue_id
code = ""
if ("code" in df.keys()):
code = str(df['code'].values[n]).strip()
mydata['code'] = code
titre = ""
if ("titre" in df.keys()):
@ -1230,7 +1262,7 @@ def Add_Update_Unite_Enseignement_Planif_mass(file=None, Folder=None, diction=No
clean_dict = {k: mydata[k] for k in mydata if (str(mydata[k]) != "nan")}
print("#### Add_Update_Unite_Enseignement_Planif_mass : clean_dict ", clean_dict)
#print("#### Add_Update_Unite_Enseignement_Planif_mass : clean_dict ", clean_dict)
status, retval = Add_Update_Unite_Enseignement_Planif(clean_dict)
if (status is False):
@ -1324,8 +1356,7 @@ def Controle_Add_Update_Unite_Enseignement_Planif_mass(saved_file=None, Folder=N
return False, " Entete du fichier csv. La Colonne '" + val + "' n'est pas acceptée"
# Verification des champs obligatoires dans le fichier
field_list_obligatoire_file = ['date_debut', 'date_fin', 'session_status', 'code_session',
'formation_code_externe']
field_list_obligatoire_file = ['code', 'titre', 'description', 'volume_horaire', 'ue_code']
for val in field_list_obligatoire_file:
if val not in df.columns: