04/01/2025 - 14h48

master
cherif 2025-01-04 14:59:25 +01:00
parent 2184118a86
commit 7c9e7b832e
4 changed files with 3694 additions and 16 deletions

View File

@ -1,15 +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="31/12/2024 - 12h30">
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="03/01/2025 - 17h30">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Activite.py" beforeDir="false" afterPath="$PROJECT_DIR$/Activite.py" 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$/articles_avis.py" beforeDir="false" afterPath="$PROJECT_DIR$/articles_avis.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/class_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/class_mgt.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Session_Formation.py" beforeDir="false" afterPath="$PROJECT_DIR$/Session_Formation.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" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -80,13 +76,6 @@
<option name="presentableId" value="Default" />
<updated>1680804787304</updated>
</task>
<task id="LOCAL-00377" summary="20/08/2024 - 21h55">
<created>1724183059275</created>
<option name="number" value="00377" />
<option name="presentableId" value="LOCAL-00377" />
<option name="project" value="LOCAL" />
<updated>1724183059276</updated>
</task>
<task id="LOCAL-00378" summary="21/08/2024 - 13h55">
<created>1724240924909</created>
<option name="number" value="00378" />
@ -423,7 +412,14 @@
<option name="project" value="LOCAL" />
<updated>1735645810803</updated>
</task>
<option name="localTasksCounter" value="426" />
<task id="LOCAL-00426" summary="03/01/2025 - 17h30">
<created>1735921643826</created>
<option name="number" value="00426" />
<option name="presentableId" value="LOCAL-00426" />
<option name="project" value="LOCAL" />
<updated>1735921643830</updated>
</task>
<option name="localTasksCounter" value="427" />
<servers />
</component>
<component name="Vcs.Log.Tabs.Properties">
@ -465,7 +461,6 @@
</option>
</component>
<component name="VcsManagerConfiguration">
<MESSAGE value="sdfsd" />
<MESSAGE value="sdfsdsdsd" />
<MESSAGE value="05/10/2024 - 12h" />
<MESSAGE value="05/10/2024 - 18h30" />
@ -490,6 +485,7 @@
<MESSAGE value="sdfd" />
<MESSAGE value="sdfdd" />
<MESSAGE value="31/12/2024 - 12h30" />
<option name="LAST_COMMIT_MESSAGE" value="31/12/2024 - 12h30" />
<MESSAGE value="03/01/2025 - 17h30" />
<option name="LAST_COMMIT_MESSAGE" value="03/01/2025 - 17h30" />
</component>
</project>

File diff suppressed because it is too large Load Diff

View File

