06/12/2023 - 17h
parent
6d88c835e4
commit
05c360e764
|
@ -1,11 +1,13 @@
|
|||
<?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="04/12/2023 - 21h">
|
||||
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="05/12/2023 - 21h">
|
||||
<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$/attached_file_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/attached_file_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" />
|
||||
|
@ -30,14 +32,14 @@
|
|||
<option name="hideEmptyMiddlePackages" value="true" />
|
||||
<option name="showLibraryContents" value="true" />
|
||||
</component>
|
||||
<component name="PropertiesComponent">{
|
||||
"keyToString": {
|
||||
"RunOnceActivity.OpenProjectViewOnStart": "true",
|
||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||
"last_opened_file_path": "C:/Users/billa/Documents/myclass.com/Siteweb/Production/Ela_back/Back_Office",
|
||||
"settings.editor.selected.configurable": "preferences.lookFeel"
|
||||
<component name="PropertiesComponent"><![CDATA[{
|
||||
"keyToString": {
|
||||
"RunOnceActivity.OpenProjectViewOnStart": "true",
|
||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||
"last_opened_file_path": "C:/Users/billa/Documents/Projet_X/projet_w_siteweb/developpement/PrjX_back",
|
||||
"settings.editor.selected.configurable": "preferences.lookFeel"
|
||||
}
|
||||
}</component>
|
||||
}]]></component>
|
||||
<component name="RecentsManager">
|
||||
<key name="CopyFile.RECENT_KEYS">
|
||||
<recent name="C:\Users\billa\Documents\myclass.com\Siteweb\Production\Ela_back\Back_Office" />
|
||||
|
@ -75,13 +77,6 @@
|
|||
<option name="presentableId" value="Default" />
|
||||
<updated>1680804787304</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00113" summary="26/09/23 - 23h">
|
||||
<created>1695761971078</created>
|
||||
<option name="number" value="00113" />
|
||||
<option name="presentableId" value="LOCAL-00113" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1695761971079</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00114" summary="26/09/23 - 23h">
|
||||
<created>1695805016861</created>
|
||||
<option name="number" value="00114" />
|
||||
|
@ -418,7 +413,14 @@
|
|||
<option name="project" value="LOCAL" />
|
||||
<updated>1701722884013</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="162" />
|
||||
<task id="LOCAL-00162" summary="05/12/2023 - 21h">
|
||||
<created>1701809248688</created>
|
||||
<option name="number" value="00162" />
|
||||
<option name="presentableId" value="LOCAL-00162" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1701809248689</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="163" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="Vcs.Log.Tabs.Properties">
|
||||
|
@ -433,7 +435,6 @@
|
|||
</option>
|
||||
</component>
|
||||
<component name="VcsManagerConfiguration">
|
||||
<MESSAGE value="23/10/2023 - 13h" />
|
||||
<MESSAGE value="23/10/2023 - 16h" />
|
||||
<MESSAGE value="30/10/23 - 16h" />
|
||||
<MESSAGE value="08/11/2023 - 23h" />
|
||||
|
@ -458,6 +459,7 @@
|
|||
<MESSAGE value="30/11/2023 - 21h" />
|
||||
<MESSAGE value="01/12/2023 - 23h" />
|
||||
<MESSAGE value="04/12/2023 - 21h" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="04/12/2023 - 21h" />
|
||||
<MESSAGE value="05/12/2023 - 21h" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="05/12/2023 - 21h" />
|
||||
</component>
|
||||
</project>
|
|
@ -34,6 +34,7 @@ import pysftp
|
|||
import email_mgt as email_mgt
|
||||
import lms_chamilo.mysy_lms as mys_lms
|
||||
from email.message import EmailMessage
|
||||
import attached_file_mgt as attached_file_mgt
|
||||
"""
|
||||
Enregistrement d'un stagiaire
|
||||
|
||||
|
@ -6036,7 +6037,7 @@ adresse email de test, on accepte en non obligatoire
|
|||
Question : Comment traiter les emails envoyées dans la liste des pièces echangés
|
||||
|
||||
"""
|
||||
def Sent_Convention_Stagiaire_By_Email(diction):
|
||||
def Sent_Convention_Stagiaire_By_Email(tab_files, Folder, diction):
|
||||
try:
|
||||
field_list_obligatoire = [ 'token', 'inscription_id', 'courrier_template_id', 'email_test', 'email_production' ]
|
||||
|
||||
|
@ -6070,6 +6071,30 @@ def Sent_Convention_Stagiaire_By_Email(diction):
|
|||
return False, " L'identifiant de l'inscription est invalide "
|
||||
|
||||
|
||||
# Traitement de l'eventuel fichier joint
|
||||
tab_files_to_attache_to_mail = []
|
||||
|
||||
for file in tab_files :
|
||||
|
||||
status, saved_file = mycommon.Upload_Save_PDF_IMG_File(file, Folder)
|
||||
if (status is False):
|
||||
mycommon.myprint("Impossible de récupérer correctement le fichier à importer")
|
||||
return False, "Impossible de récupérer correctement le fichier à importer"
|
||||
|
||||
|
||||
|
||||
file_to_attache_to_mail = MIMEBase('application', "octet-stream")
|
||||
file_to_attache_to_mail.set_payload(open(saved_file, "rb").read())
|
||||
|
||||
encoders.encode_base64(file_to_attache_to_mail)
|
||||
file_to_attache_to_mail.add_header('Content-Disposition', 'attachment; filename="{0}"' .format(os.path.basename(saved_file)))
|
||||
|
||||
new_node = {"attached_file":file_to_attache_to_mail}
|
||||
tab_files_to_attache_to_mail.append(new_node)
|
||||
|
||||
|
||||
|
||||
|
||||
# Verification de la validité des adresses email_recu
|
||||
"""
|
||||
/!\ : Si l'email de test est repli, alors on considere que c'est un test, on ne prend pas en compte l'email de email_production.
|
||||
|
@ -6137,6 +6162,42 @@ def Sent_Convention_Stagiaire_By_Email(diction):
|
|||
'partner_owner_recid': str(my_partner['recid'])}
|
||||
)
|
||||
|
||||
|
||||
# Recuperation des eventuelles pièces jointes du modèle que courrier
|
||||
local_dic = {}
|
||||
local_dic['token'] = str(diction['token'])
|
||||
local_dic['object_owner_collection'] = "courrier_template"
|
||||
local_dic['object_owner_id'] = str(courrier_template_data['_id'])
|
||||
|
||||
|
||||
local_status, local_retval = attached_file_mgt.Get_List_object_owner_collection_Stored_Files(local_dic)
|
||||
if( local_status is False ):
|
||||
return local_status, local_retval
|
||||
|
||||
print(" ### file stocké = ", local_retval)
|
||||
|
||||
# Recuperation des fichiers attachés au modele de courrier, s'il y en a
|
||||
|
||||
|
||||
for file in local_retval:
|
||||
local_JSON = ast.literal_eval(file)
|
||||
|
||||
saved_file = local_JSON['full_path']
|
||||
|
||||
file_to_attache_to_mail = MIMEBase('application', "octet-stream")
|
||||
file_to_attache_to_mail.set_payload(open(saved_file, "rb").read())
|
||||
|
||||
encoders.encode_base64(file_to_attache_to_mail)
|
||||
file_to_attache_to_mail.add_header('Content-Disposition',
|
||||
'attachment; filename="{0}"'.format(os.path.basename(saved_file)))
|
||||
|
||||
new_node = {"attached_file": file_to_attache_to_mail}
|
||||
tab_files_to_attache_to_mail.append(new_node)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#Recuperations des info de la session de formation
|
||||
session_data = MYSY_GV.dbname['session_formation'].find_one({'_id': ObjectId(str(inscription_data['session_id'])),'valide': '1',
|
||||
'partner_owner_recid':str(my_partner['recid'])})
|
||||
|
@ -6222,11 +6283,8 @@ def Sent_Convention_Stagiaire_By_Email(diction):
|
|||
html_mime = MIMEText(sourceHtml, 'html')
|
||||
|
||||
# Creation de l'email à enoyer
|
||||
print("debut envoi mail de test ")
|
||||
msg = MIMEMultipart("alternative")
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Recuperation des parametre SMTP du partner si le client a decidé d'utiliser son propre smpt
|
||||
"""
|
||||
|
@ -6285,6 +6343,10 @@ def Sent_Convention_Stagiaire_By_Email(diction):
|
|||
toaddrs = ", ".join(tab_emails_destinataire)
|
||||
msg['to'] = str(toaddrs)
|
||||
|
||||
# Attacher l'eventuelle pièces jointes
|
||||
for myfile in tab_files_to_attache_to_mail:
|
||||
msg.attach(myfile['attached_file'])
|
||||
|
||||
smtpserver.ehlo()
|
||||
smtpserver.starttls()
|
||||
smtpserver.login(partner_SMTP_COUNT_user, partner_SMTP_COUNT_password)
|
||||
|
@ -6298,6 +6360,11 @@ def Sent_Convention_Stagiaire_By_Email(diction):
|
|||
toaddrs = ", ".join(tab_emails_destinataire)
|
||||
msg['to'] = str(toaddrs)
|
||||
|
||||
|
||||
for myfile in tab_files_to_attache_to_mail:
|
||||
msg.attach(myfile['attached_file'])
|
||||
|
||||
|
||||
smtpserver.ehlo()
|
||||
smtpserver.starttls()
|
||||
smtpserver.login(MYSY_GV.O365_SMTP_COUNT_user, MYSY_GV.O365_SMTP_COUNT_password)
|
||||
|
@ -6401,8 +6468,6 @@ def Sent_Convention_Stagiaire_By_Email_mass(diction):
|
|||
warning_msg = " WARNING : Convocation(s) envoyée(s) avec les erreurs suivantes : \n : "
|
||||
is_warning_msg = False
|
||||
for new_diction in tab_new_diction:
|
||||
print(" #### new_diction = ", new_diction)
|
||||
|
||||
local_status, local_retval = Sent_Convention_Stagiaire_By_Email(new_diction)
|
||||
if( local_status is False):
|
||||
|
||||
|
|
3723
Log/log_file.log
3723
Log/log_file.log
File diff suppressed because it is too large
Load Diff
|
@ -151,6 +151,15 @@ def Store_User_Downloaded_File(file=None, Folder=None, diction=None):
|
|||
if diction['document_display_order']:
|
||||
document_display_order = diction['document_display_order']
|
||||
|
||||
if (len(str(file.filename)) > 100):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " - Fichier invalide, trop long = " + str(
|
||||
file.filename) + ". le nom doit faire moins de 100 caractère")
|
||||
|
||||
return False, " - Nom de fichier trop long. Il doit faire moins de 100 caractères"
|
||||
|
||||
|
||||
mydata = {}
|
||||
mydata['file_business_object'] = file_business_object
|
||||
mydata['date_update'] = str(datetime.now())
|
||||
|
@ -378,7 +387,7 @@ def Get_List_object_owner_collection_Stored_Files(diction):
|
|||
my_query['partner_owner_recid'] = str(my_partner['recid'])
|
||||
|
||||
|
||||
print(" ##### myquery = " + str(my_query))
|
||||
#print(" ##### myquery = " + str(my_query))
|
||||
RetObject = []
|
||||
nb_val = 0
|
||||
for retval in MYSY_GV.dbname['download_files'].find(my_query).sort([("document_display_order", pymongo.DESCENDING)]):
|
||||
|
|
12
main.py
12
main.py
|
@ -4011,9 +4011,19 @@ def Sent_Convention_Stagiaire_By_Email():
|
|||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Sent_Convention_Stagiaire_By_Email payload = ",payload)
|
||||
status, retval = inscription.Sent_Convention_Stagiaire_By_Email(payload)
|
||||
|
||||
file = []
|
||||
if request.method == 'POST':
|
||||
# Create variable for uploaded file
|
||||
tab_files = []
|
||||
for tmp in request.files.getlist("File") :
|
||||
tab_files.append(tmp)
|
||||
|
||||
status, retval = inscription.Sent_Convention_Stagiaire_By_Email(tab_files, app.config['UPLOAD_FOLDER'], payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
|
||||
"""
|
||||
API : Traitement en masse qui permet d'envoyer de le convention du stagiaire par email
|
||||
"""
|
||||
|
|
|
@ -111,6 +111,56 @@ def Upload_Save_CSV_File(file=None, Folder=None):
|
|||
myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
|
||||
return False, "Impossible de traiter le fichier."
|
||||
|
||||
|
||||
|
||||
'''
|
||||
Cette fonction recupere et enregistrer un
|
||||
fichier dans le Dossier "./Data/".
|
||||
|
||||
Seulement les fichier de type PDF et image sont acceptés
|
||||
'''
|
||||
def Upload_Save_PDF_IMG_File(file=None, Folder=None):
|
||||
try:
|
||||
basename = os.path.basename(file.filename)
|
||||
basename2 = basename.split(".")
|
||||
|
||||
|
||||
'''
|
||||
Verification qu'il s'agit bien d'un fichier image ('jpg', 'jpeg', 'png', 'jpe', ...), dont le nom ne comporte pas de "."
|
||||
'''
|
||||
if (len(basename2) != 2):
|
||||
myprint(str(inspect.stack()[0][3]) + " - : Le nom du fichier " + str(file.filename) + " est invalide")
|
||||
return False, "Le nom du fichier " + str(file.filename) + " est invalide "
|
||||
|
||||
if (str(basename2[1]).lower() not in MYSY_GV.IMG_FORMAT and str(basename2[1]).lower() != "pdf"):
|
||||
myprint(str(inspect.stack()[0][3]) + " - : Le fichier " + str(file.filename) + ". L'extention '" + str(
|
||||
basename2[1]) + "' n'est pas un fichier imagep ou pdf. Les extentions autorisées sont :" + str(
|
||||
MYSY_GV.IMG_FORMAT)+" et ['pdf'] ")
|
||||
|
||||
return False, " Le fichier " + str(file.filename) + ". L'extention '" + str(
|
||||
basename2[1]) + "' n'est pas un fichier image ou pfd. Les extentions autorisées sont :" + str(MYSY_GV.IMG_FORMAT) + " et ['pdf'] "
|
||||
|
||||
new_basename2= re.sub(r'[^a-zA-Z0-9]', '', str(basename2[0]))
|
||||
|
||||
timestr = time.strftime("%Y%m%d%H%M%S")
|
||||
local_base_name = str(new_basename2).replace('(', '').replace(')', '').replace(' ', '')
|
||||
new_file_name = str(local_base_name) + "_" + str(timestr) + "." + str(basename2[1])
|
||||
file.filename = new_file_name
|
||||
file.save(os.path.join(str(Folder), secure_filename(file.filename))) # t
|
||||
|
||||
Global_file_name = "./Data/"+file.filename
|
||||
|
||||
|
||||
|
||||
return True, Global_file_name
|
||||
|
||||
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 traiter le fichier."
|
||||
|
||||
|
||||
|
||||
'''
|
||||
Controle de l'import des images.
|
||||
les formats acceptés sont :
|
||||
|
|
Loading…
Reference in New Issue