01/08/230- 21h
parent
3796da55ab
commit
e855d8508b
|
@ -1,14 +1,12 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="29/07/23 - 29h">
|
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="30/07/23 - 17h">
|
||||||
<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$/Activite.py" beforeDir="false" afterPath="$PROJECT_DIR$/Activite.py" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/Contact.py" beforeDir="false" afterPath="$PROJECT_DIR$/Contact.py" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/GlobalVariable.py" beforeDir="false" afterPath="$PROJECT_DIR$/GlobalVariable.py" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/GlobalVariable.py" beforeDir="false" afterPath="$PROJECT_DIR$/GlobalVariable.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$/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$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/partners.py" beforeDir="false" afterPath="$PROJECT_DIR$/partners.py" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/prj_common.py" beforeDir="false" afterPath="$PROJECT_DIR$/prj_common.py" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/prj_common.py" beforeDir="false" afterPath="$PROJECT_DIR$/prj_common.py" afterDir="false" />
|
||||||
</list>
|
</list>
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
|
@ -73,13 +71,6 @@
|
||||||
<option name="presentableId" value="Default" />
|
<option name="presentableId" value="Default" />
|
||||||
<updated>1680804787304</updated>
|
<updated>1680804787304</updated>
|
||||||
</task>
|
</task>
|
||||||
<task id="LOCAL-00007" summary="15/04/23 - 22h">
|
|
||||||
<created>1681588140722</created>
|
|
||||||
<option name="number" value="00007" />
|
|
||||||
<option name="presentableId" value="LOCAL-00007" />
|
|
||||||
<option name="project" value="LOCAL" />
|
|
||||||
<updated>1681588140722</updated>
|
|
||||||
</task>
|
|
||||||
<task id="LOCAL-00008" summary="20/04/23 - 16h">
|
<task id="LOCAL-00008" summary="20/04/23 - 16h">
|
||||||
<created>1681998167874</created>
|
<created>1681998167874</created>
|
||||||
<option name="number" value="00008" />
|
<option name="number" value="00008" />
|
||||||
|
@ -416,7 +407,14 @@
|
||||||
<option name="project" value="LOCAL" />
|
<option name="project" value="LOCAL" />
|
||||||
<updated>1690661811531</updated>
|
<updated>1690661811531</updated>
|
||||||
</task>
|
</task>
|
||||||
<option name="localTasksCounter" value="56" />
|
<task id="LOCAL-00056" summary="30/07/23 - 17h">
|
||||||
|
<created>1690731459970</created>
|
||||||
|
<option name="number" value="00056" />
|
||||||
|
<option name="presentableId" value="LOCAL-00056" />
|
||||||
|
<option name="project" value="LOCAL" />
|
||||||
|
<updated>1690731459971</updated>
|
||||||
|
</task>
|
||||||
|
<option name="localTasksCounter" value="57" />
|
||||||
<servers />
|
<servers />
|
||||||
</component>
|
</component>
|
||||||
<component name="Vcs.Log.Tabs.Properties">
|
<component name="Vcs.Log.Tabs.Properties">
|
||||||
|
@ -431,7 +429,6 @@
|
||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
<component name="VcsManagerConfiguration">
|
<component name="VcsManagerConfiguration">
|
||||||
<MESSAGE value="02/06/23 - 22h" />
|
|
||||||
<MESSAGE value="05/06/23 - 15h" />
|
<MESSAGE value="05/06/23 - 15h" />
|
||||||
<MESSAGE value="06/06/23 - 19h" />
|
<MESSAGE value="06/06/23 - 19h" />
|
||||||
<MESSAGE value="08/06/23 - 21h" />
|
<MESSAGE value="08/06/23 - 21h" />
|
||||||
|
@ -456,6 +453,7 @@
|
||||||
<MESSAGE value="27/07/23 - 23h" />
|
<MESSAGE value="27/07/23 - 23h" />
|
||||||
<MESSAGE value="28/07/23 - 19h" />
|
<MESSAGE value="28/07/23 - 19h" />
|
||||||
<MESSAGE value="29/07/23 - 29h" />
|
<MESSAGE value="29/07/23 - 29h" />
|
||||||
<option name="LAST_COMMIT_MESSAGE" value="29/07/23 - 29h" />
|
<MESSAGE value="30/07/23 - 17h" />
|
||||||
|
<option name="LAST_COMMIT_MESSAGE" value="30/07/23 - 17h" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
|
@ -443,5 +443,12 @@ annulé : -1
|
||||||
|
|
||||||
ACTIVITE_STATUS = ['0', '-1', '1']
|
ACTIVITE_STATUS = ['0', '-1', '1']
|
||||||
|
|
||||||
|
"""
|
||||||
|
Les types d'image authorisé a etre stockés en base de données
|
||||||
|
"""
|
||||||
|
BDD_STOCKAGE_IMG = ['logo', 'cachet']
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
3330
Log/log_file.log
3330
Log/log_file.log
File diff suppressed because it is too large
Load Diff
25
main.py
25
main.py
|
@ -659,8 +659,15 @@ Cette fonction modifie/MAJ un partenaire
|
||||||
def update_partner_account():
|
def update_partner_account():
|
||||||
# On recupere le corps (payload) de la requete
|
# On recupere le corps (payload) de la requete
|
||||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||||
print(" ### payload = ",payload)
|
print(" ### update_partner_account payload = ",payload)
|
||||||
status, retval = pa.update_partner_account(payload)
|
|
||||||
|
if request.method == 'POST':
|
||||||
|
# Create variable for uploaded file
|
||||||
|
file_logo = request.files['file_logo']
|
||||||
|
file_cachet = request.files['file_cachet']
|
||||||
|
|
||||||
|
status, retval = pa.update_partner_account(file_logo,file_cachet, app.config['UPLOAD_FOLDER'], payload)
|
||||||
|
|
||||||
return jsonify(status=status, message=retval)
|
return jsonify(status=status, message=retval)
|
||||||
|
|
||||||
|
|
||||||
|
@ -717,11 +724,23 @@ Cette fonction recupere les données d'un partenaire
|
||||||
def get_partner_account():
|
def get_partner_account():
|
||||||
# On recupere le corps (payload) de la requete
|
# On recupere le corps (payload) de la requete
|
||||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||||
print(" ### payload = ",payload)
|
print(" ### get_partner_account payload = ",payload)
|
||||||
status, retval = pa.get_partner_account(payload)
|
status, retval = pa.get_partner_account(payload)
|
||||||
return jsonify(status=status, message=retval)
|
return jsonify(status=status, message=retval)
|
||||||
|
|
||||||
|
|
||||||
|
"""
|
||||||
|
Recuperation des images/media d'un partenaire
|
||||||
|
"""
|
||||||
|
@app.route('/myclass/api/getRecodedParnterImage_from_front/', methods=['POST','GET'])
|
||||||
|
@crossdomain(origin='*')
|
||||||
|
def getRecodedParnterImage_from_front():
|
||||||
|
# On recupere le corps (payload) de la requete
|
||||||
|
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||||
|
print(" ### getRecodedParnterImage_from_front payload = ",payload)
|
||||||
|
status, retval = pa.getRecodedParnterImage_from_front(payload)
|
||||||
|
return jsonify(status=status, message=retval)
|
||||||
|
|
||||||
|
|
||||||
'''
|
'''
|
||||||
Cette API index la base donnée.
|
Cette API index la base donnée.
|
||||||
|
|
112
partners.py
112
partners.py
|
@ -535,7 +535,7 @@ def update_partner_insert_key(diction):
|
||||||
MAJ d'un partenaire.
|
MAJ d'un partenaire.
|
||||||
la clé est l'adresse email principale
|
la clé est l'adresse email principale
|
||||||
'''
|
'''
|
||||||
def update_partner_account(diction):
|
def update_partner_account(file_logo=None, file_cachet=None, Folder=None, diction=None):
|
||||||
try:
|
try:
|
||||||
|
|
||||||
# Dictionnaire des champs utilisables
|
# Dictionnaire des champs utilisables
|
||||||
|
@ -551,7 +551,9 @@ def update_partner_account(diction):
|
||||||
'invoice_nom', 'invoice_adr_street', 'invoice_adr_city', 'invoice_adr_zip',
|
'invoice_nom', 'invoice_adr_street', 'invoice_adr_city', 'invoice_adr_zip',
|
||||||
'invoice_adr_country', 'invoice_email', 'invoice_telephone', 'invoice_vat_num',
|
'invoice_adr_country', 'invoice_email', 'invoice_telephone', 'invoice_vat_num',
|
||||||
'siren', 'num_nda', 'iscertitrace', 'isdatadock', 'isqualiopi', 'website',
|
'siren', 'num_nda', 'iscertitrace', 'isdatadock', 'isqualiopi', 'website',
|
||||||
'isbureaucertitrace', 'iscertifvoltaire']
|
'isbureaucertitrace', 'iscertifvoltaire', 'file_logo_recid', 'file_cachet_recid']
|
||||||
|
|
||||||
|
|
||||||
incom_keys = diction.keys()
|
incom_keys = diction.keys()
|
||||||
|
|
||||||
|
|
||||||
|
@ -686,13 +688,8 @@ def update_partner_account(diction):
|
||||||
if ("invoice_telephone" in diction.keys()):
|
if ("invoice_telephone" in diction.keys()):
|
||||||
mydata['invoice_telephone'] = diction['invoice_telephone']
|
mydata['invoice_telephone'] = diction['invoice_telephone']
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
mydata['date_update'] = str(datetime.now())
|
mydata['date_update'] = str(datetime.now())
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#print(str(datetime.now()) + " webservice : diction = " + str(mydata))
|
#print(str(datetime.now()) + " webservice : diction = " + str(mydata))
|
||||||
|
|
||||||
coll_name = MYSY_GV.dbname['partnair_account']
|
coll_name = MYSY_GV.dbname['partnair_account']
|
||||||
|
@ -745,13 +742,41 @@ def update_partner_account(diction):
|
||||||
return_document=ReturnDocument.AFTER
|
return_document=ReturnDocument.AFTER
|
||||||
)
|
)
|
||||||
|
|
||||||
if (ret_val and ret_val['_id']):
|
if( ret_val is None or '_id' not in ret_val.keys()):
|
||||||
mycommon.myprint(str(inspect.stack()[0][3]) + "Le partenaire a bien ete mise à jour =" + str(ret_val['_id']))
|
mycommon.myprint(
|
||||||
return True, "Le partenaire a bien ete mise à jour"
|
str(inspect.stack()[0][3]) + " - Impossible de mettre à jour le partenaire recid= : " + str(
|
||||||
else:
|
partner_recid))
|
||||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - Impossible de mettre à jour le partenaire recid= : " +str(partner_recid) )
|
|
||||||
return False, " Impossible de mettre à jour le partenaire"
|
return False, " Impossible de mettre à jour le partenaire"
|
||||||
|
|
||||||
|
|
||||||
|
"""
|
||||||
|
A present que le partenaire est mis à jour / créé, on va mettre à jour les image logo et image cachet s'il y en a
|
||||||
|
"""
|
||||||
|
recordimage_diction = {}
|
||||||
|
recordimage_diction['token'] = diction['token']
|
||||||
|
recordimage_diction['related_collection'] = "partnair_account"
|
||||||
|
recordimage_diction['type_img'] = "logo"
|
||||||
|
recordimage_diction['related_collection_recid'] = str(partner_recid)
|
||||||
|
recordimage_diction['image_recid'] = diction['file_logo_recid']
|
||||||
|
#print(" ### recordimage_diction 1 = ", recordimage_diction)
|
||||||
|
local_status, local_message = mycommon.recordClassImage_v2(file_logo, MYSY_GV.upload_folder, recordimage_diction)
|
||||||
|
if( local_status is False):
|
||||||
|
return local_status, local_message
|
||||||
|
|
||||||
|
recordimage_diction = {}
|
||||||
|
recordimage_diction['token'] = diction['token']
|
||||||
|
recordimage_diction['related_collection'] = "partnair_account"
|
||||||
|
recordimage_diction['type_img'] = "cachet"
|
||||||
|
recordimage_diction['related_collection_recid'] = str(partner_recid)
|
||||||
|
recordimage_diction['image_recid'] = diction['file_cachet_recid']
|
||||||
|
#print(" ### recordimage_diction 2 = ", recordimage_diction)
|
||||||
|
local_status, local_message = mycommon.recordClassImage_v2(file_cachet, MYSY_GV.upload_folder, recordimage_diction)
|
||||||
|
if (local_status is False):
|
||||||
|
return local_status, local_message
|
||||||
|
|
||||||
|
|
||||||
|
return True, "Le partenaire a bien ete mise à jour"
|
||||||
|
|
||||||
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) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
|
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
|
||||||
|
@ -911,7 +936,7 @@ def get_partner_account(diction):
|
||||||
tmp = coll_token.find({ 'token': str(token_value), 'valide': '1'})
|
tmp = coll_token.find({ 'token': str(token_value), 'valide': '1'})
|
||||||
partnere_recid = tmp[0]['recid']
|
partnere_recid = tmp[0]['recid']
|
||||||
|
|
||||||
print(" #### parters RECID = "+str(partnere_recid))
|
#print(" #### parters RECID = "+str(partnere_recid))
|
||||||
|
|
||||||
is_first_connexion = True
|
is_first_connexion = True
|
||||||
|
|
||||||
|
@ -925,6 +950,7 @@ def get_partner_account(diction):
|
||||||
user = retVal
|
user = retVal
|
||||||
RetObject.append(JSONEncoder().encode(user))
|
RetObject.append(JSONEncoder().encode(user))
|
||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Si la première connexion, alors on met la le champs avec la valeur firstconnexion = 0
|
Si la première connexion, alors on met la le champs avec la valeur firstconnexion = 0
|
||||||
"""
|
"""
|
||||||
|
@ -957,6 +983,66 @@ def get_partner_account(diction):
|
||||||
return False, " Impossible de recuperer les informations"
|
return False, " Impossible de recuperer les informations"
|
||||||
|
|
||||||
|
|
||||||
|
"""
|
||||||
|
Recuperation des images d'un partenaire (logo & cachet)
|
||||||
|
"""
|
||||||
|
|
||||||
|
def getRecodedParnterImage_from_front(diction=None):
|
||||||
|
try:
|
||||||
|
# Dictionnaire des champs utilisables
|
||||||
|
field_list = ['token']
|
||||||
|
incom_keys = diction.keys()
|
||||||
|
for val in incom_keys:
|
||||||
|
if val not in field_list:
|
||||||
|
mycommon.myprint(
|
||||||
|
str(inspect.stack()[0][3]) + " - Le champ '" + val + "' n'existe pas, requete annulée")
|
||||||
|
return False, " Impossible de recuperer les informations"
|
||||||
|
|
||||||
|
'''
|
||||||
|
Une fois qu'on a controlé que toutes les clés mise dans l'API sont correcte. etape precedente,
|
||||||
|
On controle que les champs obligatoires sont presents dans la liste
|
||||||
|
'''
|
||||||
|
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, " Impossible de recuperer les informations"
|
||||||
|
|
||||||
|
|
||||||
|
local_status, my_partner = mycommon.Check_Connexion_And_Return_Partner_Data(diction)
|
||||||
|
if (local_status is not True):
|
||||||
|
return local_status, my_partner
|
||||||
|
|
||||||
|
qery_images = {'locked': '0', 'valide': '1', 'related_collection': 'partnair_account',
|
||||||
|
'related_collection_recid': str(my_partner['recid'])}
|
||||||
|
|
||||||
|
print(" ### qery_images = ", qery_images)
|
||||||
|
|
||||||
|
RetObject = []
|
||||||
|
partner_images = {}
|
||||||
|
# Recuperation des image 'logo' et 'cachet' si le partenaire en a
|
||||||
|
for retVal in MYSY_GV.dbname['mysy_images'].find(qery_images):
|
||||||
|
if ('type_img' in retVal.keys()):
|
||||||
|
if (retVal['type_img'] == "logo"):
|
||||||
|
partner_images['logo_img'] = retVal['img'].decode()
|
||||||
|
partner_images['logo_img_recid'] = retVal['recid']
|
||||||
|
|
||||||
|
if (retVal['type_img'] == "cachet"):
|
||||||
|
partner_images['cachet_img'] = retVal['img'].decode()
|
||||||
|
partner_images['cachet_img_recid'] = retVal['recid']
|
||||||
|
|
||||||
|
RetObject.append(JSONEncoder().encode(partner_images))
|
||||||
|
|
||||||
|
print(" ### getRecodedParnterImage_from_front RetObject = ", RetObject)
|
||||||
|
return True, RetObject
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||||
|
print(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
|
||||||
|
return False, " Impossible de recupérer les images/médias du partenaire"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
|
131
prj_common.py
131
prj_common.py
|
@ -1698,6 +1698,137 @@ def recordClassImage(file=None, Folder=None, diction=None):
|
||||||
return False,"IMPOSSIBLE D'ENREGISTRER L'IMAGE de la formation "+str(myclassexternalcode)
|
return False,"IMPOSSIBLE D'ENREGISTRER L'IMAGE de la formation "+str(myclassexternalcode)
|
||||||
|
|
||||||
|
|
||||||
|
"""
|
||||||
|
Recriture de la fonction de base pour pouvoir enregistrer une image
|
||||||
|
avec les paramettre suivant
|
||||||
|
- related_collection
|
||||||
|
- related_collection_recid
|
||||||
|
|
||||||
|
"""
|
||||||
|
def recordClassImage_v2(file=None, Folder=None, diction=None):
|
||||||
|
try:
|
||||||
|
|
||||||
|
# Dictionnaire des champs utilisables
|
||||||
|
field_list = ['token', 'related_collection', 'related_collection_recid', 'image_recid', 'type_img']
|
||||||
|
incom_keys = diction.keys()
|
||||||
|
|
||||||
|
'''
|
||||||
|
# Verification que les champs reçus dans l'API sont bien dans la liste des champs autorisés
|
||||||
|
# Cela evite le cas ou une entité tierce ajouter les valeurs inconnu dans l'API
|
||||||
|
# Ici on doit mettre tous les champs possible (obligatoire ou non) de la BDD dans la liste
|
||||||
|
# field_list.
|
||||||
|
'''
|
||||||
|
for val in incom_keys:
|
||||||
|
if str(val).lower() not in str(field_list).lower():
|
||||||
|
myprint(
|
||||||
|
str(inspect.stack()[0][3]) + " Le champ '" + val + "' n'est pas accepté dans cette API")
|
||||||
|
return False, " Impossible de se connecter"
|
||||||
|
|
||||||
|
'''
|
||||||
|
Une fois qu'on a controlé que toutes les clés mise dans l'API sont correcte. etape precedente,
|
||||||
|
On controle que les champs obligatoires sont presents dans la liste
|
||||||
|
'''
|
||||||
|
field_list_obligatoire = ['token', 'related_collection', 'related_collection_recid', 'type_img']
|
||||||
|
for val in field_list_obligatoire:
|
||||||
|
if str(val).lower() not in diction:
|
||||||
|
myprint(
|
||||||
|
str(inspect.stack()[0][3]) + " La valeur '" + val + "' n'est pas presente dans liste des champs")
|
||||||
|
return False, "Impossible de se connecter"
|
||||||
|
|
||||||
|
mydata = {}
|
||||||
|
mytoken = ""
|
||||||
|
|
||||||
|
# recuperation des paramettre
|
||||||
|
if ("token" in diction.keys()):
|
||||||
|
if diction['token']:
|
||||||
|
mytoken = diction['token']
|
||||||
|
|
||||||
|
type_img = ""
|
||||||
|
if ("type_img" in diction.keys()):
|
||||||
|
if diction['type_img']:
|
||||||
|
type_img = diction['type_img']
|
||||||
|
|
||||||
|
if( type_img not in MYSY_GV.BDD_STOCKAGE_IMG):
|
||||||
|
myprint(
|
||||||
|
str(inspect.stack()[0][3]) + " La valeur '" + type_img + "' n'est pas autorisé. les valeurs acceptées sont "+str(MYSY_GV.BDD_STOCKAGE_IMG) )
|
||||||
|
return False, " Le type d'image n'est pas autorisé. les valeurs acceptées sont "+str(MYSY_GV.BDD_STOCKAGE_IMG)
|
||||||
|
|
||||||
|
related_collection = ""
|
||||||
|
if ("related_collection" in diction.keys()):
|
||||||
|
if diction['related_collection']:
|
||||||
|
related_collection = diction['related_collection']
|
||||||
|
|
||||||
|
|
||||||
|
related_collection_recid = ""
|
||||||
|
if ("related_collection_recid" in diction.keys()):
|
||||||
|
if diction['related_collection_recid']:
|
||||||
|
related_collection_recid = diction['related_collection_recid']
|
||||||
|
|
||||||
|
image_recid = ""
|
||||||
|
if ("image_recid" in diction.keys()):
|
||||||
|
if diction['image_recid']:
|
||||||
|
image_recid = diction['image_recid']
|
||||||
|
|
||||||
|
if(len(str(image_recid)) <= 0 ):
|
||||||
|
# cette image n'a jamais ete enregistrée
|
||||||
|
# Creation du RecId
|
||||||
|
image_recid = create_user_recid()
|
||||||
|
|
||||||
|
|
||||||
|
local_status, my_partner = Check_Connexion_And_Return_Partner_Data(diction)
|
||||||
|
if (local_status is not True):
|
||||||
|
return local_status, my_partner
|
||||||
|
|
||||||
|
|
||||||
|
status, saved_file = Upload_Save_IMG_File(file, Folder)
|
||||||
|
if (status == False):
|
||||||
|
myprint("Impossible de recuperer correctement le fichier à importer")
|
||||||
|
return False, "Impossible de recuperer correctement le fichier à importer"
|
||||||
|
|
||||||
|
# " Lecture du fichier "
|
||||||
|
#print(" Lecture du fichier : " + saved_file + ". le token est :" + str(mytoken))
|
||||||
|
nb_line = 0
|
||||||
|
coll_name = MYSY_GV.dbname['mysy_images']
|
||||||
|
|
||||||
|
with open(saved_file, "rb") as imageFile:
|
||||||
|
|
||||||
|
# strimg = base64.b64encode(imageFile.read())
|
||||||
|
strimg = base64.b64encode(imageFile.read())
|
||||||
|
|
||||||
|
new_diction = {}
|
||||||
|
new_diction['img'] = strimg
|
||||||
|
new_diction['related_collection'] = related_collection
|
||||||
|
new_diction['related_collection_recid'] = related_collection_recid
|
||||||
|
new_diction['valide'] = '1'
|
||||||
|
new_diction['date_update'] = str(datetime.now())
|
||||||
|
new_diction['locked'] = "0"
|
||||||
|
new_diction['recid'] = image_recid
|
||||||
|
new_diction['type_img'] = type_img
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
ret_val = coll_name.find_one_and_update({"recid":image_recid, "related_collection_recid": related_collection_recid,
|
||||||
|
"valide": "1", "locked": "0", "related_collection":str(related_collection),
|
||||||
|
"type_img":str(type_img)},
|
||||||
|
{"$set": new_diction},
|
||||||
|
upsert=True,
|
||||||
|
return_document=ReturnDocument.AFTER
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
if( ret_val is None or '_id' not in ret_val.keys()):
|
||||||
|
myprint(" IMPOSSIBLE D'ENREGISTRER L'IMAGE")
|
||||||
|
return False, "IMPOSSIBLE D'ENREGISTRER L'IMAGE de la formation "
|
||||||
|
|
||||||
|
print(" ### recordClassImage_v2 :L'image a été correctement enregistrée ")
|
||||||
|
return True, "L'image a été correctement enregistrée"
|
||||||
|
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||||
|
print(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
|
||||||
|
return False,"IMPOSSIBLE D'ENREGISTRER L'IMAGE "
|
||||||
|
|
||||||
|
|
||||||
'''
|
'''
|
||||||
Recuperation d'une image de profils
|
Recuperation d'une image de profils
|
||||||
|
|
Loading…
Reference in New Issue