15/08/2025 - 12h30
parent
d9312eb403
commit
d3db7a0f7c
|
@ -1,7 +1,7 @@
|
|||
<?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="dd">
|
||||
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="ddd">
|
||||
<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$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
|
||||
|
@ -75,13 +75,6 @@
|
|||
<option name="presentableId" value="Default" />
|
||||
<updated>1680804787304</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00322" summary="qsdsq">
|
||||
<created>1717577652189</created>
|
||||
<option name="number" value="00322" />
|
||||
<option name="presentableId" value="LOCAL-00322" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1717577652191</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00323" summary="qsdsqsqdsq">
|
||||
<created>1717601060943</created>
|
||||
<option name="number" value="00323" />
|
||||
|
@ -418,7 +411,14 @@
|
|||
<option name="project" value="LOCAL" />
|
||||
<updated>1723488781961</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="371" />
|
||||
<task id="LOCAL-00371" summary="ddd">
|
||||
<created>1723555903066</created>
|
||||
<option name="number" value="00371" />
|
||||
<option name="presentableId" value="LOCAL-00371" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1723555903066</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="372" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="Vcs.Log.Tabs.Properties">
|
||||
|
@ -460,7 +460,6 @@
|
|||
</option>
|
||||
</component>
|
||||
<component name="VcsManagerConfiguration">
|
||||
<MESSAGE value="11/07/2024 - 13h14" />
|
||||
<MESSAGE value="13/07/2024 - 22h" />
|
||||
<MESSAGE value="14/07/2024 - 22h" />
|
||||
<MESSAGE value="dqsdqs" />
|
||||
|
@ -485,6 +484,7 @@
|
|||
<MESSAGE value="11/08/2024 - 12h32s" />
|
||||
<MESSAGE value="11/08/2024 - 18h32s" />
|
||||
<MESSAGE value="dd" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="dd" />
|
||||
<MESSAGE value="ddd" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="ddd" />
|
||||
</component>
|
||||
</project>
|
5515
Log/log_file.log
5515
Log/log_file.log
File diff suppressed because it is too large
Load Diff
14
main.py
14
main.py
|
@ -10815,6 +10815,20 @@ def Get_Given_Sequence_Planning_Model_With_Option():
|
|||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
"""
|
||||
API permet d'appliquer un nouveau planning à une session apres avoir
|
||||
choisir un planning modele
|
||||
"""
|
||||
@app.route('/myclass/api/Apply_Planning_Model_To_Session/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Apply_Planning_Model_To_Session():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Apply_Planning_Model_To_Session payload = ",payload)
|
||||
status, retval = model_planning_sequence_mgt.Apply_Planning_Model_To_Session(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
print(" debut api")
|
||||
|
|
|
@ -406,7 +406,7 @@ def Get_Given_Sequence_Planning_Model_With_Option(diction):
|
|||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', '_id', 'date_debut', 'jounree_modele_id']
|
||||
field_list = ['token', '_id', 'date_debut']
|
||||
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
|
@ -418,7 +418,7 @@ def Get_Given_Sequence_Planning_Model_With_Option(diction):
|
|||
"""
|
||||
Verification des champs obligatoires
|
||||
"""
|
||||
field_list_obligatoire = ['token', '_id', 'date_debut', 'jounree_modele_id']
|
||||
field_list_obligatoire = ['token', '_id', 'date_debut',]
|
||||
|
||||
for val in field_list_obligatoire:
|
||||
if val not in diction:
|
||||
|
@ -443,54 +443,18 @@ def Get_Given_Sequence_Planning_Model_With_Option(diction):
|
|||
Si le "jounree_modele_id" est vide, cela veut dire qu'il faut aller chercher le modele par default
|
||||
"""
|
||||
jounree_modele_id = ""
|
||||
if (str(diction['jounree_modele_id']) == ""):
|
||||
jounree_modele_data = MYSY_GV.dbname['base_config_modele_journee'].find_one(
|
||||
{'partner_owner_recid': str(my_partner['recid']),
|
||||
'valide': '1', 'locked': '0'})
|
||||
|
||||
if (jounree_modele_data is None):
|
||||
# On ne trouve pas de modele par defaut pour ce client. On va aller le chercher le modele par defaut de MySy
|
||||
jounree_modele_data_mysy = MYSY_GV.dbname['base_config_modele_journee'].find_one(
|
||||
{'partner_owner_recid': "default", 'valide': '1', 'locked': '0'})
|
||||
|
||||
if (jounree_modele_data_mysy is None):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " - Aucun modèle de journée n'est configuré dans le système ")
|
||||
return False, " Aucun modèle de journée n'est configuré dans le système "
|
||||
|
||||
jounree_modele_id = str(jounree_modele_data_mysy['_id'])
|
||||
|
||||
|
||||
else:
|
||||
jounree_modele_id = str(jounree_modele_data['_id'])
|
||||
|
||||
|
||||
else:
|
||||
jounree_modele_id = str(diction['jounree_modele_id'])
|
||||
|
||||
|
||||
if (str(jounree_modele_id).strip() == ""):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " - Aucun modèle de journée n'est configuré dans le système (2) ")
|
||||
return False, " Aucun modèle de journée n'est configuré dans le système (2) "
|
||||
|
||||
|
||||
# Verification de l'existence du modele de journée
|
||||
is_existe_valide_journee_model_id = MYSY_GV.dbname["base_config_modele_journee"].count_documents(
|
||||
{'_id': ObjectId(str(jounree_modele_id)),
|
||||
'partner_owner_recid': str(my_partner['recid']),
|
||||
jounree_modele_data = MYSY_GV.dbname['base_config_modele_journee'].find_one(
|
||||
{'partner_owner_recid': str(my_partner['recid']),
|
||||
'valide': '1', 'locked': '0'})
|
||||
|
||||
if (is_existe_valide_journee_model_id <= 0):
|
||||
if (jounree_modele_data is None):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " - L'identifiant du modèle de journee n'est pas valide ")
|
||||
return False, " L'identifiant du modèle de journee n'est pas valide "
|
||||
str(inspect.stack()[0][3]) + " - Aucun modèle de journée n'est configuré ")
|
||||
return False, " Aucun modèle de journée n'est configuré. "
|
||||
|
||||
jounree_modele_id = str(jounree_modele_data['_id'])
|
||||
|
||||
# Recuperation des data de la journée modele
|
||||
is_existe_valide_journee_model_data = MYSY_GV.dbname["base_config_modele_journee"].find_one(
|
||||
{'_id': ObjectId(str(jounree_modele_id)),
|
||||
'partner_owner_recid': str(my_partner['recid']),
|
||||
'valide': '1', 'locked': '0'})
|
||||
|
||||
"""
|
||||
Verifier la validité du modele de planning
|
||||
|
@ -519,11 +483,6 @@ def Get_Given_Sequence_Planning_Model_With_Option(diction):
|
|||
|
||||
date_debut = str(diction['date_debut'])[0:10]
|
||||
|
||||
jounree_modele_id = ""
|
||||
if( "jounree_modele_id" in diction.keys() and diction['jounree_modele_id']):
|
||||
jounree_modele_id = diction['jounree_modele_id']
|
||||
|
||||
|
||||
|
||||
data_header_qry = {'_id': ObjectId(str(diction['_id'])),
|
||||
'partner_owner_recid': str(my_partner['recid']), }
|
||||
|
@ -557,24 +516,30 @@ def Get_Given_Sequence_Planning_Model_With_Option(diction):
|
|||
])
|
||||
|
||||
lines_data = []
|
||||
new_lines_data = []
|
||||
for retval in MYSY_GV.dbname['planning_model_line'].aggregate(data_lines_qry):
|
||||
user = retval
|
||||
lines_data.append(user)
|
||||
|
||||
|
||||
print(" ### 1ere date du planning precedent est : ", str(lines_data[0]['sequence_start'])[0:10])
|
||||
|
||||
|
||||
"""
|
||||
Traiter l'application des options au calendrier
|
||||
"""
|
||||
print(" jounree_modele_id = ", jounree_modele_id, " date_debut = ", date_debut)
|
||||
if( jounree_modele_id and date_debut ):
|
||||
mytoday = datetime.today().strftime("%d/%m/%Y")
|
||||
decalage_planning = (datetime.strptime(str(date_debut), '%d/%m/%Y') - datetime.strptime(str(mytoday),
|
||||
'%d/%m/%Y')).days
|
||||
decalage_planning = (datetime.strptime(str(date_debut), '%d/%m/%Y') - datetime.strptime(str(str(lines_data[0]['sequence_start'])[0:10]), '%d/%m/%Y') ).days
|
||||
|
||||
print(" ### ce planning doit etre appliqué avec un de calage de "+str(decalage_planning)+" jours ")
|
||||
|
||||
|
||||
for planning_line in lines_data:
|
||||
new_planning_line_node = {}
|
||||
new_planning_line_node = planning_line
|
||||
|
||||
planning_line_sequence_start = str(planning_line['sequence_start'])
|
||||
local_status = mycommon.CheckisDate_Hours(planning_line_sequence_start)
|
||||
if (local_status is False):
|
||||
|
@ -626,13 +591,13 @@ def Get_Given_Sequence_Planning_Model_With_Option(diction):
|
|||
print(" jour_name = ", jour_name)
|
||||
|
||||
is_off_day_of_week = "0"
|
||||
if (str(jour_name) in is_existe_valide_journee_model_data.keys()):
|
||||
is_off_day_of_week = is_existe_valide_journee_model_data[str(jour_name)]['is_off_day']
|
||||
if (str(jour_name) in jounree_modele_data.keys()):
|
||||
is_off_day_of_week = jounree_modele_data[str(jour_name)]['is_off_day']
|
||||
|
||||
if (date_jour not in is_existe_valide_journee_model_data['date_off'] and is_off_day_of_week != "1"):
|
||||
if (date_jour not in jounree_modele_data['date_off'] and is_off_day_of_week != "1"):
|
||||
print(" DATE / JOUR OKKKKK")
|
||||
|
||||
while (date_jour in is_existe_valide_journee_model_data['date_off'] or is_off_day_of_week == "1"):
|
||||
while (date_jour in jounree_modele_data['date_off'] or is_off_day_of_week == "1"):
|
||||
print(str(date_jour)+" est KOOOO ")
|
||||
print(str(jour_name) + " est KOOOO ")
|
||||
|
||||
|
@ -649,13 +614,22 @@ def Get_Given_Sequence_Planning_Model_With_Option(diction):
|
|||
date_jour = str(new_planning_line_sequence_start_datetime.strftime("%Y-%m-%d"))
|
||||
jour_name = new_planning_line_sequence_start_datetime.strftime("%A")
|
||||
|
||||
if (str(jour_name) in is_existe_valide_journee_model_data.keys()):
|
||||
is_off_day_of_week = is_existe_valide_journee_model_data[str(jour_name)]['is_off_day']
|
||||
if (str(jour_name) in jounree_modele_data.keys()):
|
||||
is_off_day_of_week = jounree_modele_data[str(jour_name)]['is_off_day']
|
||||
|
||||
print(" new_planning_line_sequence_start_datetime = ", new_planning_line_sequence_start_datetime.strftime("%d/%m/%Y %H:%M"))
|
||||
print(" new_planning_line_sequence_end_datetime = ", new_planning_line_sequence_end_datetime.strftime("%d/%m/%Y %H:%M"))
|
||||
|
||||
new_planning_line_node['new_sequence_start'] = new_planning_line_sequence_start_datetime.strftime("%d/%m/%Y %H:%M")
|
||||
new_planning_line_node['new_sequence_end'] = new_planning_line_sequence_end_datetime.strftime("%d/%m/%Y %H:%M")
|
||||
|
||||
new_lines_data.append(new_planning_line_node)
|
||||
|
||||
print(" ### new_lines_data = ", new_lines_data)
|
||||
|
||||
RetObject = {}
|
||||
RetObject['header_data'] = mycommon.JSONEncoder().encode(header_data)
|
||||
RetObject['lines_data'] = mycommon.JSONEncoder().encode(lines_data)
|
||||
RetObject['lines_data'] = mycommon.JSONEncoder().encode(new_lines_data)
|
||||
|
||||
return True, RetObject
|
||||
|
||||
|
@ -667,4 +641,109 @@ def Get_Given_Sequence_Planning_Model_With_Option(diction):
|
|||
return False, " Impossible de récuperer le modèle de planning "
|
||||
|
||||
|
||||
"""
|
||||
Cette fonction permet d'appliquer un nouveau planning à une session apres avoir
|
||||
choisir un planning modele
|
||||
"""
|
||||
def Apply_Planning_Model_To_Session(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token','session_id', 'tab_sequence_modele']
|
||||
|
||||
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','session_id', 'tab_sequence_modele']
|
||||
|
||||
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
|
||||
|
||||
|
||||
tab_sequence_modele = diction['tab_sequence_modele']
|
||||
tab_sequence_modele_JSON = ast.literal_eval(tab_sequence_modele)
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Suppression de la planification existant de cette session s'il en existe
|
||||
1 - Suppression dans "session_formation_sequence_affectation"
|
||||
2 - Suppression dans "session_formation_sequence"
|
||||
"""
|
||||
for tmp in MYSY_GV.dbname['session_formation_sequence'].find({'session_id':str(diction['session_id']),
|
||||
'partner_owner_recid':str(my_partner['recid'])}):
|
||||
MYSY_GV.dbname['session_formation_sequence_affectation'].delete_many({'sequence_session_id':str(tmp['_id']),
|
||||
'partner_owner_recid':str(my_partner['recid'])})
|
||||
|
||||
|
||||
deleted_data = MYSY_GV.dbname['session_formation_sequence'].delete_many({'session_id':str(diction['session_id']),
|
||||
'partner_owner_recid':str(my_partner['recid'])})
|
||||
|
||||
|
||||
#print(" ### deleted_data.deleted_count = ", deleted_data.deleted_count )
|
||||
|
||||
|
||||
"""
|
||||
Enregistrement du nouveau planning
|
||||
"""
|
||||
for new_sequence in tab_sequence_modele_JSON:
|
||||
|
||||
local_start = str(new_sequence['start'])
|
||||
local_start_datetime = datetime.strptime(local_start, "%Y-%m-%dT%H:%M:%S.%fZ")
|
||||
local_start_datetime_str = str(local_start_datetime.strftime('%d/%m/%Y %H:%M'))
|
||||
|
||||
local_end = str(new_sequence['start'])
|
||||
local_end_datetime = datetime.strptime(local_end, "%Y-%m-%dT%H:%M:%S.%fZ")
|
||||
local_end_datetime_str = str(local_end_datetime.strftime('%m/%d/%Y %H:%M'))
|
||||
|
||||
|
||||
|
||||
local_node = {}
|
||||
|
||||
local_node['session_id'] = str(diction['session_id'])
|
||||
local_node['sequence_title'] = str(new_sequence['title'])
|
||||
local_node['sequence_start'] = str(local_start_datetime_str)
|
||||
local_node['sequence_end'] = str(local_end_datetime_str)
|
||||
local_node['agenda'] = str(new_sequence['local_agenda'])
|
||||
local_node['objectif'] = str(new_sequence['local_objectif'])
|
||||
local_node['commentaire'] = str(new_sequence['local_comment'])
|
||||
local_node['valide'] = "1"
|
||||
local_node['locked'] = "0"
|
||||
local_node['partner_owner_recid'] = str(my_partner['recid'])
|
||||
local_node['update_by'] = str(my_partner['_id'])
|
||||
|
||||
MYSY_GV.dbname['session_formation_sequence'].insert_one(local_node)
|
||||
|
||||
|
||||
return True, " Le planning a été correctement appliqué"
|
||||
|
||||
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'appliquer le planning "
|
||||
|
|
Loading…
Reference in New Issue