From 9a4549015cf70930fd21d9e76563b810f9792b26 Mon Sep 17 00:00:00 2001 From: cherif Date: Fri, 9 Feb 2024 21:59:31 +0100 Subject: [PATCH] 09/02/24 - 22h --- .idea/workspace.xml | 26 ++- Log/log_file.log | 184 ++++++++++++++++ crm_opportunite.py | 65 ++++++ main.py | 90 ++++++++ site_formation.py | 526 ++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 879 insertions(+), 12 deletions(-) create mode 100644 site_formation.py diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 877f73f..9b6412c 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -1,10 +1,12 @@ - + + - + + @@ -432,7 +434,6 @@ - @@ -457,6 +458,7 @@ - \ No newline at end of file diff --git a/Log/log_file.log b/Log/log_file.log index abc967b..5602c41 100644 --- a/Log/log_file.log +++ b/Log/log_file.log @@ -2084549,3 +2084549,187 @@ INFO:root:2024-02-08 21:24:46.011933 : Security check : IP adresse '127.0.0.1' INFO:root:2024-02-08 21:24:46.026932 : Security check : IP adresse '127.0.0.1' connected INFO:werkzeug:127.0.0.1 - - [08/Feb/2024 21:24:46] "POST /myclass/api/Get_Given_Partner_Order/ HTTP/1.1" 200 - INFO:werkzeug:127.0.0.1 - - [08/Feb/2024 21:24:46] "POST /myclass/api/Get_Given_Partner_Order_Lines/ HTTP/1.1" 200 - +INFO:root:2024-02-09 19:53:49.300815 : ++++ ENVIRONNEMENT DEVELOPPEMENT ++++ +INFO:root:2024-02-09 19:53:49.301822 : ++ DATABASE mongodb://localhost:27017/cherifdb_dev ++ +INFO:root:2024-02-09 19:53:49.301822 : ++ DBNAME Database(MongoClient(host=['localhost:27017'], document_class=dict, tz_aware=False, connect=True), 'cherifdb_dev') ++ +INFO:root:2024-02-09 19:53:49.301822 : ++ FLASK PORT 5001 ++ +INFO:root:2024-02-09 19:53:49.301822 : ++ LMS_BAS_URL mysy-training.com/ ++ +INFO:werkzeug:WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead. + * Running on http://localhost:5001 +INFO:werkzeug:Press CTRL+C to quit +INFO:werkzeug: * Restarting with stat +INFO:root:2024-02-09 19:54:00.685824 : ++++ ENVIRONNEMENT DEVELOPPEMENT ++++ +INFO:root:2024-02-09 19:54:00.685824 : ++ DATABASE mongodb://localhost:27017/cherifdb_dev ++ +INFO:root:2024-02-09 19:54:00.685824 : ++ DBNAME Database(MongoClient(host=['localhost:27017'], document_class=dict, tz_aware=False, connect=True), 'cherifdb_dev') ++ +INFO:root:2024-02-09 19:54:00.685824 : ++ FLASK PORT 5001 ++ +INFO:root:2024-02-09 19:54:00.685824 : ++ LMS_BAS_URL mysy-training.com/ ++ +WARNING:werkzeug: * Debugger is active! +INFO:werkzeug: * Debugger PIN: 877-541-979 +INFO:root:2024-02-09 19:54:16.482546 : Security check : IP adresse '127.0.0.1' connected +INFO:werkzeug:127.0.0.1 - - [09/Feb/2024 19:54:16] "POST /myclass/api/partner_login/ HTTP/1.1" 200 - +INFO:root:2024-02-09 19:54:16.849906 : Security check : IP adresse '127.0.0.1' connected +INFO:root:2024-02-09 19:54:16.858150 : Security check : IP adresse '127.0.0.1' connected +INFO:root:2024-02-09 19:54:16.861492 : Security check : IP adresse '127.0.0.1' connected +INFO:root:2024-02-09 19:54:16.866450 : Security check : IP adresse '127.0.0.1' connected +INFO:werkzeug:127.0.0.1 - - [09/Feb/2024 19:54:16] "POST /myclass/api/getRecodedImage/ HTTP/1.1" 200 - +INFO:root:2024-02-09 19:54:16.894988 : Connexion du partner recid = dbdd36f3d86a73e2bfac7b3f10f062ce1e7c22f7da37de192a OK. Mise à jour du firstconnexion et/ou lastconnexion : OK +INFO:werkzeug:127.0.0.1 - - [09/Feb/2024 19:54:16] "POST /myclass/api/get_partner_account/ HTTP/1.1" 200 - +INFO:werkzeug:127.0.0.1 - - [09/Feb/2024 19:54:16] "POST /myclass/api/LMS_Get_Partner_Data/ HTTP/1.1" 200 - +INFO:werkzeug:127.0.0.1 - - [09/Feb/2024 19:54:17] "POST /myclass/api/get_partner_class/ HTTP/1.1" 200 - +INFO:root:2024-02-09 19:54:17.062864 : Security check : IP adresse '127.0.0.1' connected +INFO:root:2024-02-09 19:54:17.066880 : Security check : IP adresse '127.0.0.1' connected +INFO:werkzeug:127.0.0.1 - - [09/Feb/2024 19:54:17] "POST /myclass/api/Get_Partner_Object_Specific_Valide_Displayed_Fields/ HTTP/1.1" 200 - +INFO:werkzeug:127.0.0.1 - - [09/Feb/2024 19:54:17] "POST /myclass/api/find_partner_class_like/ HTTP/1.1" 200 - +INFO:root:2024-02-09 19:54:26.624307 : Security check : IP adresse '127.0.0.1' connected +INFO:root:2024-02-09 19:54:26.628310 : Security check : IP adresse '127.0.0.1' connected +INFO:werkzeug:127.0.0.1 - - [09/Feb/2024 19:54:26] "POST /myclass/api/Get_List_Partner_Basic_Setup/ HTTP/1.1" 200 - +INFO:werkzeug:127.0.0.1 - - [09/Feb/2024 19:54:26] "POST /myclass/api/Get_Client_Type_List/ HTTP/1.1" 200 - +INFO:root:2024-02-09 19:54:58.147859 : Security check : IP adresse '127.0.0.1' connected +INFO:werkzeug:127.0.0.1 - - [09/Feb/2024 19:54:58] "POST /myclass/api/Get_List_Partner_session_step/ HTTP/1.1" 200 - +INFO:root:2024-02-09 19:55:46.875625 : Security check : IP adresse '127.0.0.1' connected +INFO:root:2024-02-09 19:55:46.880635 : Security check : IP adresse '127.0.0.1' connected +INFO:werkzeug:127.0.0.1 - - [09/Feb/2024 19:55:46] "POST /myclass/api/Get_List_Partner_Basic_Setup/ HTTP/1.1" 200 - +INFO:werkzeug:127.0.0.1 - - [09/Feb/2024 19:55:46] "POST /myclass/api/Get_Client_Type_List/ HTTP/1.1" 200 - +INFO:root:2024-02-09 19:57:09.047590 : Security check : IP adresse '127.0.0.1' connected +INFO:root:2024-02-09 19:57:09.051623 : Security check : IP adresse '127.0.0.1' connected +INFO:werkzeug:127.0.0.1 - - [09/Feb/2024 19:57:09] "POST /myclass/api/Get_List_Partner_Basic_Setup/ HTTP/1.1" 200 - +INFO:werkzeug:127.0.0.1 - - [09/Feb/2024 19:57:09] "POST /myclass/api/Get_Client_Type_List/ HTTP/1.1" 200 - +INFO:werkzeug: * Detected change in 'C:\\Users\\billa\\Documents\\myclass.com\\Siteweb\\Production\\Ela_back\\Back_Office\\site_formation.py', reloading +INFO:werkzeug: * Restarting with stat +INFO:root:2024-02-09 19:59:49.987110 : ++++ ENVIRONNEMENT DEVELOPPEMENT ++++ +INFO:root:2024-02-09 19:59:49.988371 : ++ DATABASE mongodb://localhost:27017/cherifdb_dev ++ +INFO:root:2024-02-09 19:59:49.988371 : ++ DBNAME Database(MongoClient(host=['localhost:27017'], document_class=dict, tz_aware=False, connect=True), 'cherifdb_dev') ++ +INFO:root:2024-02-09 19:59:49.988371 : ++ FLASK PORT 5001 ++ +INFO:root:2024-02-09 19:59:49.988371 : ++ LMS_BAS_URL mysy-training.com/ ++ +WARNING:werkzeug: * Debugger is active! +INFO:werkzeug: * Debugger PIN: 877-541-979 +INFO:werkzeug: * Detected change in 'C:\\Users\\billa\\Documents\\myclass.com\\Siteweb\\Production\\Ela_back\\Back_Office\\site_formation.py', reloading +INFO:werkzeug: * Restarting with stat +INFO:root:2024-02-09 20:06:34.215282 : ++++ ENVIRONNEMENT DEVELOPPEMENT ++++ +INFO:root:2024-02-09 20:06:34.215282 : ++ DATABASE mongodb://localhost:27017/cherifdb_dev ++ +INFO:root:2024-02-09 20:06:34.215282 : ++ DBNAME Database(MongoClient(host=['localhost:27017'], document_class=dict, tz_aware=False, connect=True), 'cherifdb_dev') ++ +INFO:root:2024-02-09 20:06:34.215282 : ++ FLASK PORT 5001 ++ +INFO:root:2024-02-09 20:06:34.215282 : ++ LMS_BAS_URL mysy-training.com/ ++ +WARNING:werkzeug: * Debugger is active! +INFO:werkzeug: * Debugger PIN: 877-541-979 +INFO:root:2024-02-09 20:57:34.693745 : Security check : IP adresse '127.0.0.1' connected +INFO:root:2024-02-09 20:57:34.696747 : Security check : IP adresse '127.0.0.1' connected +INFO:root:2024-02-09 20:57:34.700827 : Security check : IP adresse '127.0.0.1' connected +INFO:werkzeug:127.0.0.1 - - [09/Feb/2024 20:57:34] "POST /myclass/api/getRecodedImage/ HTTP/1.1" 200 - +INFO:root:2024-02-09 20:57:34.711432 : Connexion du partner recid = dbdd36f3d86a73e2bfac7b3f10f062ce1e7c22f7da37de192a OK. Mise à jour du firstconnexion et/ou lastconnexion : OK +INFO:werkzeug:127.0.0.1 - - [09/Feb/2024 20:57:34] "POST /myclass/api/get_partner_account/ HTTP/1.1" 200 - +INFO:werkzeug:127.0.0.1 - - [09/Feb/2024 20:57:34] "POST /myclass/api/LMS_Get_Partner_Data/ HTTP/1.1" 200 - +INFO:root:2024-02-09 21:01:07.755576 : Security check : IP adresse '127.0.0.1' connected +INFO:root:2024-02-09 21:01:07.757920 : Security check : IP adresse '127.0.0.1' connected +INFO:root:2024-02-09 21:01:07.762376 : Security check : IP adresse '127.0.0.1' connected +INFO:werkzeug:127.0.0.1 - - [09/Feb/2024 21:01:07] "POST /myclass/api/getRecodedImage/ HTTP/1.1" 200 - +INFO:root:2024-02-09 21:01:07.771029 : Connexion du partner recid = dbdd36f3d86a73e2bfac7b3f10f062ce1e7c22f7da37de192a OK. Mise à jour du firstconnexion et/ou lastconnexion : OK +INFO:werkzeug:127.0.0.1 - - [09/Feb/2024 21:01:07] "POST /myclass/api/get_partner_account/ HTTP/1.1" 200 - +INFO:werkzeug:127.0.0.1 - - [09/Feb/2024 21:01:07] "POST /myclass/api/LMS_Get_Partner_Data/ HTTP/1.1" 200 - +INFO:root:2024-02-09 21:18:17.577584 : Security check : IP adresse '127.0.0.1' connected +INFO:root:2024-02-09 21:18:17.580367 : Security check : IP adresse '127.0.0.1' connected +INFO:root:2024-02-09 21:18:17.585403 : Security check : IP adresse '127.0.0.1' connected +INFO:werkzeug:127.0.0.1 - - [09/Feb/2024 21:18:17] "POST /myclass/api/getRecodedImage/ HTTP/1.1" 200 - +INFO:root:2024-02-09 21:18:17.593279 : Connexion du partner recid = dbdd36f3d86a73e2bfac7b3f10f062ce1e7c22f7da37de192a OK. Mise à jour du firstconnexion et/ou lastconnexion : OK +INFO:werkzeug:127.0.0.1 - - [09/Feb/2024 21:18:17] "POST /myclass/api/get_partner_account/ HTTP/1.1" 200 - +INFO:werkzeug:127.0.0.1 - - [09/Feb/2024 21:18:17] "POST /myclass/api/LMS_Get_Partner_Data/ HTTP/1.1" 200 - +INFO:root:2024-02-09 21:25:29.667799 : Security check : IP adresse '127.0.0.1' connected +INFO:root:2024-02-09 21:25:29.674304 : Security check : IP adresse '127.0.0.1' connected +INFO:werkzeug:127.0.0.1 - - [09/Feb/2024 21:25:29] "POST /myclass/api/getRecodedImage/ HTTP/1.1" 200 - +INFO:root:2024-02-09 21:25:29.682201 : Security check : IP adresse '127.0.0.1' connected +INFO:root:2024-02-09 21:25:29.692193 : Connexion du partner recid = dbdd36f3d86a73e2bfac7b3f10f062ce1e7c22f7da37de192a OK. Mise à jour du firstconnexion et/ou lastconnexion : OK +INFO:werkzeug:127.0.0.1 - - [09/Feb/2024 21:25:29] "POST /myclass/api/get_partner_account/ HTTP/1.1" 200 - +INFO:werkzeug:127.0.0.1 - - [09/Feb/2024 21:25:29] "POST /myclass/api/LMS_Get_Partner_Data/ HTTP/1.1" 200 - +INFO:root:2024-02-09 21:25:41.788826 : Security check : IP adresse '127.0.0.1' connected +INFO:root:2024-02-09 21:25:41.799716 : Security check : IP adresse '127.0.0.1' connected +INFO:root:2024-02-09 21:25:41.808260 : Security check : IP adresse '127.0.0.1' connected +INFO:werkzeug:127.0.0.1 - - [09/Feb/2024 21:25:41] "POST /myclass/api/getRecodedImage/ HTTP/1.1" 200 - +INFO:root:2024-02-09 21:25:41.819493 : Security check : IP adresse '127.0.0.1' connected +INFO:root:2024-02-09 21:25:41.877492 : Connexion du partner recid = dbdd36f3d86a73e2bfac7b3f10f062ce1e7c22f7da37de192a OK. Mise à jour du firstconnexion et/ou lastconnexion : OK +INFO:werkzeug:127.0.0.1 - - [09/Feb/2024 21:25:41] "POST /myclass/api/get_partner_account/ HTTP/1.1" 200 - +INFO:werkzeug:127.0.0.1 - - [09/Feb/2024 21:25:41] "POST /myclass/api/LMS_Get_Partner_Data/ HTTP/1.1" 200 - +INFO:root:2024-02-09 21:25:42.031456 : Security check : IP adresse '127.0.0.1' connected +INFO:root:2024-02-09 21:25:42.043333 : Security check : IP adresse '127.0.0.1' connected +INFO:werkzeug:127.0.0.1 - - [09/Feb/2024 21:25:42] "POST /myclass/api/Get_Partner_Object_Specific_Valide_Displayed_Fields/ HTTP/1.1" 200 - +INFO:werkzeug:127.0.0.1 - - [09/Feb/2024 21:25:42] "POST /myclass/api/get_partner_class/ HTTP/1.1" 200 - +INFO:werkzeug:127.0.0.1 - - [09/Feb/2024 21:25:42] "POST /myclass/api/find_partner_class_like/ HTTP/1.1" 200 - +INFO:root:2024-02-09 21:28:43.178265 : Security check : IP adresse '127.0.0.1' connected +INFO:root:2024-02-09 21:28:43.182898 : Security check : IP adresse '127.0.0.1' connected +INFO:root:2024-02-09 21:28:43.187293 : Security check : IP adresse '127.0.0.1' connected +INFO:werkzeug:127.0.0.1 - - [09/Feb/2024 21:28:43] "POST /myclass/api/getRecodedImage/ HTTP/1.1" 200 - +INFO:root:2024-02-09 21:28:43.200300 : Connexion du partner recid = dbdd36f3d86a73e2bfac7b3f10f062ce1e7c22f7da37de192a OK. Mise à jour du firstconnexion et/ou lastconnexion : OK +INFO:werkzeug:127.0.0.1 - - [09/Feb/2024 21:28:43] "POST /myclass/api/get_partner_account/ HTTP/1.1" 200 - +INFO:werkzeug:127.0.0.1 - - [09/Feb/2024 21:28:43] "POST /myclass/api/LMS_Get_Partner_Data/ HTTP/1.1" 200 - +INFO:root:2024-02-09 21:28:43.484760 : Security check : IP adresse '127.0.0.1' connected +INFO:root:2024-02-09 21:28:43.492189 : Security check : IP adresse '127.0.0.1' connected +INFO:root:2024-02-09 21:28:43.499949 : Security check : IP adresse '127.0.0.1' connected +INFO:werkzeug:127.0.0.1 - - [09/Feb/2024 21:28:43] "POST /myclass/api/Get_List_Partner_Basic_Setup/ HTTP/1.1" 200 - +INFO:werkzeug:127.0.0.1 - - [09/Feb/2024 21:28:43] "POST /myclass/api/Get_Client_Type_List/ HTTP/1.1" 200 - +INFO:werkzeug:127.0.0.1 - - [09/Feb/2024 21:28:43] "POST /myclass/api/Get_List_Site_Formation_with_filter/ HTTP/1.1" 200 - +INFO:root:2024-02-09 21:28:55.834024 : Security check : IP adresse '127.0.0.1' connected +INFO:root:2024-02-09 21:28:55.839023 : Security check : IP adresse '127.0.0.1' connected +INFO:root:2024-02-09 21:28:55.845019 : Security check : IP adresse '127.0.0.1' connected +INFO:werkzeug:127.0.0.1 - - [09/Feb/2024 21:28:55] "POST /myclass/api/getRecodedImage/ HTTP/1.1" 200 - +INFO:root:2024-02-09 21:28:55.854143 : Connexion du partner recid = dbdd36f3d86a73e2bfac7b3f10f062ce1e7c22f7da37de192a OK. Mise à jour du firstconnexion et/ou lastconnexion : OK +INFO:werkzeug:127.0.0.1 - - [09/Feb/2024 21:28:55] "POST /myclass/api/get_partner_account/ HTTP/1.1" 200 - +INFO:werkzeug:127.0.0.1 - - [09/Feb/2024 21:28:55] "POST /myclass/api/LMS_Get_Partner_Data/ HTTP/1.1" 200 - +INFO:root:2024-02-09 21:28:55.998376 : Security check : IP adresse '127.0.0.1' connected +INFO:root:2024-02-09 21:28:56.001750 : Security check : IP adresse '127.0.0.1' connected +INFO:root:2024-02-09 21:28:56.007239 : Security check : IP adresse '127.0.0.1' connected +INFO:werkzeug:127.0.0.1 - - [09/Feb/2024 21:28:56] "POST /myclass/api/Get_List_Partner_Basic_Setup/ HTTP/1.1" 200 - +INFO:werkzeug:127.0.0.1 - - [09/Feb/2024 21:28:56] "POST /myclass/api/Get_Client_Type_List/ HTTP/1.1" 200 - +INFO:werkzeug:127.0.0.1 - - [09/Feb/2024 21:28:56] "POST /myclass/api/Get_List_Site_Formation_with_filter/ HTTP/1.1" 200 - +INFO:root:2024-02-09 21:30:33.935449 : Security check : IP adresse '127.0.0.1' connected +INFO:root:2024-02-09 21:30:33.939868 : Security check : IP adresse '127.0.0.1' connected +INFO:root:2024-02-09 21:30:33.945012 : Security check : IP adresse '127.0.0.1' connected +INFO:werkzeug:127.0.0.1 - - [09/Feb/2024 21:30:33] "POST /myclass/api/Get_List_Partner_Basic_Setup/ HTTP/1.1" 200 - +INFO:werkzeug:127.0.0.1 - - [09/Feb/2024 21:30:33] "POST /myclass/api/Get_Client_Type_List/ HTTP/1.1" 200 - +INFO:werkzeug:127.0.0.1 - - [09/Feb/2024 21:30:33] "POST /myclass/api/Get_List_Site_Formation_with_filter/ HTTP/1.1" 200 - +INFO:root:2024-02-09 21:37:29.776415 : Security check : IP adresse '127.0.0.1' connected +INFO:root:2024-02-09 21:37:29.782419 : Security check : IP adresse '127.0.0.1' connected +INFO:root:2024-02-09 21:37:29.786417 : Security check : IP adresse '127.0.0.1' connected +INFO:werkzeug:127.0.0.1 - - [09/Feb/2024 21:37:29] "POST /myclass/api/Get_Client_Type_List/ HTTP/1.1" 200 - +INFO:werkzeug:127.0.0.1 - - [09/Feb/2024 21:37:29] "POST /myclass/api/Get_List_Partner_Basic_Setup/ HTTP/1.1" 200 - +INFO:werkzeug:127.0.0.1 - - [09/Feb/2024 21:37:29] "POST /myclass/api/Get_List_Site_Formation_with_filter/ HTTP/1.1" 200 - +INFO:root:2024-02-09 21:38:45.728922 : Security check : IP adresse '127.0.0.1' connected +INFO:root:2024-02-09 21:38:45.733924 : Security check : IP adresse '127.0.0.1' connected +INFO:root:2024-02-09 21:38:45.739111 : Security check : IP adresse '127.0.0.1' connected +INFO:werkzeug:127.0.0.1 - - [09/Feb/2024 21:38:45] "POST /myclass/api/Get_List_Partner_Basic_Setup/ HTTP/1.1" 200 - +INFO:werkzeug:127.0.0.1 - - [09/Feb/2024 21:38:45] "POST /myclass/api/Get_List_Site_Formation_with_filter/ HTTP/1.1" 200 - +INFO:werkzeug:127.0.0.1 - - [09/Feb/2024 21:38:45] "POST /myclass/api/Get_Client_Type_List/ HTTP/1.1" 200 - +INFO:root:2024-02-09 21:44:23.422504 : Security check : IP adresse '127.0.0.1' connected +INFO:root:2024-02-09 21:44:23.428533 : Security check : IP adresse '127.0.0.1' connected +INFO:root:2024-02-09 21:44:23.433617 : Security check : IP adresse '127.0.0.1' connected +INFO:werkzeug:127.0.0.1 - - [09/Feb/2024 21:44:23] "POST /myclass/api/Get_List_Partner_Basic_Setup/ HTTP/1.1" 200 - +INFO:werkzeug:127.0.0.1 - - [09/Feb/2024 21:44:23] "POST /myclass/api/Get_Client_Type_List/ HTTP/1.1" 200 - +INFO:werkzeug:127.0.0.1 - - [09/Feb/2024 21:44:23] "POST /myclass/api/Get_List_Site_Formation_with_filter/ HTTP/1.1" 200 - +INFO:root:2024-02-09 21:45:05.503334 : Security check : IP adresse '127.0.0.1' connected +INFO:root:2024-02-09 21:45:05.507267 : Security check : IP adresse '127.0.0.1' connected +INFO:root:2024-02-09 21:45:05.512860 : Security check : IP adresse '127.0.0.1' connected +INFO:werkzeug:127.0.0.1 - - [09/Feb/2024 21:45:05] "POST /myclass/api/Get_List_Partner_Basic_Setup/ HTTP/1.1" 200 - +INFO:werkzeug:127.0.0.1 - - [09/Feb/2024 21:45:05] "POST /myclass/api/Get_Client_Type_List/ HTTP/1.1" 200 - +INFO:werkzeug:127.0.0.1 - - [09/Feb/2024 21:45:05] "POST /myclass/api/Get_List_Site_Formation_with_filter/ HTTP/1.1" 200 - +INFO:root:2024-02-09 21:51:14.544345 : Security check : IP adresse '127.0.0.1' connected +INFO:root:2024-02-09 21:51:14.548876 : Security check : IP adresse '127.0.0.1' connected +INFO:root:2024-02-09 21:51:14.555880 : Security check : IP adresse '127.0.0.1' connected +INFO:werkzeug:127.0.0.1 - - [09/Feb/2024 21:51:14] "POST /myclass/api/Get_List_Partner_Basic_Setup/ HTTP/1.1" 200 - +INFO:werkzeug:127.0.0.1 - - [09/Feb/2024 21:51:14] "POST /myclass/api/Get_List_Site_Formation_with_filter/ HTTP/1.1" 200 - +INFO:werkzeug:127.0.0.1 - - [09/Feb/2024 21:51:14] "POST /myclass/api/Get_Client_Type_List/ HTTP/1.1" 200 - +INFO:root:2024-02-09 21:54:17.222560 : Security check : IP adresse '127.0.0.1' connected +INFO:root:2024-02-09 21:54:17.227062 : Security check : IP adresse '127.0.0.1' connected +INFO:root:2024-02-09 21:54:17.233287 : Security check : IP adresse '127.0.0.1' connected +INFO:werkzeug:127.0.0.1 - - [09/Feb/2024 21:54:17] "POST /myclass/api/Get_List_Partner_Basic_Setup/ HTTP/1.1" 200 - +INFO:werkzeug:127.0.0.1 - - [09/Feb/2024 21:54:17] "POST /myclass/api/Get_Client_Type_List/ HTTP/1.1" 200 - +INFO:werkzeug:127.0.0.1 - - [09/Feb/2024 21:54:17] "POST /myclass/api/Get_List_Site_Formation_with_filter/ HTTP/1.1" 200 - +INFO:root:2024-02-09 21:54:33.896144 : Security check : IP adresse '127.0.0.1' connected +INFO:root:2024-02-09 21:54:33.901228 : Security check : IP adresse '127.0.0.1' connected +INFO:root:2024-02-09 21:54:33.907224 : Security check : IP adresse '127.0.0.1' connected +INFO:werkzeug:127.0.0.1 - - [09/Feb/2024 21:54:33] "POST /myclass/api/Get_Client_Type_List/ HTTP/1.1" 200 - +INFO:werkzeug:127.0.0.1 - - [09/Feb/2024 21:54:33] "POST /myclass/api/Get_List_Partner_Basic_Setup/ HTTP/1.1" 200 - +INFO:werkzeug:127.0.0.1 - - [09/Feb/2024 21:54:33] "POST /myclass/api/Get_List_Site_Formation_with_filter/ HTTP/1.1" 200 - +INFO:root:2024-02-09 21:58:57.266643 : Security check : IP adresse '127.0.0.1' connected +INFO:root:2024-02-09 21:58:57.275495 : Security check : IP adresse '127.0.0.1' connected +INFO:root:2024-02-09 21:58:57.277834 : Security check : IP adresse '127.0.0.1' connected +INFO:werkzeug:127.0.0.1 - - [09/Feb/2024 21:58:57] "POST /myclass/api/Get_List_Partner_Basic_Setup/ HTTP/1.1" 200 - +INFO:werkzeug:127.0.0.1 - - [09/Feb/2024 21:58:57] "POST /myclass/api/Get_List_Site_Formation_with_filter/ HTTP/1.1" 200 - +INFO:werkzeug:127.0.0.1 - - [09/Feb/2024 21:58:57] "POST /myclass/api/Get_Client_Type_List/ HTTP/1.1" 200 - diff --git a/crm_opportunite.py b/crm_opportunite.py index 0abbf32..973f429 100644 --- a/crm_opportunite.py +++ b/crm_opportunite.py @@ -470,6 +470,71 @@ def Get_Given_CRM_Opportunite(diction): return False, " Impossible de récupérer les données de opportunité " +""" +Suppression d'un opportunité +""" +def Delete_Given_CRM_Opportunite(diction): + try: + diction = mycommon.strip_dictionary(diction) + + """ + Verification des input acceptés + """ + field_list = ['token', 'opport_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', 'opport_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 l'existance de l'opportunité + is_opportunit_valide = MYSY_GV.dbname['crm_opportunite'].count_documents({'_id':ObjectId(str(diction['opport_id'])), + 'partner_owner_recid':str(my_partner['recid'])}) + + if (is_opportunit_valide != 1): + mycommon.myprint( + str(inspect.stack()[0][3]) + " L'identifiant de l'opportunité est invalide ") + return False, " L'identifiant de opportunité est invalide " + + qry = {'_id':ObjectId(str(diction['opport_id'])), 'partner_owner_recid':str(my_partner['recid'])} + + ret_site_formation = MYSY_GV.dbname['crm_opportunite'].delete_many(qry) + + return True, "L'opportunité a été correctement supprimée" + + + 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 récupérer les données de opportunité " + + """ Fonction d'ajout d'une étape (configuration) d'opportunité diff --git a/main.py b/main.py index 60ec229..6f1e9b6 100644 --- a/main.py +++ b/main.py @@ -75,6 +75,9 @@ import apprenant_mgt as apprenant_mgt import module_editique as module_editique import attestation_formation as attestation_formation import crm_opportunite as crm_opportunite +import site_formation as site_formation + + app = Flask(__name__) cors = CORS(app, resources={r"/foo": {"origins": "*"}}) @@ -7582,6 +7585,21 @@ def Get_Given_CRM_Opportunite(): return jsonify(status=status, message=retval) +""" +API de suppression des data d'une opportunité données +""" +@app.route('/myclass/api/Delete_Given_CRM_Opportunite/', methods=['POST','GET']) +@crossdomain(origin='*') +def Delete_Given_CRM_Opportunite(): + # On recupere le corps (payload) de la requete + payload = mycommon.strip_dictionary (request.form.to_dict()) + print(" ### Delete_Given_CRM_Opportunite payload = ",payload) + print(request.files) + status, retval = crm_opportunite.Delete_Given_CRM_Opportunite(payload) + return jsonify(status=status, message=retval) + + + @@ -7600,6 +7618,78 @@ def Account_Migration_to_delete(): return jsonify(status=status, message=retval) +""" +API pour ajouter un site de formation +""" +@app.route('/myclass/api/Add_Site_Formation/', methods=['POST','GET']) +@crossdomain(origin='*') +def Add_Site_Formation(): + # On recupere le corps (payload) de la requete + payload = mycommon.strip_dictionary (request.form.to_dict()) + print(" ### Add_Site_Formation payload = ",payload) + print(request.files) + status, retval = site_formation.Add_Site_Formation(payload) + return jsonify(status=status, message=retval) + + +""" +API pour mettre à jour un site de formation +""" +@app.route('/myclass/api/Update_Site_Formation/', methods=['POST','GET']) +@crossdomain(origin='*') +def Update_Site_Formation(): + # On recupere le corps (payload) de la requete + payload = mycommon.strip_dictionary (request.form.to_dict()) + print(" ### Update_Site_Formation payload = ",payload) + print(request.files) + status, retval = site_formation.Update_Site_Formation(payload) + return jsonify(status=status, message=retval) + + +""" +API pour recuperer la liste des site de formation d'un partenaire avec des filtres +""" +@app.route('/myclass/api/Get_List_Site_Formation_with_filter/', methods=['POST','GET']) +@crossdomain(origin='*') +def Get_List_Site_Formation_with_filter(): + # On recupere le corps (payload) de la requete + payload = mycommon.strip_dictionary (request.form.to_dict()) + print(" ### Get_List_Site_Formation_with_filter payload = ",payload) + print(request.files) + status, retval = site_formation.Get_List_Site_Formation_with_filter(payload) + return jsonify(status=status, message=retval) + +""" +API pour recuperer les données d'un site de formation donnée +""" +@app.route('/myclass/api/Get_Given_Site_Formation/', methods=['POST','GET']) +@crossdomain(origin='*') +def Get_Given_Site_Formation(): + # On recupere le corps (payload) de la requete + payload = mycommon.strip_dictionary (request.form.to_dict()) + print(" ### Get_Given_Site_Formation payload = ",payload) + print(request.files) + status, retval = site_formation.Get_Given_Site_Formation(payload) + return jsonify(status=status, message=retval) + + + +""" +API pour supprimer les données d'un site de formation donnée +""" +@app.route('/myclass/api/Delete_Given_Site_Formation/', methods=['POST','GET']) +@crossdomain(origin='*') +def Delete_Given_Site_Formation(): + # On recupere le corps (payload) de la requete + payload = mycommon.strip_dictionary (request.form.to_dict()) + print(" ### Delete_Given_Site_Formation payload = ",payload) + print(request.files) + status, retval = site_formation.Delete_Given_Site_Formation(payload) + return jsonify(status=status, message=retval) + + + + if __name__ == '__main__': print(" debut api") context = SSL.Context(SSL.SSLv23_METHOD) diff --git a/site_formation.py b/site_formation.py new file mode 100644 index 0000000..7d4fc47 --- /dev/null +++ b/site_formation.py @@ -0,0 +1,526 @@ +""" +Ce fichier permet de gérer les differents sites d'un établissement de formation. +1) Ajouter la notion de site de formation +Un site géré dans les paramètres +Un site est un lieu physique où virtuel de formation. A moyen et long terme il sera utilisé pour gérer une école avec plusieurs lieux de formation. + +Un site est defini par : "code_site", "nom_site", "site_adr", "site_cp", "site_ville", "site_pays", "telephone", "email", "site_rattachement_id" + +la clé est le "code_site" +""" +import ast +import xlsxwriter +import jinja2 +import pymongo +from flask import send_file +from pymongo import MongoClient +import json +from bson import ObjectId +import re +from datetime import datetime, date + +from xhtml2pdf import pisa + +import attached_file_mgt +import prj_common as mycommon +import secrets +import inspect +import sys, os +import csv +import pandas as pd +from pymongo import ReturnDocument +import GlobalVariable as MYSY_GV +from math import isnan +import GlobalVariable as MYSY_GV +import ela_index_bdd_classes as eibdd +import email_mgt as email +import Inscription_mgt as Inscription_mgt +import Session_Formation as sf + +""" +Ajout d'un site de formation +""" +def Add_Site_Formation(diction): + try: + diction = mycommon.strip_dictionary(diction) + + """ + Verification des input acceptés + """ + field_list = ['token', "code_site", "nom_site", "site_adr", "site_cp", "site_ville", "site_pays", + "telephone", "email", "site_rattachement_id", "description" + ] + + 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', "code_site", "nom_site",] + + 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 s'il n'y pas un site avec le meme code + is_code_site_valide = MYSY_GV.dbname['site_formation'].count_documents({'code_site':str(diction['code_site']), + 'valide':'1', + 'locked':'0', + 'partner_owner_recid':str(my_partner['recid'])}) + if( is_code_site_valide != 0 ): + mycommon.myprint( + str(inspect.stack()[0][3]) + " Un site avec le même code existe déjà ") + return False, " Un site avec le même code existe déjà " + + # Si un te site de rattachement est envoyé, verifier sa validité + site_rattachement_id = "" + if( "site_rattachement_id" in diction.keys() and diction['site_rattachement_id']): + site_rattachement_id = diction['site_rattachement_id'] + + is_site_rattachement_id_valide = MYSY_GV.dbname['site_formation'].count_documents({'_id':ObjectId(str(site_rattachement_id)), + 'valide':'1', + 'locked':'0', + 'partner_owner_recid':str(my_partner['recid'])}) + + if( is_site_rattachement_id_valide != 1 ): + mycommon.myprint( + str(inspect.stack()[0][3]) + " L'identifiant du site de rattachement est invalide ") + return False, " L'identifiant du site de rattachement est invalide " + + + mydata = diction + del mydata['token'] + """ + # Initialisation et remplissage des champs non envoyés à vide + """ + for val in field_list: + if val not in diction.keys(): + mydata[str(val)] = "" + + mydata['code_site'] = str(diction['code_site']).lower() + mydata['date_update'] = str(datetime.now()) + mydata['update_by'] = str(my_partner['_id']) + mydata['partner_owner_recid'] = str(my_partner['recid']) + mydata['valide'] = "1" + mydata['locked'] = "0" + + print(" ### site à créer = ", mydata) + + inserted_id = MYSY_GV.dbname['site_formation'].insert_one(mydata).inserted_id + + if (not inserted_id): + mycommon.myprint(" Impossible de créer le site de formation (2) ") + return False, " Impossible de créer le site de formation (2) " + + + return True, "Le site a été correctement 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 de créer le site de formation " + + +""" +Mettre à jour un site de formation +""" +def Update_Site_Formation(diction): + try: + diction = mycommon.strip_dictionary(diction) + + """ + Verification des input acceptés + """ + field_list = ['token', "site_id", "code_site", "nom_site", "site_adr", "site_cp", "site_ville", "site_pays", "telephone", + "email", "site_rattachement_id", "description" + ] + + 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', "site_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 que site existe + is_code_site_valide = MYSY_GV.dbname['site_formation'].count_documents({'_id':ObjectId(str(diction['site_id'])), + 'valide':'1', + 'locked':'0', + 'partner_owner_recid':str(my_partner['recid'])}) + if( is_code_site_valide != 1 ): + mycommon.myprint( + str(inspect.stack()[0][3]) + " L'identifiant du site est invalide ") + return False, " L'identifiant du site est invalide " + + # Si un te site de rattachement est envoyé, verifier sa validité + site_rattachement_id = "" + if( "site_rattachement_id" in diction.keys() and diction['site_rattachement_id']): + site_rattachement_id = diction['site_rattachement_id'] + + is_site_rattachement_id_valide = MYSY_GV.dbname['site_formation'].count_documents({'_id':ObjectId(str(site_rattachement_id)), + 'valide':'1', + 'locked':'0', + 'partner_owner_recid':str(my_partner['recid'])}) + + if( is_site_rattachement_id_valide != 1 ): + mycommon.myprint( + str(inspect.stack()[0][3]) + " L'identifiant du site de rattachement est invalide ") + return False, " L'identifiant du site de rattachement est invalide " + + + my_site_id = diction['site_id'] + mydata = diction + del mydata['token'] + del mydata['site_id'] + + + + mydata['date_update'] = str(datetime.now()) + mydata['update_by'] = str(my_partner['_id']) + + result = MYSY_GV.dbname['crm_opportunite'].find_one_and_update( + {'_id': ObjectId(str(my_site_id)), + 'partner_owner_recid': str(my_partner['recid'])}, + {"$set": mydata}, + upsert=False, + return_document=ReturnDocument.AFTER + ) + if ("_id" not in result.keys()): + mycommon.myprint( + " Impossible de mettre à jour le site de formation (2) ") + return False, " Impossible de mettre à jour le site de formation (2) " + + + return True, "Le site a été correctement mis à jour " + + 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 mettre à jour le site de formation " + + +""" +Recuperation de liste des sites de formation +""" +def Get_List_Site_Formation_with_filter(diction): + try: + diction = mycommon.strip_dictionary(diction) + + """ + Verification des input acceptés + """ + field_list = ['token', "code_site", "nom_site", ] + + 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',] + + 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 + + filt_code_site = {} + if ("code_site" in diction.keys()): + filt_code_site = {'code_site': {'$regex': str(diction['code_site']), "$options": "i"}} + + filt_nom_site = {} + if ("nom_site" in diction.keys()): + filt_nom_site = {'nom_site': {'$regex': str(diction['nom_site']), "$options": "i"}} + + + RetObject = [] + val_tmp = 0 + + qry = {"partner_owner_recid":str(my_partner['recid']), 'valide':'1', 'locked':'0'} + query_with_filter = {'$and': [qry, filt_code_site, filt_nom_site ]} + + for New_retVal in MYSY_GV.dbname['site_formation'].find(query_with_filter): + user = New_retVal + user['id'] = str(val_tmp) + val_tmp = val_tmp + 1 + + site_rattachement_nom = "" + site_rattachement_code = "" + if( "site_rattachement_id" in New_retVal.keys() and New_retVal['site_rattachement_id']): + site_rattachement_data = MYSY_GV.dbname['site_formation'].find_one( + {'_id': ObjectId(str(New_retVal['site_rattachement_id'])), 'valide': '1', 'locked': '0', + 'partner_owner_recid': str(my_partner['recid'])}) + + if( "code_site" in site_rattachement_data.keys()): + site_rattachement_code = site_rattachement_data['code_site'] + + if ("nom_site" in site_rattachement_data.keys()): + site_rattachement_nom = site_rattachement_data['nom_site'] + + user['site_rattachement_nom'] = site_rattachement_nom + user['site_rattachement_code'] = site_rattachement_code + + RetObject.append(mycommon.JSONEncoder().encode(user)) + + + return True, RetObject + + 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 récupérer la liste des sites de formation " + + +""" +Recuperer les données d'un site +""" +def Get_Given_Site_Formation(diction): + try: + diction = mycommon.strip_dictionary(diction) + + """ + Verification des input acceptés + """ + field_list = ['token', "site_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','site_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 + + + + RetObject = [] + val_tmp = 0 + + qry = {"partner_owner_recid":str(my_partner['recid']), 'valide':'1', 'locked':'0','_id':ObjectId(str(diction['site_id']))} + + + for New_retVal in MYSY_GV.dbname['site_formation'].find(qry): + user = New_retVal + user['id'] = str(val_tmp) + val_tmp = val_tmp + 1 + + site_rattachement_nom = "" + site_rattachement_code = "" + if( "site_rattachement_id" in New_retVal.keys() and New_retVal['site_rattachement_id']): + site_rattachement_data = MYSY_GV.dbname['site_formation'].find_one( + {'_id': ObjectId(str(New_retVal['site_rattachement_id'])), 'valide': '1', 'locked': '0', + 'partner_owner_recid': str(my_partner['recid'])}) + + if( "code_site" in site_rattachement_data.keys()): + site_rattachement_code = site_rattachement_data['code_site'] + + if ("nom_site" in site_rattachement_data.keys()): + site_rattachement_nom = site_rattachement_data['nom_site'] + + user['site_rattachement_nom'] = site_rattachement_nom + user['site_rattachement_code'] = site_rattachement_code + + RetObject.append(mycommon.JSONEncoder().encode(user)) + + + return True, RetObject + + 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 récupérer les données du site de formation " + + +""" +Supprimer un site de formation +regle : +Un site n'est supprimable que s'il n'est pas utilisé dans les collections : +- ressource_humaine +- ressource_materielle +- session_formation + +""" +def Delete_Given_Site_Formation(diction): + try: + diction = mycommon.strip_dictionary(diction) + + """ + Verification des input acceptés + """ + field_list = ['token', "site_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','site_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 que la site exist + """ + is_site_existe = MYSY_GV.dbname['site_formation'].count_documents({'_id':ObjectId(str(diction['site_id'])), + 'partner_owner_recid':str(my_partner['recid'])}) + + if( is_site_existe != 1 ): + mycommon.myprint( + str(inspect.stack()[0][3]) + " L'identifiant du site est invalide ") + return False, " L'identifiant du site est invalide " + + """ + Verifier que le site n'est pas utilisé dans les collections suivantes : + - ressource_humaine + - ressource_materielle + - session_formation + """ + list_collection_to_check = ['ressource_humaine', 'ressource_materielle'] + for local_collection in list_collection_to_check: + is_site_id_exist = MYSY_GV.dbname[str(local_collection)].count_documents({'site_formation_id':str(diction['site_id']), + 'partner_recid':str(my_partner['recid']), + 'valide':'1'}) + if( is_site_id_exist != 0 ): + mycommon.myprint( + str(inspect.stack()[0][3]) + " Ce site de formation est utilisé "+str(is_site_id_exist)+" fois dans "+str(local_collection)) + return False, " Ce site de formation est utilisé "+str(is_site_id_exist)+" fois dans "+str(local_collection) + + + list_collection_to_check = ['partner_owner_recid'] + for local_collection in list_collection_to_check: + is_site_id_exist = MYSY_GV.dbname[str(local_collection)].count_documents( + {'site_formation_id': str(diction['site_id']), + 'partner_recid': str(my_partner['recid']), + 'valide': '1'}) + if (is_site_id_exist != 0): + mycommon.myprint( + str(inspect.stack()[0][3]) + " Ce site de formation est utilisé " + str( + is_site_id_exist) + " fois dans " + str(local_collection)) + return False, " Ce site de formation est utilisé " + str(is_site_id_exist) + " fois dans " + str( + local_collection) + + RetObject = [] + val_tmp = 0 + + qry = {"partner_owner_recid":str(my_partner['recid']), '_id':ObjectId(str(diction['site_id']))} + + ret_site_formation = MYSY_GV.dbname['site_formation'].delete_many(qry) + + + return True, "Le site de formation a été correctement supprimé" + + 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 supprimer les données du site de formation " +