04/12/2023 - 21h
parent
a0b197164e
commit
6cf91d8f9e
|
@ -3,9 +3,11 @@
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="01/12/2023 - 23h">
|
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="01/12/2023 - 23h">
|
||||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/Dashbord_queries/session_tbd_qries.py" beforeDir="false" afterPath="$PROJECT_DIR$/Dashbord_queries/session_tbd_qries.py" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/Inscription_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/Inscription_mgt.py" 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$/Log/log_file.log" beforeDir="false" afterPath="$PROJECT_DIR$/Log/log_file.log" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/partner_document_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/partner_document_mgt.py" afterDir="false" />
|
||||||
</list>
|
</list>
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||||
|
|
|
@ -728,8 +728,6 @@ def Export_Dashbord_To_Csv(diction):
|
||||||
my_new_diction['session_end_date'] = session_end_date
|
my_new_diction['session_end_date'] = session_end_date
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if( my_user_dashbord['dashbord_internal_code'] == "tbd_code_session_01"):
|
if( my_user_dashbord['dashbord_internal_code'] == "tbd_code_session_01"):
|
||||||
local_status, local_retval = Get_Qery_List_Session_Data(my_new_diction)
|
local_status, local_retval = Get_Qery_List_Session_Data(my_new_diction)
|
||||||
if( local_status is False):
|
if( local_status is False):
|
||||||
|
|
|
@ -6124,14 +6124,18 @@ def Sent_Convention_Stagiaire_By_Email(diction):
|
||||||
return False, " Aucune adresse email n'a été fourni. "
|
return False, " Aucune adresse email n'a été fourni. "
|
||||||
|
|
||||||
# Verifier que le 'courrier_template_id' est valide
|
# Verifier que le 'courrier_template_id' est valide
|
||||||
|
# Ici le template doit etre un PDF
|
||||||
qry = {'_id':ObjectId(str(diction['courrier_template_id'])),
|
qry = {'_id':ObjectId(str(diction['courrier_template_id'])),
|
||||||
'valide':'1',
|
'valide':'1',
|
||||||
'locked':'0',
|
'locked':'0',
|
||||||
|
'type_doc':'email',
|
||||||
|
|
||||||
'partner_owner_recid': str(my_partner['recid'])}
|
'partner_owner_recid': str(my_partner['recid'])}
|
||||||
|
|
||||||
print( " ### qry = ", qry)
|
print( " ### qry = ", qry)
|
||||||
is_courrier_template_id_valide = MYSY_GV.dbname['courrier_template'].count_documents({'_id':ObjectId(str(diction['courrier_template_id'])),
|
is_courrier_template_id_valide = MYSY_GV.dbname['courrier_template'].count_documents({'_id':ObjectId(str(diction['courrier_template_id'])),
|
||||||
'valide':'1',
|
'valide':'1',
|
||||||
|
'type_doc': 'email',
|
||||||
'locked':'0',
|
'locked':'0',
|
||||||
'partner_owner_recid': str(my_partner['recid'])}
|
'partner_owner_recid': str(my_partner['recid'])}
|
||||||
)
|
)
|
||||||
|
@ -6174,23 +6178,7 @@ def Sent_Convention_Stagiaire_By_Email(diction):
|
||||||
|
|
||||||
sourceHtml = contenu_doc_Template.render(params=convention_dictionnary_data)
|
sourceHtml = contenu_doc_Template.render(params=convention_dictionnary_data)
|
||||||
|
|
||||||
todays_date = str(date.today().strftime("%d/%m/%Y"))
|
|
||||||
ts = datetime.now().timestamp()
|
|
||||||
ts = str(ts).replace(".", "").replace(",", "")[-5:]
|
|
||||||
|
|
||||||
orig_file_name = "Convention_" + str(my_partner['recid']) + "_" + str(ts) + ".pdf"
|
|
||||||
outputFilename = str(MYSY_GV.TEMPORARY_DIRECTORY) + "/" + str(orig_file_name)
|
|
||||||
|
|
||||||
# open output file for writing (truncated binary)
|
|
||||||
resultFile = open(outputFilename, "w+b")
|
|
||||||
|
|
||||||
# convert HTML to PDF
|
|
||||||
pisaStatus = pisa.CreatePDF(
|
|
||||||
src=sourceHtml, # the HTML to convert
|
|
||||||
dest=resultFile) # file handle to receive result
|
|
||||||
|
|
||||||
# close output file
|
|
||||||
resultFile.close()
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Corps du mail qui accompagne le pdf
|
Corps du mail qui accompagne le pdf
|
||||||
|
@ -6208,18 +6196,12 @@ def Sent_Convention_Stagiaire_By_Email(diction):
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>'''
|
</html>'''
|
||||||
html_mime = MIMEText(corp_mail, 'html')
|
html_mime = MIMEText(sourceHtml, 'html')
|
||||||
|
|
||||||
# Creation de l'email à enoyer
|
# Creation de l'email à enoyer
|
||||||
print("debut envoi mail de test ")
|
print("debut envoi mail de test ")
|
||||||
msg = MIMEMultipart("alternative")
|
msg = MIMEMultipart("alternative")
|
||||||
|
|
||||||
#f = './Invoices/aaa.pdf'
|
|
||||||
part = MIMEBase('application', "octet-stream")
|
|
||||||
part.set_payload(open(outputFilename, "rb").read())
|
|
||||||
encoders.encode_base64(part)
|
|
||||||
part.add_header('Content-Disposition', 'attachment; filename="{0}"'
|
|
||||||
.format(os.path.basename(outputFilename)))
|
|
||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
@ -6273,7 +6255,6 @@ def Sent_Convention_Stagiaire_By_Email(diction):
|
||||||
|
|
||||||
if (str(partner_own_smtp_value) == "1"):
|
if (str(partner_own_smtp_value) == "1"):
|
||||||
msg.attach(html_mime)
|
msg.attach(html_mime)
|
||||||
msg.attach(part)
|
|
||||||
msg['From'] = partner_SMTP_COUNT_From_User
|
msg['From'] = partner_SMTP_COUNT_From_User
|
||||||
msg['Bcc'] = 'contact@mysy-training.com'
|
msg['Bcc'] = 'contact@mysy-training.com'
|
||||||
msg['Subject'] = courrier_template_data['sujet']
|
msg['Subject'] = courrier_template_data['sujet']
|
||||||
|
@ -6285,7 +6266,6 @@ def Sent_Convention_Stagiaire_By_Email(diction):
|
||||||
|
|
||||||
else:
|
else:
|
||||||
msg.attach(html_mime)
|
msg.attach(html_mime)
|
||||||
msg.attach(part)
|
|
||||||
msg['From'] = MYSY_GV.O365_SMTP_COUNT_From_User
|
msg['From'] = MYSY_GV.O365_SMTP_COUNT_From_User
|
||||||
msg['Bcc'] = 'contact@mysy-training.com'
|
msg['Bcc'] = 'contact@mysy-training.com'
|
||||||
msg['Subject'] = courrier_template_data['sujet']
|
msg['Subject'] = courrier_template_data['sujet']
|
||||||
|
@ -6304,4 +6284,125 @@ def Sent_Convention_Stagiaire_By_Email(diction):
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||||
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - Line : " + str(exc_tb.tb_lineno))
|
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 conventions"
|
return False, " Impossible d'envoyer la convention par email "
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
"""
|
||||||
|
Impression de la convetion en mode PDF
|
||||||
|
"""
|
||||||
|
|
||||||
|
def Download_Convention_Stagiaire_PDF(diction):
|
||||||
|
try:
|
||||||
|
field_list_obligatoire = ['token', 'inscription_id', 'courrier_template_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, " La valeur '" + val + "' n'est pas presente dans liste"
|
||||||
|
|
||||||
|
my_token = ""
|
||||||
|
if ("token" in diction.keys()):
|
||||||
|
if diction['token']:
|
||||||
|
my_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 le stagiaire est bien inscrit. Le statut de l'inscription doit etre "1"
|
||||||
|
is_inscription_valide = MYSY_GV.dbname['inscription'].count_documents(
|
||||||
|
{'_id': ObjectId(str(diction['inscription_id'])),
|
||||||
|
'status': '1',
|
||||||
|
'partner_owner_recid': str(my_partner['recid'])})
|
||||||
|
|
||||||
|
if (is_inscription_valide != 1):
|
||||||
|
mycommon.myprint(
|
||||||
|
str(inspect.stack()[0][
|
||||||
|
3]) + " L'identifiant de l'inscription est invalide ")
|
||||||
|
return False, " L'identifiant de l'inscription est invalide "
|
||||||
|
|
||||||
|
|
||||||
|
# Verifier que le 'courrier_template_id' est valide. il doit etre de type PDF
|
||||||
|
qry = {'_id': ObjectId(str(diction['courrier_template_id'])),
|
||||||
|
'valide': '1',
|
||||||
|
'locked': '0',
|
||||||
|
'type_doc':'pdf',
|
||||||
|
'partner_owner_recid': str(my_partner['recid'])}
|
||||||
|
|
||||||
|
print(" ### qry = ", qry)
|
||||||
|
is_courrier_template_id_valide = MYSY_GV.dbname['courrier_template'].count_documents(
|
||||||
|
{'_id': ObjectId(str(diction['courrier_template_id'])),
|
||||||
|
'valide': '1',
|
||||||
|
'locked': '0',
|
||||||
|
'type_doc': 'pdf',
|
||||||
|
'partner_owner_recid': str(my_partner['recid'])}
|
||||||
|
)
|
||||||
|
|
||||||
|
if (is_courrier_template_id_valide != 1):
|
||||||
|
mycommon.myprint(str(inspect.stack()[0][3]) + " L'identifiant du modèle de courrier est invalide ")
|
||||||
|
return False, " L'identifiant du modèle de courrier est invalide "
|
||||||
|
|
||||||
|
# Recuperation des données du stagaire
|
||||||
|
inscription_data = MYSY_GV.dbname['inscription'].find_one({'_id': ObjectId(str(diction['inscription_id'])),
|
||||||
|
'status': '1',
|
||||||
|
'partner_owner_recid': str(my_partner['recid'])})
|
||||||
|
|
||||||
|
# Recupération des données du modèle de document
|
||||||
|
courrier_template_data = MYSY_GV.dbname['courrier_template'].find_one(
|
||||||
|
{'_id': ObjectId(str(diction['courrier_template_id'])),
|
||||||
|
'valide': '1',
|
||||||
|
'locked': '0',
|
||||||
|
'partner_owner_recid': str(my_partner['recid'])}
|
||||||
|
)
|
||||||
|
|
||||||
|
# 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'])})
|
||||||
|
|
||||||
|
# Recuperation du titre de la formation
|
||||||
|
class_data = MYSY_GV.dbname['myclass'].find_one(
|
||||||
|
{'internal_url': str(session_data['class_internal_url']), 'valide': '1',
|
||||||
|
'partner_owner_recid': str(my_partner['recid']), 'locked': '0'})
|
||||||
|
|
||||||
|
# Creation du dictionnaire d'information à utiliser pour la creation du doc
|
||||||
|
convention_dictionnary_data = {}
|
||||||
|
## Creation du PDF
|
||||||
|
contenu_doc_Template = jinja2.Template(str(courrier_template_data['contenu_doc']))
|
||||||
|
|
||||||
|
sourceHtml = contenu_doc_Template.render(params=convention_dictionnary_data)
|
||||||
|
|
||||||
|
todays_date = str(date.today().strftime("%d/%m/%Y"))
|
||||||
|
ts = datetime.now().timestamp()
|
||||||
|
ts = str(ts).replace(".", "").replace(",", "")[-5:]
|
||||||
|
|
||||||
|
orig_file_name = "Convention_" + str(my_partner['recid']) + "_" + str(ts) + ".pdf"
|
||||||
|
outputFilename = str(MYSY_GV.TEMPORARY_DIRECTORY) + "/" + str(orig_file_name)
|
||||||
|
|
||||||
|
# open output file for writing (truncated binary)
|
||||||
|
resultFile = open(outputFilename, "w+b")
|
||||||
|
|
||||||
|
# convert HTML to PDF
|
||||||
|
pisaStatus = pisa.CreatePDF(
|
||||||
|
src=sourceHtml, # the HTML to convert
|
||||||
|
dest=resultFile) # file handle to receive result
|
||||||
|
|
||||||
|
# close output file
|
||||||
|
resultFile.close()
|
||||||
|
|
||||||
|
if os.path.exists(outputFilename):
|
||||||
|
#print(" ### ok os.path.exists(outputFilename) "+str(outputFilename))
|
||||||
|
return True, send_file(outputFilename, as_attachment=True)
|
||||||
|
|
||||||
|
return False, " Impossible de générer le fichier PDF (2) "
|
||||||
|
|
||||||
|
|
||||||
|
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 générer le fichier PDF (2) "
|
||||||
|
|
||||||
|
|
||||||
|
|
1059
Log/log_file.log
1059
Log/log_file.log
File diff suppressed because it is too large
Load Diff
40
main.py
40
main.py
|
@ -4003,7 +4003,7 @@ def Get_List_Conventions_Stagiaire():
|
||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Envoie de le convention du stagiaire
|
API qui permet d'envoyer de le convention du stagiaire par email
|
||||||
"""
|
"""
|
||||||
@app.route('/myclass/api/Sent_Convention_Stagiaire_By_Email/', methods=['POST','GET'])
|
@app.route('/myclass/api/Sent_Convention_Stagiaire_By_Email/', methods=['POST','GET'])
|
||||||
@crossdomain(origin='*')
|
@crossdomain(origin='*')
|
||||||
|
@ -4015,6 +4015,28 @@ def Sent_Convention_Stagiaire_By_Email():
|
||||||
return jsonify(status=status, message=retval)
|
return jsonify(status=status, message=retval)
|
||||||
|
|
||||||
|
|
||||||
|
"""
|
||||||
|
API qui permet de telecharger la convention en mode PDF
|
||||||
|
"""
|
||||||
|
@app.route('/myclass/api/Download_Convention_Stagiaire_PDF/<token>/<inscription_id>/<courrier_template_id>', methods=['POST','GET'])
|
||||||
|
@crossdomain(origin='*')
|
||||||
|
def Download_Convention_Stagiaire_PDF(token, inscription_id, courrier_template_id):
|
||||||
|
# On recupere le corps (payload) de la requete
|
||||||
|
payload = mycommon.strip_dictionary(request.form.to_dict())
|
||||||
|
payload['token'] = str(token)
|
||||||
|
payload['inscription_id'] = str(inscription_id)
|
||||||
|
payload['courrier_template_id'] = str(courrier_template_id)
|
||||||
|
|
||||||
|
|
||||||
|
print(" ### Download_Convention_Stagiaire_PDF payload = ",payload)
|
||||||
|
|
||||||
|
status, retval = inscription.Download_Convention_Stagiaire_PDF(payload)
|
||||||
|
if (status):
|
||||||
|
return retval
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
@ -4964,6 +4986,21 @@ def Get_Given_Personnalisable_Fields_By_courrier_template_id():
|
||||||
return jsonify(status=status, message=retval)
|
return jsonify(status=status, message=retval)
|
||||||
|
|
||||||
|
|
||||||
|
"""
|
||||||
|
API qui permet de dupliquer un document personnalisé
|
||||||
|
"""
|
||||||
|
|
||||||
|
@app.route('/myclass/api/Duplicate_Given_Partner_Document/', methods=['POST','GET'])
|
||||||
|
@crossdomain(origin='*')
|
||||||
|
def Duplicate_Given_Partner_Document():
|
||||||
|
# On recupere le corps (payload) de la requete
|
||||||
|
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||||
|
print(" ### Duplicate_Given_Partner_Document payload = ",payload)
|
||||||
|
status, retval = partner_document_mgt.Duplicate_Given_Partner_Document(payload)
|
||||||
|
return jsonify(status=status, message=retval)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
@ -5862,7 +5899,6 @@ def Export_Dashbord_To_Csv(token, user_dashbord_id):
|
||||||
payload['token'] = str(token)
|
payload['token'] = str(token)
|
||||||
payload['user_dashbord_id'] = str(user_dashbord_id)
|
payload['user_dashbord_id'] = str(user_dashbord_id)
|
||||||
|
|
||||||
|
|
||||||
print(" ### Export_Dashbord_To_Csv payload = ",payload)
|
print(" ### Export_Dashbord_To_Csv payload = ",payload)
|
||||||
|
|
||||||
status, retval = session_tbd_qries.Export_Dashbord_To_Csv(payload)
|
status, retval = session_tbd_qries.Export_Dashbord_To_Csv(payload)
|
||||||
|
|
|
@ -489,6 +489,8 @@ def Get_List_Partner_Document(diction):
|
||||||
for retval in MYSY_GV.dbname['courrier_template'].find(data_cle):
|
for retval in MYSY_GV.dbname['courrier_template'].find(data_cle):
|
||||||
user = retval
|
user = retval
|
||||||
user['id'] = str(val_tmp)
|
user['id'] = str(val_tmp)
|
||||||
|
if ("duplicate" not in retval.keys()):
|
||||||
|
user['duplicate'] = "0"
|
||||||
val_tmp = val_tmp + 1
|
val_tmp = val_tmp + 1
|
||||||
RetObject.append(mycommon.JSONEncoder().encode(user))
|
RetObject.append(mycommon.JSONEncoder().encode(user))
|
||||||
|
|
||||||
|
@ -780,6 +782,9 @@ def Get_List_Partner_Document_no_filter(diction):
|
||||||
user = retval
|
user = retval
|
||||||
user['id'] = str(val_tmp)
|
user['id'] = str(val_tmp)
|
||||||
val_tmp = val_tmp + 1
|
val_tmp = val_tmp + 1
|
||||||
|
if( "duplicate" not in retval.keys()):
|
||||||
|
user['duplicate'] = "0"
|
||||||
|
|
||||||
RetObject.append(mycommon.JSONEncoder().encode(user))
|
RetObject.append(mycommon.JSONEncoder().encode(user))
|
||||||
|
|
||||||
return True, RetObject
|
return True, RetObject
|
||||||
|
@ -1105,3 +1110,91 @@ def Get_Given_Personnalisable_Fields_By_courrier_template_id(diction):
|
||||||
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - Line : " + str(exc_tb.tb_lineno))
|
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - Line : " + str(exc_tb.tb_lineno))
|
||||||
return False, " Impossible de récupérer les champs personnalisables de l'objet "
|
return False, " Impossible de récupérer les champs personnalisables de l'objet "
|
||||||
|
|
||||||
|
|
||||||
|
"""
|
||||||
|
Dupliquer un document
|
||||||
|
"""
|
||||||
|
def Duplicate_Given_Partner_Document(diction):
|
||||||
|
try:
|
||||||
|
diction = mycommon.strip_dictionary(diction)
|
||||||
|
|
||||||
|
"""
|
||||||
|
Verification des input acceptés
|
||||||
|
"""
|
||||||
|
field_list = ['token', '_id', 'nom', 'sujet', 'type_doc']
|
||||||
|
|
||||||
|
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 = field_list = ['token', '_id', 'nom', 'sujet', 'type_doc']
|
||||||
|
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 le document existe et qu"il est bien duplicable
|
||||||
|
"""
|
||||||
|
is_document_valide = MYSY_GV.dbname['courrier_template'].count_documents({'_id':ObjectId(str(diction['_id'])),
|
||||||
|
'valide':'1',
|
||||||
|
'locked':'0',
|
||||||
|
'duplicate':'1',
|
||||||
|
'partner_owner_recid':str(my_partner['recid'])
|
||||||
|
})
|
||||||
|
|
||||||
|
if(is_document_valide != 1 ):
|
||||||
|
mycommon.myprint(
|
||||||
|
str(inspect.stack()[0][3]) + " - L'identifiant du modèle de courrier est invalide ")
|
||||||
|
return False, " L'identifiant du modèle de courrier est invalide ",
|
||||||
|
|
||||||
|
is_document_data = MYSY_GV.dbname['courrier_template'].find_one({'_id': ObjectId(str(diction['_id'])),
|
||||||
|
'valide': '1',
|
||||||
|
'locked': '0',
|
||||||
|
'duplicate': '1',
|
||||||
|
'partner_owner_recid': str(
|
||||||
|
my_partner['recid'])
|
||||||
|
})
|
||||||
|
|
||||||
|
new_document = is_document_data
|
||||||
|
del new_document['_id']
|
||||||
|
|
||||||
|
new_document['date_update'] = str(datetime.now())
|
||||||
|
new_document['update_by'] = str(my_partner['_id'])
|
||||||
|
new_document['type_doc'] = str(diction['type_doc'])
|
||||||
|
new_document['nom'] = str(diction['nom'])
|
||||||
|
new_document['sujet'] = str(diction['sujet'])
|
||||||
|
|
||||||
|
|
||||||
|
inserted_id = MYSY_GV.dbname['courrier_template'].insert_one(new_document).inserted_id
|
||||||
|
if (not inserted_id):
|
||||||
|
mycommon.myprint(
|
||||||
|
" Impossible de dupliquer le document (1) ")
|
||||||
|
return False, " Impossible de dupliquer le document (1) "
|
||||||
|
|
||||||
|
|
||||||
|
return True, "Le document a été correctement dupliqué "
|
||||||
|
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 du dupliquer le document "
|
Loading…
Reference in New Issue