@ -562,6 +562,142 @@ def Add_Update_SessionFormation(diction):
return False, "Impossible de créer / mettre à jour la session de formation"
"""
Gestion de mise à jour JUSTE de l'etape, notamment utilisé dans le mode kanban
/!\ : Une session est modifiable tanque la facturation n'a pas demarré. Apres tous est bloqué
"""
def Update_SessionFormation_Only_Step(diction):
try:
'''
# Verification que les champs reçus dans l'API sont bien dans la liste des champs autorisés
# Cela evite le cas ou une entité tierce ajouter les valeurs inconnu dans l'API
# Ici on doit mettre tous les champs possible (obligatoire ou non) de la BDD dans la liste
# field_list.
'''
field_list = ['token', '_id', 'session_etape', ]
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, " Toutes les informations fournies ne sont pas valables"
"""
Verification de la liste des champs obligatoires
"""
field_list_obligatoire = ['token', '_id', 'session_etape', ]
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, "Toutes les informations necessaires n'ont pas été fournies"
mydata = {}
query_key = {}
my_token = ""
if ("token" in diction.keys()):
if diction['token']:
my_token = diction['token']
data_for_check_connexion = {'token': my_token}
local_status, my_partner = mycommon.Check_Connexion_And_Return_Partner_Data(data_for_check_connexion)
if (local_status is not True):
return local_status, my_partner
"""
Verifier la valididé de la session de formation
"""
is_valide_session = MYSY_GV.dbname['session_formation'].count_documents({'_id':ObjectId(str(diction['_id'])),
'valide':'1', 'partner_owner_recid':str(my_partner['recid'])})
if( is_valide_session != 1 ):
mycommon.myprint(
str(inspect.stack()[0][3]) + " - L'identifiant de la session de formation est invalide ")
return False, "L'identifiant de la session de formation est invalide"
is_valide_session_data = MYSY_GV.dbname['session_formation'].find_one({'_id': ObjectId(str(diction['_id'])),
'valide': '1',
'partner_owner_recid': str(
my_partner['recid'])})
if( "invoiced_statut" in is_valide_session_data.keys() and is_valide_session_data['invoiced_statut'] == '1'):
mycommon.myprint(
str(inspect.stack()[0][3]) + " - Cette session est partiellement facturée. Impossible de modifier l'étape ")
return False, "Cette session est partiellement facturée. Impossible de modifier l'étape"
if ("invoiced_statut" in is_valide_session_data.keys() and is_valide_session_data['invoiced_statut'] == '2'):
mycommon.myprint(
str(inspect.stack()[0][
3]) + " - Cette session est complètement facturée. Impossible de modifier l'étape ")
return False, "Cette session est complètement facturée. Impossible de modifier l'étape"
new_data = {}
new_data['date_update'] = str(datetime.now())
new_data['update_by'] = str(my_partner['_id'])
new_data['valide'] = "1"
new_data['session_etape'] = str(diction['session_etape'])
# print(" ###laaa mydata = ", mydata)
coll_name = MYSY_GV.dbname['session_formation']
ret_val = coll_name.find_one_and_update(
{'_id': ObjectId(str(diction['_id'])),
'valide': '1', 'partner_owner_recid': str(my_partner['recid'])},
{"$set": new_data},
upsert=False,
return_document=ReturnDocument.AFTER
)
if (ret_val is None or '_id' not in ret_val.keys()):
mycommon.myprint(
str(inspect.stack()[0][3]) + " Impossible d'ajouter/mettre à jour la session '" + str(
diction['code_session']) + "' ")
return False, "Impossible d'ajouter/mettre à jour la session '" + str(diction['code_session']) + "' "
"""
# Ajout de l'evenement dans l'historique
"""
now = str(datetime.now().strftime("%d/%m/%Y %H:%M:%S"))
history_event_dict = {}
history_event_dict['token'] = diction['token']
history_event_dict['related_collection'] = "session_formation"
history_event_dict['related_collection_recid'] = str(ret_val['_id'])
history_event_dict['action_date'] = str(now)
history_event_dict['action_description'] = "Mise à jour : Session Etape passe à "+str(diction['session_etape'])
local_status, local_retval = mycommon.Collection_Historique.Add_Historique_Event(history_event_dict)
if (local_status is False):
mycommon.myprint(
" WARNING : Impossible de logguer l'historique pour l'évènement : " + str(history_event_dict))
return True, " La session de formation à bien été mise à jour"
except Exception as e:
exc_type, exc_obj, exc_tb = sys.exc_info()
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
return False, "Impossible mettre à jour la session de formation"
"""
Fonction de recuperation d'une session de formation.

19
main.py
View File

@ -2214,6 +2214,25 @@ def Add_Update_SessionFormation():
localStatus, message= SF.Add_Update_SessionFormation(payload)
return jsonify(status=localStatus, message=message )
"""
API de mise à jour JUSTE de l'etape, notamment utilisé dans le mode kanban
/!\ : Une session est modifiable tanque la facturation n'a pas demarré. Apres tous est bloqué
"""
@app.route('/myclass/api/Update_SessionFormation_Only_Step/', methods=['POST','GET'])
@crossdomain(origin='*')
def Update_SessionFormation_Only_Step():
# On recupere le corps (payload) de la requete
payload = mycommon.strip_dictionary (request.form.to_dict())
print(" ### Update_SessionFormation_Only_Step : payload = ",str(payload))
localStatus, message= SF.Update_SessionFormation_Only_Step(payload)
return jsonify(status=localStatus, message=message )
"""
API de recuperation de toutes les sessions de formation valides et actives
"""