11/11/2023 - 17h
parent
0b16aea7d4
commit
ededcbcf32
|
@ -1,10 +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="09/11/2023 - 23h">
|
||||
<change afterPath="$PROJECT_DIR$/agenda.py" afterDir="false" />
|
||||
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="sdds">
|
||||
<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$/agenda.py" beforeDir="false" afterPath="$PROJECT_DIR$/agenda.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" />
|
||||
|
@ -75,13 +76,6 @@
|
|||
<option name="presentableId" value="Default" />
|
||||
<updated>1680804787304</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00093" summary="01/09/23 - 19h">
|
||||
<created>1693586455361</created>
|
||||
<option name="number" value="00093" />
|
||||
<option name="presentableId" value="LOCAL-00093" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1693586455361</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00094" summary="04/09/23 - 20h">
|
||||
<created>1693853116601</created>
|
||||
<option name="number" value="00094" />
|
||||
|
@ -418,7 +412,14 @@
|
|||
<option name="project" value="LOCAL" />
|
||||
<updated>1699567383855</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="142" />
|
||||
<task id="LOCAL-00142" summary="sdds">
|
||||
<created>1699654387810</created>
|
||||
<option name="number" value="00142" />
|
||||
<option name="presentableId" value="LOCAL-00142" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1699654387811</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="143" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="Vcs.Log.Tabs.Properties">
|
||||
|
@ -433,7 +434,6 @@
|
|||
</option>
|
||||
</component>
|
||||
<component name="VcsManagerConfiguration">
|
||||
<MESSAGE value="28/09/23 - 23h" />
|
||||
<MESSAGE value="30/09/2023 - 14h" />
|
||||
<MESSAGE value="30/09/2023 - 18h" />
|
||||
<MESSAGE value="30/09/2023 - 19h" />
|
||||
|
@ -458,6 +458,7 @@
|
|||
<MESSAGE value="30/10/23 - 16h" />
|
||||
<MESSAGE value="08/11/2023 - 23h" />
|
||||
<MESSAGE value="09/11/2023 - 23h" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="09/11/2023 - 23h" />
|
||||
<MESSAGE value="sdds" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="sdds" />
|
||||
</component>
|
||||
</project>
|
|
@ -521,4 +521,15 @@ Pour la personnalisation des champ, seuls certains objet metier / collection
|
|||
sont autorisés
|
||||
"""
|
||||
PERSONALISATION_AUTORIZED_COLLECTION = ['ressource_humaine', 'ressource_materielle', 'partner_client',
|
||||
'myclass', 'session_formation', 'inscription']
|
||||
'myclass', 'session_formation', 'inscription']
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Les objets metiers qui accepte d'etre lié à un agenda.
|
||||
Par defaut il en y a 2 :
|
||||
- ressource_humaine et
|
||||
- ressource_materielle
|
||||
"""
|
||||
ALLOWED_AGENDA_RELATED_COLLECTION = ['ressource_humaine', 'ressource_materielle']
|
||||
|
||||
|
|
1402
Log/log_file.log
1402
Log/log_file.log
File diff suppressed because it is too large
Load Diff
200
agenda.py
200
agenda.py
|
@ -40,6 +40,122 @@ from email import encoders
|
|||
|
||||
|
||||
|
||||
"""
|
||||
Cette fonction ajoute ou met à jour un eventement de l'agenda
|
||||
"""
|
||||
def Add_Update_Agenda_Event(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', '_id', 'related_collection', 'event_title', 'event_start', 'event_end', 'related_collection_recid', 'comment']
|
||||
|
||||
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', '_id', 'related_collection', 'event_title', 'event_start', 'event_end', 'related_collection_recid',]
|
||||
|
||||
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'existance et de l'acceptation d'un evement pour le 'related_collection'
|
||||
if( diction['related_collection'] not in MYSY_GV.ALLOWED_AGENDA_RELATED_COLLECTION):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " - L'objet metier "+str(diction['related_collection'] )+" n'accepte pas de planning")
|
||||
return False, " L'objet metier "+str(diction['related_collection'] )+" n'accepte pas de planning "
|
||||
|
||||
|
||||
# Verifier que 'related_collection_recid' existe et est valide dans la collection 'related_collection'
|
||||
is_existe_valide_related_collection_recid = MYSY_GV.dbname[str(diction['related_collection'])].count_documents({'_id':ObjectId(str(diction['related_collection_recid'])),
|
||||
'partner_recid':str(my_partner['recid']),
|
||||
'valide':'1',
|
||||
'locked':'0'})
|
||||
|
||||
if( is_existe_valide_related_collection_recid <= 0):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " - L'identifiant du 'related_collection_recid' n'est pas valide ")
|
||||
return False, " L'identifiant du 'related_collection_recid' n'est pas valide "
|
||||
|
||||
|
||||
mydata = {}
|
||||
mydata['related_collection'] = str(diction['related_collection'])
|
||||
mydata['related_collection_recid'] = str(diction['related_collection_recid'])
|
||||
mydata['event_title'] = str(diction['event_title'])
|
||||
mydata['event_start'] = str(diction['event_start'])
|
||||
mydata['event_end'] = str(diction['event_end'])
|
||||
|
||||
comment = ""
|
||||
if( "comment" in diction.keys()):
|
||||
comment = str(diction['comment'])
|
||||
mydata['comment'] = comment
|
||||
|
||||
|
||||
if( len(str(diction['_id']).strip()) > 0):
|
||||
# Verifier si l'id de l'evenement existe
|
||||
is_event_exist = MYSY_GV.dbname['agenda'].count_documents({'_id':ObjectId(str(diction['_id'])),
|
||||
'partner_owner_recid':str(my_partner['recid']),
|
||||
'valide':'1',
|
||||
'locked':'0'})
|
||||
|
||||
if( is_event_exist > 0 ):
|
||||
# L'eventement existe est valide, on autorise la mise à jour
|
||||
mydata['date_update'] = str(datetime.now())
|
||||
update = MYSY_GV.dbname['agenda'].update_one({'_id':ObjectId(str(diction['_id'])),
|
||||
'partner_owner_recid':str(my_partner['recid']),
|
||||
'valide':'1',
|
||||
'locked':'0'},
|
||||
{'$set':mydata}
|
||||
)
|
||||
|
||||
return True, " L'événement a été mis à jour"
|
||||
|
||||
else:
|
||||
# L'identifiant fournit est invalide, on refuse la mise à jour
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " - L'identifiant de l'événement n'est pas valide ")
|
||||
return False, " L'identifiant de l'événement n'est pas valide "
|
||||
|
||||
else:
|
||||
# Il s'agit de la creation d'un evenement.
|
||||
mydata['partner_owner_recid'] = str(my_partner['recid'])
|
||||
mydata['valide'] = "1"
|
||||
mydata['locked'] = "0"
|
||||
|
||||
insert = MYSY_GV.dbname['agenda'].insert_one(mydata)
|
||||
return True, " L'événement a été ajouté"
|
||||
|
||||
|
||||
|
||||
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 ou mettre à jour l'événement "
|
||||
|
||||
|
||||
"""
|
||||
Recuperation de la liste des agenda (draft)
|
||||
|
@ -51,7 +167,7 @@ def get_Agenda_Event_List(diction):
|
|||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', ]
|
||||
field_list = ['token', 'related_collection', 'related_collection_recid']
|
||||
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
|
@ -63,7 +179,7 @@ def get_Agenda_Event_List(diction):
|
|||
"""
|
||||
Verification des champs obligatoires
|
||||
"""
|
||||
field_list_obligatoire = ['token', ]
|
||||
field_list_obligatoire = ['token', 'related_collection', 'related_collection_recid']
|
||||
for val in field_list_obligatoire:
|
||||
if val not in diction:
|
||||
mycommon.myprint(
|
||||
|
@ -85,7 +201,8 @@ def get_Agenda_Event_List(diction):
|
|||
|
||||
RetObject = []
|
||||
val_tmp = 1
|
||||
for New_retVal in MYSY_GV.dbname['agenda'].find({'partner_owner_recid':str(my_partner['recid']), 'valide':'1', 'locked':'0'}):
|
||||
for New_retVal in MYSY_GV.dbname['agenda'].find({'related_collection':str(diction['related_collection']), 'related_collection_recid':str(diction['related_collection_recid']),
|
||||
'partner_owner_recid':str(my_partner['recid']), 'valide':'1', 'locked':'0'}):
|
||||
|
||||
user = New_retVal
|
||||
user['id'] = str(val_tmp)
|
||||
|
@ -99,3 +216,80 @@ def get_Agenda_Event_List(diction):
|
|||
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - Line : " + str(exc_tb.tb_lineno))
|
||||
return False, " Impossible de récupérer la liste des evenement "
|
||||
|
||||
|
||||
"""
|
||||
Cette fonction supprime un evenement
|
||||
"""
|
||||
def Delete_Agenda_Event(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', '_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"
|
||||
|
||||
"""
|
||||
Verification des champs obligatoires
|
||||
"""
|
||||
field_list_obligatoire = ['token', '_id', ]
|
||||
|
||||
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
|
||||
|
||||
|
||||
|
||||
|
||||
# Verifier si l'id de l'evenement existe
|
||||
is_event_exist = MYSY_GV.dbname['agenda'].count_documents({'_id':ObjectId(str(diction['_id'])),
|
||||
'partner_owner_recid':str(my_partner['recid']),
|
||||
'valide':'1',
|
||||
'locked':'0'})
|
||||
|
||||
if( is_event_exist > 0 ):
|
||||
# L'eventement existe est valide, on autorise la suppression
|
||||
update = MYSY_GV.dbname['agenda'].delete_one({'_id':ObjectId(str(diction['_id'])),
|
||||
'partner_owner_recid':str(my_partner['recid']),
|
||||
'valide':'1',
|
||||
'locked':'0'},
|
||||
|
||||
)
|
||||
|
||||
return True, " L'événement a été supprimé"
|
||||
|
||||
else:
|
||||
# L'identifiant fournit est invalide, on refuse la mise à jour
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " - L'identifiant de l'événement n'est pas valide ")
|
||||
return False, " L'identifiant de l'événement n'est pas valide "
|
||||
|
||||
|
||||
|
||||
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 ou mettre à jour l'événement "
|
||||
|
||||
|
|
50
main.py
50
main.py
|
@ -5304,17 +5304,7 @@ def get_list_specific_field_partner_by_object():
|
|||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
"""
|
||||
API de la recuperation de la liste des evenement dans l'agenda (draft)
|
||||
"""
|
||||
@app.route('/myclass/api/get_Agenda_Event_List/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def get_Agenda_Event_List():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### get_Agenda_Event_List : payload = ",payload)
|
||||
status, retval = agenda.get_Agenda_Event_List(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
"""
|
||||
Cette API retourne la liste des objet metier eligibles
|
||||
|
@ -5330,6 +5320,44 @@ def Get_Collection_Eligible_Champ_Specific():
|
|||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
"""
|
||||
API de la recuperation de la liste des evenement dans l'agenda (draft)
|
||||
"""
|
||||
@app.route('/myclass/api/get_Agenda_Event_List/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def get_Agenda_Event_List():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### get_Agenda_Event_List : payload = ",payload)
|
||||
status, retval = agenda.get_Agenda_Event_List(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
"""
|
||||
API d'ajout ou mise à jour d'un evenement
|
||||
"""
|
||||
@app.route('/myclass/api/Add_Update_Agenda_Event/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Add_Update_Agenda_Event():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Add_Update_Agenda_Event : payload = ",payload)
|
||||
status, retval = agenda.Add_Update_Agenda_Event(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
""" API de suppression d'un evenement dans un agenda
|
||||
"""
|
||||
@app.route('/myclass/api/Delete_Agenda_Event/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Delete_Agenda_Event():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Delete_Agenda_Event : payload = ",payload)
|
||||
status, retval = agenda.Delete_Agenda_Event(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
print(" debut api")
|
||||
|
|
Loading…
Reference in New Issue