17/01/2023 - 20h

master
cherif 2023-01-17 19:35:54 +01:00
parent 3c7b40fac1
commit 0af72c415e
5 changed files with 5581 additions and 7 deletions

View File

@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="1122d9e2-679f-46d6-8c4f-97e9ae4041b5" name="Changes" comment="13/01/22 à 20h">
<list default="true" id="1122d9e2-679f-46d6-8c4f-97e9ae4041b5" name="Changes" comment="15/01/2023 - 22h">
<change afterPath="$PROJECT_DIR$/tools_cherif/tools_cherif.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Inscription_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/Inscription_mgt.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$/Session_Formation.py" beforeDir="false" afterPath="$PROJECT_DIR$/Session_Formation.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/class_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/class_mgt.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/prj_common.py" beforeDir="false" afterPath="$PROJECT_DIR$/prj_common.py" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -198,7 +198,14 @@
<option name="project" value="LOCAL" />
<updated>1673777794415</updated>
</task>
<option name="localTasksCounter" value="19" />
<task id="LOCAL-00019" summary="15/01/2023 - 22h">
<created>1673817096179</created>
<option name="number" value="00019" />
<option name="presentableId" value="LOCAL-00019" />
<option name="project" value="LOCAL" />
<updated>1673817096179</updated>
</task>
<option name="localTasksCounter" value="20" />
<servers />
</component>
<component name="Vcs.Log.Tabs.Properties">
@ -230,7 +237,8 @@
<MESSAGE value="27/12/2022 - 16h00" />
<MESSAGE value="09/01/22 à 11h" />
<MESSAGE value="13/01/22 à 20h" />
<option name="LAST_COMMIT_MESSAGE" value="13/01/22 à 20h" />
<MESSAGE value="15/01/2023 - 22h" />
<option name="LAST_COMMIT_MESSAGE" value="15/01/2023 - 22h" />
</component>
<component name="XDebuggerManager">
<breakpoint-manager>

File diff suppressed because it is too large Load Diff

29
main.py
View File

@ -36,6 +36,7 @@ import email_mgt as emails
import email_inscription_mgt as emails_support
import opco as opco
import Attestation_Certificat as Att_Cert
import tools_cherif.tools_cherif as tools_cherif
app = Flask(__name__)
cors = CORS(app, resources={r"/foo": {"origins": "*"}})
@ -2289,6 +2290,34 @@ def get_List_domaine_metier():
localStatus, message= mycommon.get_List_domaine_metier()
return jsonify(status=localStatus, message=message )
"""
API de verification de la vlidation d'un email
"""
@app.route('/myclass/api/email_validation/', methods=['POST','GET'])
@crossdomain(origin='*')
def email_validation():
# On recupere le corps (payload) de la requete
payload = request.form.to_dict()
print(" ### email_validation : payload = ",payload)
localStatus, message= tools_cherif.email_validation()
return jsonify(status=localStatus, message=message )
"""
Cette API permet de desabonner une personne
"""
@app.route('/myclass/api/Sedesabonner/', methods=['POST','GET'])
@crossdomain(origin='*')
def Sedesabonner():
# On recupere le corps (payload) de la requete
payload = request.form.to_dict()
print(" ### Sedesabonner : payload = ",payload)
localStatus, message= mycommon.Sedesabonner(payload)
return jsonify(status=localStatus, message=message )
if __name__ == '__main__':
print(" debut api")
context = SSL.Context(SSL.SSLv23_METHOD)

View File

@ -2660,4 +2660,52 @@ def format_MySy_Text_Tag(sentence):
sentence = sentence.replace("<s>", "<u>")
sentence = sentence.replace("</s>", "</u>")
return sentence
return sentence
"""
Cette fonction permet gerer le desabonnement d'une personne.
par defaut, l'adresse email recu est mis dans la collection 'mail_blacklist'
"""
def Sedesabonner(diction):
try:
field_list_obligatoire = ['email',]
for val in field_list_obligatoire:
if val not in diction:
myprint(
str(inspect.stack()[0][3]) + " - La valeur '" + val + "' n'est pas presente dans liste ")
return False, " Impossible de finaliser le desabonnement."
mydata = {}
mydata['email'] = diction['email']
mytoday = datetime.today().strftime("%d/%m/%Y")[0:10]
mydata['date_blacklist'] = mytoday
coll_name = MYSY_GV.dbname['mail_blacklist']
ret_val = coll_name.find_one_and_update(
{'email': str(diction['email'])},
{"$set": mydata},
upsert=True,
return_document=ReturnDocument.AFTER
)
if (ret_val and ret_val['_id']):
nb_doc = str(ret_val['_id'])
myprint(
str(inspect.stack()[0][3]) + " - l'adresse email =" + str(diction['email'])+" a été retirée" )
return True, " l'adresse email =" + str(diction['email'])+" a été retirée"
else:
myprint(str(inspect.stack()[0][3]) + " Impossible de desactivier l'adresse email : " +str(diction['email']))
return False, " Impossible de desactivier l'adresse email : " +str(diction['email'])
except Exception as e:
exc_type, exc_obj, exc_tb = sys.exc_info()
myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
return False, " Impossible de desactivier l'adresse email "

View File

@ -0,0 +1,78 @@
import pymongo
from pymongo import MongoClient
import json
from bson import ObjectId
import re
from datetime import datetime
import prj_common as mycommon
import secrets
import inspect
import sys, os
import csv
import pandas as pd
from pymongo import ReturnDocument
from math import isnan
import GlobalVariable as MYSY_GV
import ela_index_bdd_classes as eibdd
import email_mgt as email
from validate_email import validate_email
def email_validation():
try:
coll_emails = MYSY_GV.dbname['bdd_email']
cpt = 0
for val in coll_emails.find({'valide':'1', "checked_status": {"$ne": "1"}}):
cpt = cpt + 1
if ("email_address" in val.keys()):
is_valid = validate_email(
email_address=val['email_address'],
check_format=True,
check_blacklist=True,
check_dns=True,
dns_timeout=5,
check_smtp=True,
smtp_timeout=5,
smtp_helo_host='smtp.office365.com',
smtp_from_address='support@mysy-training.com',
smtp_skip_tls=False,
smtp_tls_context=None,
smtp_debug=False)
retval = ""
checked_status = ""
if( is_valid ):
#print(" ### l'adresse ",val['email_address']," est valide ")
retval = True
checked_status = "1"
else:
#print(" ### l'adresse ", val['email_address'], " N'EST PAS valide ")
retval = False
checked_status = "0"
mydata = {}
mytoday = datetime.today().strftime("%d/%m/%Y")
mydata['last_check_date'] = str(mytoday)[0:10]
mydata['checked'] = str("1")
mydata['checked_status'] = str(checked_status)
ret_val = coll_emails.find_one_and_update(
{'email_address': str(val['email_address']), 'valide': '1'},
{"$set": mydata},
return_document=ReturnDocument.AFTER
)
print(" ### "+str(cpt)+" email traité")
return retval, str(cpt)+" adresse email ont été mise à 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 recuperer la formation"