05/05/2024 - 13h30
parent
ecb28d720d
commit
ed71a0b865
|
@ -1,10 +1,9 @@
|
|||
<?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="vvvv">
|
||||
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="04/05/2024 - 20h30">
|
||||
<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$/Session_Formation_Sequence.py" beforeDir="false" afterPath="$PROJECT_DIR$/Session_Formation_Sequence.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
|
||||
</list>
|
||||
|
@ -76,13 +75,6 @@
|
|||
<option name="presentableId" value="Default" />
|
||||
<updated>1680804787304</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00235" summary="04/03/2024 - 22h15">
|
||||
<created>1709587020472</created>
|
||||
<option name="number" value="00235" />
|
||||
<option name="presentableId" value="LOCAL-00235" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1709587020474</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00236" summary="06/03/2024 - 22h15">
|
||||
<created>1709759516683</created>
|
||||
<option name="number" value="00236" />
|
||||
|
@ -419,7 +411,14 @@
|
|||
<option name="project" value="LOCAL" />
|
||||
<updated>1714823572226</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="284" />
|
||||
<task id="LOCAL-00284" summary="04/05/2024 - 20h30">
|
||||
<created>1714847858090</created>
|
||||
<option name="number" value="00284" />
|
||||
<option name="presentableId" value="LOCAL-00284" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1714847858091</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="285" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="Vcs.Log.Tabs.Properties">
|
||||
|
@ -461,7 +460,6 @@
|
|||
</option>
|
||||
</component>
|
||||
<component name="VcsManagerConfiguration">
|
||||
<MESSAGE value="04/04/24 - 19h30" />
|
||||
<MESSAGE value="04/04/24 - 21h30" />
|
||||
<MESSAGE value="06/04/2024 - 21h19" />
|
||||
<MESSAGE value="07/04/2024 - 13h19" />
|
||||
|
@ -486,6 +484,7 @@
|
|||
<MESSAGE value="02/05/2024 - 22h" />
|
||||
<MESSAGE value="sss" />
|
||||
<MESSAGE value="vvvv" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="vvvv" />
|
||||
<MESSAGE value="04/05/2024 - 20h30" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="04/05/2024 - 20h30" />
|
||||
</component>
|
||||
</project>
|
3860
Log/log_file.log
3860
Log/log_file.log
File diff suppressed because it is too large
Load Diff
|
@ -516,7 +516,7 @@ def Create_Automatic_Sequence(diction):
|
|||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', 'session_id', 'jounree_modele_id', 'option' ]
|
||||
field_list = ['token', 'session_id', 'jounree_modele_id', 'option', 'ecrase_existing' ]
|
||||
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
|
@ -664,21 +664,22 @@ def Create_Automatic_Sequence(diction):
|
|||
"""
|
||||
/!\ Suppression des sequences qui existe et reservation dans les agenda par rapport à cette session
|
||||
"""
|
||||
for local_retval in MYSY_GV.dbname['session_formation_sequence'].find({'session_id': str(diction['session_id']),
|
||||
'partner_owner_recid': str(
|
||||
my_partner['recid']), }):
|
||||
deleted_data_agenda = MYSY_GV.dbname['agenda'].delete_many({'sequence_session_id': str(local_retval['_id']),
|
||||
'partner_owner_recid': str(
|
||||
my_partner['recid']), })
|
||||
if( "ecrase_existing" in diction.keys() and diction['ecrase_existing'] == "1"):
|
||||
for local_retval in MYSY_GV.dbname['session_formation_sequence'].find({'session_id': str(diction['session_id']),
|
||||
'partner_owner_recid': str(
|
||||
my_partner['recid']), }):
|
||||
deleted_data_agenda = MYSY_GV.dbname['agenda'].delete_many({'sequence_session_id': str(local_retval['_id']),
|
||||
'partner_owner_recid': str(
|
||||
my_partner['recid']), })
|
||||
|
||||
deleted_data_affectation = MYSY_GV.dbname['session_formation_sequence_affectation'].delete_many(
|
||||
{'sequence_session_id': str(local_retval['_id']),
|
||||
deleted_data_affectation = MYSY_GV.dbname['session_formation_sequence_affectation'].delete_many(
|
||||
{'sequence_session_id': str(local_retval['_id']),
|
||||
'partner_owner_recid': str(my_partner['recid']), })
|
||||
|
||||
deleted_data_sequence = MYSY_GV.dbname['session_formation_sequence'].delete_many(
|
||||
{'session_id': str(diction['session_id']),
|
||||
'partner_owner_recid': str(my_partner['recid']), })
|
||||
|
||||
deleted_data_sequence = MYSY_GV.dbname['session_formation_sequence'].delete_many(
|
||||
{'session_id': str(diction['session_id']),
|
||||
'partner_owner_recid': str(my_partner['recid']), })
|
||||
|
||||
cpt = 10
|
||||
|
||||
nb_sequence = 0
|
||||
|
@ -2120,6 +2121,13 @@ def Convert_And_ReFormat_Week_Type(semaine_tab_event):
|
|||
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - Line : " + str(exc_tb.tb_lineno))
|
||||
return False, " Impossible de reformater la semaine type "
|
||||
|
||||
|
||||
"""
|
||||
Cette fonction permet de créer les planification à la semaine.
|
||||
|
||||
mais avant tout traitement, un reformatage est necessaure
|
||||
avec la fontion : Convert_And_ReFormat_Week_Type
|
||||
"""
|
||||
def Create_Automatic_Sequence_From_Week_Model(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
@ -2127,7 +2135,7 @@ def Create_Automatic_Sequence_From_Week_Model(diction):
|
|||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', 'session_id', 'date_debut', 'date_fin', "semaine_tab_event"]
|
||||
field_list = ['token', 'session_id', 'planif_date_debut', 'planif_date_fin', "semaine_tab_event", "ecrase_existing"]
|
||||
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
|
@ -2139,7 +2147,7 @@ def Create_Automatic_Sequence_From_Week_Model(diction):
|
|||
"""
|
||||
Verification des champs obligatoires
|
||||
"""
|
||||
field_list_obligatoire = ['token', 'session_id', 'date_debut', 'date_fin', 'semaine_tab_event']
|
||||
field_list_obligatoire = ['token', 'session_id', 'planif_date_debut', 'planif_date_fin', 'semaine_tab_event']
|
||||
|
||||
for val in field_list_obligatoire:
|
||||
if val not in diction:
|
||||
|
@ -2173,8 +2181,17 @@ def Create_Automatic_Sequence_From_Week_Model(diction):
|
|||
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 "
|
||||
|
||||
is_existe_valide_session_data = MYSY_GV.dbname["session_formation"].find_one(
|
||||
{'_id': ObjectId(str(diction['session_id'])),
|
||||
'partner_owner_recid': str(my_partner['recid']),
|
||||
'valide': '1'})
|
||||
|
||||
date_session_debut = str(is_existe_valide_session_data['date_debut'])[0:10]
|
||||
date_session_fin = str(is_existe_valide_session_data['date_fin'])[0:10]
|
||||
|
||||
|
||||
# Controle de cohérence sur les dates
|
||||
local_status = mycommon.CheckisDate(str(diction['date_debut'])[0:10])
|
||||
local_status = mycommon.CheckisDate(str(diction['planif_date_debut'])[0:10])
|
||||
if (local_status is False):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
|
@ -2182,7 +2199,7 @@ def Create_Automatic_Sequence_From_Week_Model(diction):
|
|||
|
||||
return False, " La date de debut n'est pas au format jj/mm/aaaa "
|
||||
|
||||
local_status = mycommon.CheckisDate(str(diction['date_fin'])[0:10])
|
||||
local_status = mycommon.CheckisDate(str(diction['planif_date_fin'])[0:10])
|
||||
if (local_status is False):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
|
@ -2191,16 +2208,16 @@ def Create_Automatic_Sequence_From_Week_Model(diction):
|
|||
return False, "La date de fin n'est pas au format jj/mm/aaaa "
|
||||
|
||||
|
||||
if (datetime.strptime(str(diction['date_debut'])[0:10], '%d/%m/%Y') > datetime.strptime(
|
||||
str(diction['date_fin'])[0:10], '%d/%m/%Y')):
|
||||
if (datetime.strptime(str(diction['planif_date_debut'])[0:10], '%d/%m/%Y') > datetime.strptime(
|
||||
str(diction['planif_date_fin'])[0:10], '%d/%m/%Y')):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " La date debut " + str(
|
||||
diction['date_debut'])[0:10] +
|
||||
" est postérieure à la date de fin " + str(diction['date_fin'])[0:10])
|
||||
diction['planif_date_debut'])[0:10] +
|
||||
" est postérieure à la date de fin " + str(diction['planif_date_fin'])[0:10])
|
||||
|
||||
return False, " La date debut de formation " + str(diction['date_debut'])[0:10] + \
|
||||
" est postérieure à la date de fin de formation " + str(diction['date_fin'])[0:10] + " "
|
||||
return False, " La date debut de formation " + str(diction['planif_date_debut'])[0:10] + \
|
||||
" est postérieure à la date de fin de formation " + str(diction['planif_date_fin'])[0:10] + " "
|
||||
|
||||
semaine_tab_event = diction['semaine_tab_event']
|
||||
|
||||
|
@ -2215,21 +2232,40 @@ def Create_Automatic_Sequence_From_Week_Model(diction):
|
|||
|
||||
formated_semaine_tab_event = local_retval
|
||||
|
||||
date_debut_session = datetime.strptime(str(diction['date_debut'])[0:10], '%d/%m/%Y')
|
||||
date_fin_session = datetime.strptime(str(diction['date_fin'])[0:10], '%d/%m/%Y')
|
||||
date_debut_periode_planif = datetime.strptime(str(diction['planif_date_debut'])[0:10], '%d/%m/%Y')
|
||||
date_fin_periode_planif = datetime.strptime(str(diction['planif_date_fin'])[0:10], '%d/%m/%Y')
|
||||
|
||||
"""
|
||||
/!\ Suppression des sequences qui existe et reservation dans les agenda par rapport à cette session
|
||||
si l'option est activée
|
||||
"""
|
||||
if( "ecrase_existing" in diction.keys() and diction['ecrase_existing'] == "1"):
|
||||
for local_retval in MYSY_GV.dbname['session_formation_sequence'].find(
|
||||
{'session_id': str(diction['session_id']),
|
||||
'partner_owner_recid': str(
|
||||
my_partner['recid']), }):
|
||||
deleted_data_agenda = MYSY_GV.dbname['agenda'].delete_many(
|
||||
{'sequence_session_id': str(local_retval['_id']),
|
||||
'partner_owner_recid': str(
|
||||
my_partner['recid']), })
|
||||
|
||||
cpt = 10
|
||||
deleted_data_affectation = MYSY_GV.dbname['session_formation_sequence_affectation'].delete_many(
|
||||
{'sequence_session_id': str(local_retval['_id']),
|
||||
'partner_owner_recid': str(my_partner['recid']), })
|
||||
|
||||
deleted_data_sequence = MYSY_GV.dbname['session_formation_sequence'].delete_many(
|
||||
{'session_id': str(diction['session_id']),
|
||||
'partner_owner_recid': str(my_partner['recid']), })
|
||||
|
||||
cpt = 0
|
||||
|
||||
nb_sequence = 0
|
||||
|
||||
print(" date_debut = ", str(diction['date_debut'])[0:10])
|
||||
|
||||
print(" date_fin = ", str(diction['date_fin'])[0:10])
|
||||
|
||||
for single_date in mycommon.daterange(date_debut_session, date_fin_session):
|
||||
print(single_date.strftime("%Y-%m-%d"))
|
||||
print(single_date.strftime("%A"))
|
||||
for single_date in mycommon.daterange(date_debut_periode_planif, date_fin_periode_planif):
|
||||
#print(single_date.strftime("%Y-%m-%d"))
|
||||
#print(single_date.strftime("%A"))
|
||||
|
||||
"""
|
||||
Recuperation des events associé à ce jour
|
||||
|
@ -2240,9 +2276,9 @@ def Create_Automatic_Sequence_From_Week_Model(diction):
|
|||
if( "day_week" in local_tmp.keys() and local_tmp['day_week'] == local_day ):
|
||||
tab_events = local_tmp['tab_event']
|
||||
|
||||
print(" Pour le jour : ", local_day)
|
||||
#print(" Pour le jour : ", local_day)
|
||||
|
||||
print(" TAB EVENT = ", tab_events)
|
||||
#print(" TAB EVENT = ", tab_events)
|
||||
for local_event in tab_events :
|
||||
|
||||
local_start_date = datetime.strptime(str(local_event['start']), "%Y-%m-%d %H:%M:%S")
|
||||
|
@ -2266,11 +2302,11 @@ def Create_Automatic_Sequence_From_Week_Model(diction):
|
|||
sequence_data['sequence_end'] = str(single_date.strftime("%d/%m/%Y")) + " " + str(local_end_hour).strip()
|
||||
|
||||
|
||||
print(" #### sequence_data = ", sequence_data)
|
||||
#print(" #### sequence_data = ", sequence_data)
|
||||
|
||||
local_status, local_event = Add_Session_Sequence(sequence_data)
|
||||
|
||||
print(" ### OK ")
|
||||
#print(" ### OK ")
|
||||
|
||||
if (local_status is False):
|
||||
mycommon.myprint(
|
||||
|
@ -2287,3 +2323,350 @@ def Create_Automatic_Sequence_From_Week_Model(diction):
|
|||
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 dupliquer la semaine "
|
||||
|
||||
|
||||
"""
|
||||
Cette fonction permet de dupliquer une semaine type
|
||||
de date_debut à date_fin.
|
||||
|
||||
le champ : 'semaine_tab_event' contient la semaine type et est de forme :
|
||||
[
|
||||
{
|
||||
"id": "1714820379044",
|
||||
"title": "Nouvelle",
|
||||
"start": "2024-05-02 11:00:00",
|
||||
"end": "2024-05-02 12:30:00",
|
||||
"agenda": "ddd",
|
||||
"objectif": "ff",
|
||||
"comment": "sdfds",
|
||||
"day_week": "Thursday"
|
||||
},
|
||||
{
|
||||
"id": "1714820397818",
|
||||
"title": "Nouvelle",
|
||||
"start": "2024-04-30 14:30:00",
|
||||
"end": "2024-04-30 16:00:00",
|
||||
"agenda": "ddfd",
|
||||
"objectif": "fff",
|
||||
"comment": "qqsdsq",
|
||||
"day_week": "Tuesday"
|
||||
},
|
||||
{
|
||||
"id": "1714831959464",
|
||||
"title": "Nouvelle",
|
||||
"start": "2024-05-03 09:00:00",
|
||||
"end": "2024-05-03 11:00:00",
|
||||
"agenda": "",
|
||||
"objectif": "",
|
||||
"comment": "",
|
||||
"day_week": "Friday"
|
||||
},
|
||||
{
|
||||
"id": "1714831968489",
|
||||
"title": "Nouvelle",
|
||||
"start": "2024-05-04 08:30:00",
|
||||
"end": "2024-05-04 12:00:00",
|
||||
"agenda": "",
|
||||
"objectif": "",
|
||||
"comment": "",
|
||||
"day_week": "Saturday"
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
il faut dans une premier tmps reordonnée la liste des events comme suit :
|
||||
[
|
||||
{
|
||||
"day_month": "1",
|
||||
"tab_event" : [ { "id": "1714820379044",
|
||||
"title": "Nouvelle",
|
||||
"start": "2024-05-02 11:00:00",
|
||||
"end": "2024-05-02 12:30:00",
|
||||
"agenda": "ddd",
|
||||
"objectif": "ff",
|
||||
"comment": "sdfds"
|
||||
},
|
||||
{ "id": "1714831959464",
|
||||
"title": "Nouvelle",
|
||||
"start": "2024-05-03 09:00:00",
|
||||
"end": "2024-05-03 11:00:00",
|
||||
"agenda": "",
|
||||
"objectif": "",
|
||||
"comment": "",
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"day_week": "2",
|
||||
"tab_event" : [ { "id": "1714820379044",
|
||||
"title": "Nouvelle",
|
||||
"start": "2024-05-02 11:00:00",
|
||||
"end": "2024-05-02 12:30:00",
|
||||
"agenda": "ddd",
|
||||
"objectif": "ff",
|
||||
"comment": "sdfds"
|
||||
},
|
||||
{ "id": "1714831959464",
|
||||
"title": "Nouvelle",
|
||||
"start": "2024-05-03 09:00:00",
|
||||
"end": "2024-05-03 11:00:00",
|
||||
"agenda": "",
|
||||
"objectif": "",
|
||||
"comment": "",
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
"""
|
||||
|
||||
def Convert_And_ReFormat_Month_Type(month_tab_event):
|
||||
try:
|
||||
|
||||
Formated_Month = []
|
||||
|
||||
for tmp in month_tab_event:
|
||||
print(" inside month : ", tmp )
|
||||
|
||||
local_node = {}
|
||||
local_node['id'] = tmp['id']
|
||||
local_node['title'] = tmp['title']
|
||||
local_node['start'] = tmp['start']
|
||||
local_node['end'] = tmp['end']
|
||||
local_node['agenda'] = tmp['agenda']
|
||||
local_node['objectif'] = tmp['objectif']
|
||||
local_node['comment'] = tmp['comment']
|
||||
|
||||
local_start_date = datetime.strptime(str(tmp['start']), "%Y-%m-%d %H:%M:%S")
|
||||
local_start_day = local_start_date.strftime("%d")
|
||||
|
||||
print(" ### Traitement du jour du mois = ", local_start_day)
|
||||
|
||||
day_in_Formated_Month = 0
|
||||
|
||||
for exist_data in Formated_Month :
|
||||
if( "day_month" in exist_data.keys() and exist_data["day_month"] == local_start_day ):
|
||||
exist_data["tab_event"].append(local_node)
|
||||
day_in_Formated_Month = 1
|
||||
|
||||
if( day_in_Formated_Month == 0 ):
|
||||
new_node = {}
|
||||
new_node['day_month'] = local_start_day
|
||||
new_node['tab_event'] = []
|
||||
new_node['tab_event'].append(local_node)
|
||||
|
||||
Formated_Month.append(new_node)
|
||||
|
||||
|
||||
return True, Formated_Month
|
||||
|
||||
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 reformater le mois type type "
|
||||
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Cette fonction permet de créer les planification au mois.
|
||||
|
||||
mais avant tout traitement, un reformatage est necessaure
|
||||
avec la fontion (MOIS) : Convert_And_ReFormat_Month_Type
|
||||
"""
|
||||
def Create_Automatic_Sequence_From_Month_Model(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', 'session_id', 'planif_date_debut', 'planif_date_fin', "semaine_tab_event", "ecrase_existing"]
|
||||
|
||||
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', 'planif_date_debut', 'planif_date_fin', 'semaine_tab_event']
|
||||
|
||||
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
|
||||
|
||||
# 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 "
|
||||
|
||||
is_existe_valide_session_data = MYSY_GV.dbname["session_formation"].find_one(
|
||||
{'_id': ObjectId(str(diction['session_id'])),
|
||||
'partner_owner_recid': str(my_partner['recid']),
|
||||
'valide': '1'})
|
||||
|
||||
date_session_debut = str(is_existe_valide_session_data['date_debut'])[0:10]
|
||||
date_session_fin = str(is_existe_valide_session_data['date_fin'])[0:10]
|
||||
|
||||
|
||||
# Controle de cohérence sur les dates
|
||||
local_status = mycommon.CheckisDate(str(diction['planif_date_debut'])[0:10])
|
||||
if (local_status is False):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " La date de debut n'est pas au format jj/mm/aaaa ")
|
||||
|
||||
return False, " La date de debut n'est pas au format jj/mm/aaaa "
|
||||
|
||||
local_status = mycommon.CheckisDate(str(diction['planif_date_fin'])[0:10])
|
||||
if (local_status is False):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " La date de fin n'est pas au format jj/mm/aaaa ")
|
||||
|
||||
return False, "La date de fin n'est pas au format jj/mm/aaaa "
|
||||
|
||||
|
||||
if (datetime.strptime(str(diction['planif_date_debut'])[0:10], '%d/%m/%Y') > datetime.strptime(
|
||||
str(diction['planif_date_fin'])[0:10], '%d/%m/%Y')):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " La date debut " + str(
|
||||
diction['planif_date_debut'])[0:10] +
|
||||
" est postérieure à la date de fin " + str(diction['planif_date_fin'])[0:10])
|
||||
|
||||
return False, " La date debut de formation " + str(diction['planif_date_debut'])[0:10] + \
|
||||
" est postérieure à la date de fin de formation " + str(diction['planif_date_fin'])[0:10] + " "
|
||||
|
||||
semaine_tab_event = diction['semaine_tab_event']
|
||||
|
||||
|
||||
semaine_tab_event_JSON = ast.literal_eval(semaine_tab_event)
|
||||
|
||||
|
||||
local_status, local_retval = Convert_And_ReFormat_Month_Type(semaine_tab_event_JSON)
|
||||
if( local_status is False):
|
||||
return local_status, local_retval
|
||||
|
||||
|
||||
formated_mois_tab_event = local_retval
|
||||
|
||||
print(" ### formated_mois_tab_event = ", formated_mois_tab_event)
|
||||
|
||||
date_debut_periode_planif = datetime.strptime(str(diction['planif_date_debut'])[0:10], '%d/%m/%Y')
|
||||
date_fin_periode_planif = datetime.strptime(str(diction['planif_date_fin'])[0:10], '%d/%m/%Y')
|
||||
|
||||
"""
|
||||
/!\ Suppression des sequences qui existe et reservation dans les agenda par rapport à cette session
|
||||
si l'option est activée
|
||||
"""
|
||||
if( "ecrase_existing" in diction.keys() and diction['ecrase_existing'] == "1"):
|
||||
for local_retval in MYSY_GV.dbname['session_formation_sequence'].find(
|
||||
{'session_id': str(diction['session_id']),
|
||||
'partner_owner_recid': str(
|
||||
my_partner['recid']), }):
|
||||
deleted_data_agenda = MYSY_GV.dbname['agenda'].delete_many(
|
||||
{'sequence_session_id': str(local_retval['_id']),
|
||||
'partner_owner_recid': str(
|
||||
my_partner['recid']), })
|
||||
|
||||
deleted_data_affectation = MYSY_GV.dbname['session_formation_sequence_affectation'].delete_many(
|
||||
{'sequence_session_id': str(local_retval['_id']),
|
||||
'partner_owner_recid': str(my_partner['recid']), })
|
||||
|
||||
deleted_data_sequence = MYSY_GV.dbname['session_formation_sequence'].delete_many(
|
||||
{'session_id': str(diction['session_id']),
|
||||
'partner_owner_recid': str(my_partner['recid']), })
|
||||
|
||||
cpt = 0
|
||||
|
||||
nb_sequence = 0
|
||||
|
||||
|
||||
|
||||
for single_date in mycommon.daterange(date_debut_periode_planif, date_fin_periode_planif):
|
||||
#print(single_date.strftime("%Y-%m-%d"))
|
||||
#print(single_date.strftime("%A"))
|
||||
|
||||
"""
|
||||
Recuperation des events associé à ce jour
|
||||
"""
|
||||
local_day = single_date.strftime("%d")
|
||||
tab_events = []
|
||||
for local_tmp in formated_mois_tab_event:
|
||||
if( "day_month" in local_tmp.keys() and local_tmp['day_month'] == local_day ):
|
||||
tab_events = local_tmp['tab_event']
|
||||
|
||||
#print(" TAB EVENT = ", tab_events)
|
||||
for local_event in tab_events :
|
||||
|
||||
local_start_date = datetime.strptime(str(local_event['start']), "%Y-%m-%d %H:%M:%S")
|
||||
local_start_hour = local_start_date.strftime("%H:%M")
|
||||
|
||||
local_end_date = datetime.strptime(str(local_event['end']), "%Y-%m-%d %H:%M:%S")
|
||||
local_end_hour = local_end_date.strftime("%H:%M")
|
||||
|
||||
sequence_data = {}
|
||||
sequence_data['token'] = diction['token']
|
||||
sequence_data['session_id'] = diction['session_id']
|
||||
sequence_data['sequence_title'] = local_event['title']
|
||||
|
||||
sequence_data['agenda'] = local_event['agenda']
|
||||
sequence_data['objectif'] = local_event['objectif']
|
||||
sequence_data['commentaire'] = local_event['comment']
|
||||
|
||||
sequence_data['check_chevauchement'] = "0"
|
||||
|
||||
sequence_data['sequence_start'] = str(single_date.strftime("%d/%m/%Y")) + " " + str( local_start_hour).strip()
|
||||
sequence_data['sequence_end'] = str(single_date.strftime("%d/%m/%Y")) + " " + str(local_end_hour).strip()
|
||||
|
||||
|
||||
#print(" #### sequence_data = ", sequence_data)
|
||||
|
||||
local_status, local_event = Add_Session_Sequence(sequence_data)
|
||||
|
||||
#print(" ### OK ")
|
||||
|
||||
if (local_status is False):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " WARNING : " + str(local_event))
|
||||
else:
|
||||
nb_sequence = nb_sequence + 1
|
||||
|
||||
cpt = cpt + 1
|
||||
|
||||
|
||||
return True, str(nb_sequence) + " séquence(s) automatiquement créée(s) "
|
||||
|
||||
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 dupliquer le mois "
|
||||
|
||||
|
|
15
main.py
15
main.py
|
@ -8761,7 +8761,6 @@ def Get_Givent_Unite_Enseignement_Data_Of_Given_Class():
|
|||
|
||||
|
||||
|
||||
|
||||
"""
|
||||
API Pour créer automatiquement des sequence de session en partant d'une semaine type
|
||||
"""
|
||||
|
@ -8775,6 +8774,20 @@ def Create_Automatic_Sequence_From_Week_Model():
|
|||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
"""
|
||||
API Pour créer automatiquement des sequence de session en partant d'un MOIS type
|
||||
"""
|
||||
@app.route('/myclass/api/Create_Automatic_Sequence_From_Month_Model/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Create_Automatic_Sequence_From_Month_Model():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Create_Automatic_Sequence_From_Month_Model payload = ",payload)
|
||||
status, retval = Session_Formation_Sequence.Create_Automatic_Sequence_From_Month_Model(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
Loading…
Reference in New Issue