diff --git a/.idea/workspace.xml b/.idea/workspace.xml index f9608ef..2aab84b 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -4,14 +4,9 @@ - @@ -523,6 +517,7 @@ - \ No newline at end of file diff --git a/Log/log_file.log b/Log/log_file.log index 1d92665..fd06104 100644 --- a/Log/log_file.log +++ b/Log/log_file.log @@ -81191,3 +81191,93 @@ INFO:root:2025-11-23 21:14:03.619898 : ++ FLASK PORT 5001 ++ INFO:root:2025-11-23 21:14:03.619898 : ++ LMS_BAS_URL mysy-hosting.com/ ++ WARNING:werkzeug: * Debugger is active! INFO:werkzeug: * Debugger PIN: 479-264-725 +INFO:werkzeug: * Detected change in 'C:\\Users\\Cherif\\Documents\\myclass.com\\Siteweb\\Elyos_Ftion_Initiale\\Ela_back\\Back_Office_FI\\ent_alert_messages.py', reloading +INFO:werkzeug: * Restarting with stat +DEBUG:matplotlib:matplotlib data path: C:\Users\Cherif\Documents\myclass.com\Siteweb\Elyos_Ftion_Continue\Ela_back\Back_Office\venv\Lib\site-packages\matplotlib\mpl-data +DEBUG:matplotlib:CONFIGDIR=C:\Users\Cherif\.matplotlib +DEBUG:matplotlib:interactive is False +DEBUG:matplotlib:platform is win32 +DEBUG:matplotlib:CACHEDIR=C:\Users\Cherif\.matplotlib +DEBUG:matplotlib.font_manager:Using fontManager instance from C:\Users\Cherif\.matplotlib\fontlist-v390.json +INFO:root:2025-11-23 21:21:37.018491 : ++++ ENVIRONNEMENT DEVELOPPEMENT ++++ +INFO:root:2025-11-23 21:21:37.019493 : ++ DATABASE mongodb://localhost:27017/cherifdb_dev_fi ++ +INFO:root:2025-11-23 21:21:37.019493 : ++ DBNAME Database(MongoClient(host=['localhost:27017'], document_class=dict, tz_aware=False, connect=True), 'cherifdb_dev_fi') ++ +INFO:root:2025-11-23 21:21:37.019493 : ++ FLASK PORT 5001 ++ +INFO:root:2025-11-23 21:21:37.019493 : ++ LMS_BAS_URL mysy-hosting.com/ ++ +WARNING:werkzeug: * Debugger is active! +INFO:werkzeug: * Debugger PIN: 479-264-725 +INFO:werkzeug: * Detected change in 'C:\\Users\\Cherif\\Documents\\myclass.com\\Siteweb\\Elyos_Ftion_Initiale\\Ela_back\\Back_Office_FI\\ent_alert_messages.py', reloading +INFO:werkzeug: * Restarting with stat +DEBUG:matplotlib:matplotlib data path: C:\Users\Cherif\Documents\myclass.com\Siteweb\Elyos_Ftion_Continue\Ela_back\Back_Office\venv\Lib\site-packages\matplotlib\mpl-data +DEBUG:matplotlib:CONFIGDIR=C:\Users\Cherif\.matplotlib +DEBUG:matplotlib:interactive is False +DEBUG:matplotlib:platform is win32 +DEBUG:matplotlib:CACHEDIR=C:\Users\Cherif\.matplotlib +DEBUG:matplotlib.font_manager:Using fontManager instance from C:\Users\Cherif\.matplotlib\fontlist-v390.json +INFO:root:2025-11-23 21:22:19.920832 : ++++ ENVIRONNEMENT DEVELOPPEMENT ++++ +INFO:root:2025-11-23 21:22:19.921835 : ++ DATABASE mongodb://localhost:27017/cherifdb_dev_fi ++ +INFO:root:2025-11-23 21:22:19.921835 : ++ DBNAME Database(MongoClient(host=['localhost:27017'], document_class=dict, tz_aware=False, connect=True), 'cherifdb_dev_fi') ++ +INFO:root:2025-11-23 21:22:19.921835 : ++ FLASK PORT 5001 ++ +INFO:root:2025-11-23 21:22:19.921835 : ++ LMS_BAS_URL mysy-hosting.com/ ++ +WARNING:werkzeug: * Debugger is active! +INFO:werkzeug: * Debugger PIN: 479-264-725 +INFO:werkzeug: * Detected change in 'C:\\Users\\Cherif\\Documents\\myclass.com\\Siteweb\\Elyos_Ftion_Initiale\\Ela_back\\Back_Office_FI\\main.py', reloading +INFO:werkzeug: * Restarting with stat +DEBUG:matplotlib:matplotlib data path: C:\Users\Cherif\Documents\myclass.com\Siteweb\Elyos_Ftion_Continue\Ela_back\Back_Office\venv\Lib\site-packages\matplotlib\mpl-data +DEBUG:matplotlib:CONFIGDIR=C:\Users\Cherif\.matplotlib +DEBUG:matplotlib:interactive is False +DEBUG:matplotlib:platform is win32 +DEBUG:matplotlib:CACHEDIR=C:\Users\Cherif\.matplotlib +DEBUG:matplotlib.font_manager:Using fontManager instance from C:\Users\Cherif\.matplotlib\fontlist-v390.json +INFO:root:2025-11-23 21:23:22.166547 : ++++ ENVIRONNEMENT DEVELOPPEMENT ++++ +INFO:root:2025-11-23 21:23:22.166547 : ++ DATABASE mongodb://localhost:27017/cherifdb_dev_fi ++ +INFO:root:2025-11-23 21:23:22.166547 : ++ DBNAME Database(MongoClient(host=['localhost:27017'], document_class=dict, tz_aware=False, connect=True), 'cherifdb_dev_fi') ++ +INFO:root:2025-11-23 21:23:22.166547 : ++ FLASK PORT 5001 ++ +INFO:root:2025-11-23 21:23:22.166547 : ++ LMS_BAS_URL mysy-hosting.com/ ++ +WARNING:werkzeug: * Debugger is active! +INFO:werkzeug: * Debugger PIN: 479-264-725 +INFO:werkzeug: * Detected change in 'C:\\Users\\Cherif\\Documents\\myclass.com\\Siteweb\\Elyos_Ftion_Initiale\\Ela_back\\Back_Office_FI\\ent_alert_messages.py', reloading +INFO:werkzeug: * Restarting with stat +DEBUG:matplotlib:matplotlib data path: C:\Users\Cherif\Documents\myclass.com\Siteweb\Elyos_Ftion_Continue\Ela_back\Back_Office\venv\Lib\site-packages\matplotlib\mpl-data +DEBUG:matplotlib:CONFIGDIR=C:\Users\Cherif\.matplotlib +DEBUG:matplotlib:interactive is False +DEBUG:matplotlib:platform is win32 +DEBUG:matplotlib:CACHEDIR=C:\Users\Cherif\.matplotlib +DEBUG:matplotlib.font_manager:Using fontManager instance from C:\Users\Cherif\.matplotlib\fontlist-v390.json +INFO:root:2025-11-23 21:23:58.110938 : ++++ ENVIRONNEMENT DEVELOPPEMENT ++++ +INFO:root:2025-11-23 21:23:58.110938 : ++ DATABASE mongodb://localhost:27017/cherifdb_dev_fi ++ +INFO:root:2025-11-23 21:23:58.110938 : ++ DBNAME Database(MongoClient(host=['localhost:27017'], document_class=dict, tz_aware=False, connect=True), 'cherifdb_dev_fi') ++ +INFO:root:2025-11-23 21:23:58.110938 : ++ FLASK PORT 5001 ++ +INFO:root:2025-11-23 21:23:58.110938 : ++ LMS_BAS_URL mysy-hosting.com/ ++ +WARNING:werkzeug: * Debugger is active! +INFO:werkzeug: * Debugger PIN: 479-264-725 +INFO:werkzeug: * Detected change in 'C:\\Users\\Cherif\\Documents\\myclass.com\\Siteweb\\Elyos_Ftion_Initiale\\Ela_back\\Back_Office_FI\\ent_alert_messages.py', reloading +INFO:werkzeug: * Restarting with stat +DEBUG:matplotlib:matplotlib data path: C:\Users\Cherif\Documents\myclass.com\Siteweb\Elyos_Ftion_Continue\Ela_back\Back_Office\venv\Lib\site-packages\matplotlib\mpl-data +DEBUG:matplotlib:CONFIGDIR=C:\Users\Cherif\.matplotlib +DEBUG:matplotlib:interactive is False +DEBUG:matplotlib:platform is win32 +DEBUG:matplotlib:CACHEDIR=C:\Users\Cherif\.matplotlib +DEBUG:matplotlib.font_manager:Using fontManager instance from C:\Users\Cherif\.matplotlib\fontlist-v390.json +INFO:root:2025-11-23 21:26:30.125176 : ++++ ENVIRONNEMENT DEVELOPPEMENT ++++ +INFO:root:2025-11-23 21:26:30.125176 : ++ DATABASE mongodb://localhost:27017/cherifdb_dev_fi ++ +INFO:root:2025-11-23 21:26:30.125176 : ++ DBNAME Database(MongoClient(host=['localhost:27017'], document_class=dict, tz_aware=False, connect=True), 'cherifdb_dev_fi') ++ +INFO:root:2025-11-23 21:26:30.126174 : ++ FLASK PORT 5001 ++ +INFO:root:2025-11-23 21:26:30.126174 : ++ LMS_BAS_URL mysy-hosting.com/ ++ +WARNING:werkzeug: * Debugger is active! +INFO:werkzeug: * Debugger PIN: 479-264-725 +INFO:werkzeug: * Detected change in 'C:\\Users\\Cherif\\Documents\\myclass.com\\Siteweb\\Elyos_Ftion_Initiale\\Ela_back\\Back_Office_FI\\main.py', reloading +INFO:werkzeug: * Restarting with stat +DEBUG:matplotlib:matplotlib data path: C:\Users\Cherif\Documents\myclass.com\Siteweb\Elyos_Ftion_Continue\Ela_back\Back_Office\venv\Lib\site-packages\matplotlib\mpl-data +DEBUG:matplotlib:CONFIGDIR=C:\Users\Cherif\.matplotlib +DEBUG:matplotlib:interactive is False +DEBUG:matplotlib:platform is win32 +DEBUG:matplotlib:CACHEDIR=C:\Users\Cherif\.matplotlib +DEBUG:matplotlib.font_manager:Using fontManager instance from C:\Users\Cherif\.matplotlib\fontlist-v390.json +INFO:root:2025-11-23 21:28:14.520222 : ++++ ENVIRONNEMENT DEVELOPPEMENT ++++ +INFO:root:2025-11-23 21:28:14.521225 : ++ DATABASE mongodb://localhost:27017/cherifdb_dev_fi ++ +INFO:root:2025-11-23 21:28:14.521225 : ++ DBNAME Database(MongoClient(host=['localhost:27017'], document_class=dict, tz_aware=False, connect=True), 'cherifdb_dev_fi') ++ +INFO:root:2025-11-23 21:28:14.528228 : ++ FLASK PORT 5001 ++ +INFO:root:2025-11-23 21:28:14.529224 : ++ LMS_BAS_URL mysy-hosting.com/ ++ +WARNING:werkzeug: * Debugger is active! +INFO:werkzeug: * Debugger PIN: 479-264-725 diff --git a/ent_alert_messages.py b/ent_alert_messages.py index 9018458..c63dc0f 100644 --- a/ent_alert_messages.py +++ b/ent_alert_messages.py @@ -125,6 +125,7 @@ def Add_Ent_Alert_Message(diction): new_data['valide'] = "1" new_data['locked'] = "0" + new_data['publish_ent'] = "0" new_data['creation_date'] = str(datetime.now()) new_data['update_by'] = str(my_partner['_id']) @@ -257,7 +258,7 @@ def Update_Ent_Alert_Message(diction): data_cle['valide'] = "1" data_cle['locked'] = "0" - result = MYSY_GV.dbname['class_domaine'].find_one_and_update( + result = MYSY_GV.dbname['ent_alert_message'].find_one_and_update( data_cle, {"$set": new_data}, upsert=False, @@ -269,7 +270,7 @@ def Update_Ent_Alert_Message(diction): " Impossible de mettre à jour le message (2) ") return False, " Impossible de mettre à jour le message (2) " - return True, " Le message de formation a été correctement mis à jour" + return True, " Le message a été correctement mis à jour" except Exception as e: exc_type, exc_obj, exc_tb = sys.exc_info() @@ -347,6 +348,79 @@ def Get_List_Ent_Alert_Message(diction): return False, " Impossible de récupérer la liste des messages " + +""" +Recuperer la liste des message d'alerte PUBLIE sur ENT d'un partenaire +""" +def Get_List_Published_Ent_Alert_Message(diction): + try: + diction = mycommon.strip_dictionary(diction) + + """ + Verification des input acceptés + """ + field_list = ['token', ] + + 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'existe pas") + 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 la liste des arguments ") + 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 + + print(" ## my_partner = ",my_partner) + """ + Clés de mise à jour + """ + data_cle = {} + data_cle['partner_owner_recid'] = str(my_partner['partner_owner_recid']) + data_cle['valide'] = "1" + data_cle['locked'] = "0" + data_cle['publish_ent'] = "1" + + + RetObject = [] + val_tmp = 0 + + for retval in MYSY_GV.dbname['ent_alert_message'].find(data_cle).sort([ ("priorite", pymongo.ASCENDING), ("_id", pymongo.DESCENDING), ]): + user = retval + user['id'] = str(val_tmp) + val_tmp = val_tmp + 1 + 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 messages " + + + """ Cette fonction permet de supprimer une liste de message """ @@ -487,3 +561,149 @@ def Get_Given_Ent_Alert_Message(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 récupérer les données du message " + + +""" +Cette fonction permet publier le message vers l'ENT +""" +def Publish_to_ENT_Alert_Message(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 la liste des arguments ") + 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 + + + local_id = str(diction['_id']) + + data_cle = {} + data_cle['partner_owner_recid'] = str(my_partner['recid']) + data_cle['_id'] = ObjectId(local_id) + data_cle['valide'] = "1" + data_cle['locked'] = "0" + + result = MYSY_GV.dbname['ent_alert_message'].find_one_and_update( + data_cle, + {"$set": {'publish_ent':'1'}}, + upsert=False, + return_document=ReturnDocument.AFTER + ) + + if ("_id" not in result.keys()): + mycommon.myprint( + " Impossible de publier le message vers l'ENT (2) ") + return False, " Impossible de publier le message vers l'ENT (2) " + + return True, " Le message a été correctement publié vers l'ENT" + + 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 publier le message vers l'ENT" + + +""" +Cette fonction permet dépublier le message de l'ENT +""" + + +def Unpublish_to_ENT_Alert_Message(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 la liste des arguments ") + 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 + + local_id = str(diction['_id']) + + data_cle = {} + data_cle['partner_owner_recid'] = str(my_partner['recid']) + data_cle['_id'] = ObjectId(local_id) + data_cle['valide'] = "1" + data_cle['locked'] = "0" + + result = MYSY_GV.dbname['ent_alert_message'].find_one_and_update( + data_cle, + {"$set": {'publish_ent': '0'}}, + upsert=False, + return_document=ReturnDocument.AFTER + ) + + if ("_id" not in result.keys()): + mycommon.myprint( + " Impossible de dépublier le message vers l'ENT (2) ") + return False, " Impossible de dépublier le message vers l'ENT (2) " + + return True, " Le message a été correctement dépublier de l'ENT" + + 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 dépublier le message vers l'ENT" diff --git a/main.py b/main.py index 9333b22..12b7aee 100644 --- a/main.py +++ b/main.py @@ -14714,7 +14714,6 @@ def Get_Given_Ent_Alert_Message(): return jsonify(status=status, message=retval) - """ API pour supprimer une liste de messages d'alerte """ @@ -14730,6 +14729,46 @@ def Delete_Ent_Alert_Message(): +""" +API pour publier liste de messages d'alerte vers l'ENT +""" +@app.route('/myclass/api/Publish_to_ENT_Alert_Message/', methods=['POST','GET']) +@crossdomain(origin='*') +def Publish_to_ENT_Alert_Message(): + # On recupere le corps (payload) de la requete + payload = mycommon.strip_dictionary (request.form.to_dict()) + print(" ### Publish_to_ENT_Alert_Message payload = ",payload) + status, retval = ent_alert_messages.Publish_to_ENT_Alert_Message(payload) + return jsonify(status=status, message=retval) + + +""" +API pour dépublier liste de messages d'alerte vers l'ENT +""" +@app.route('/myclass/api/Unpublish_to_ENT_Alert_Message/', methods=['POST','GET']) +@crossdomain(origin='*') +def Unpublish_to_ENT_Alert_Message(): + # On recupere le corps (payload) de la requete + payload = mycommon.strip_dictionary (request.form.to_dict()) + print(" ### Unpublish_to_ENT_Alert_Message payload = ",payload) + status, retval = ent_alert_messages.Unpublish_to_ENT_Alert_Message(payload) + return jsonify(status=status, message=retval) + + +""" +API pour récuperer la liste des messages publiée sur l'ENT +""" +@app.route('/myclass/api/Get_List_Published_Ent_Alert_Message/', methods=['POST','GET']) +@crossdomain(origin='*') +def Get_List_Published_Ent_Alert_Message(): + # On recupere le corps (payload) de la requete + payload = mycommon.strip_dictionary (request.form.to_dict()) + print(" ### Get_List_Published_Ent_Alert_Message payload = ",payload) + status, retval = ent_alert_messages.Get_List_Published_Ent_Alert_Message(payload) + return jsonify(status=status, message=retval) + + + if __name__ == '__main__':