16/07/23 - 21h
parent
76cd2ad20a
commit
dbee53c9e3
|
@ -1,14 +1,15 @@
|
|||
<?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="10/07/23 - 22h">
|
||||
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="12/07/23 - 21h">
|
||||
<change afterPath="$PROJECT_DIR$/partner_client.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Emargement/test_emargement.pdf" beforeDir="false" afterPath="$PROJECT_DIR$/Emargement/test_emargement.pdf" 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$/ela_factures_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/ela_factures_mgt.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/emargement.py" beforeDir="false" afterPath="$PROJECT_DIR$/emargement.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/strype_payement.py" beforeDir="false" afterPath="$PROJECT_DIR$/strype_payement.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/abonnement_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/abonnement_mgt.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/appel_offre.py" beforeDir="false" afterPath="$PROJECT_DIR$/appel_offre.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/email_inscription_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/email_inscription_mgt.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
|
@ -380,7 +381,14 @@
|
|||
<option name="project" value="LOCAL" />
|
||||
<updated>1689020473211</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="45" />
|
||||
<task id="LOCAL-00045" summary="12/07/23 - 21h">
|
||||
<created>1689190734585</created>
|
||||
<option name="number" value="00045" />
|
||||
<option name="presentableId" value="LOCAL-00045" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1689190734585</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="46" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="Vcs.Log.Tabs.Properties">
|
||||
|
@ -395,7 +403,6 @@
|
|||
</option>
|
||||
</component>
|
||||
<component name="VcsManagerConfiguration">
|
||||
<MESSAGE value="13/05/23 - 17h" />
|
||||
<MESSAGE value="13/05/23 - 23h" />
|
||||
<MESSAGE value="15/05/23 - 23h" />
|
||||
<MESSAGE value="21/05/23 - 10h" />
|
||||
|
@ -420,6 +427,7 @@
|
|||
<MESSAGE value="09/07/23 - 16h" />
|
||||
<MESSAGE value="09/07/23 - 21h" />
|
||||
<MESSAGE value="10/07/23 - 22h" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="10/07/23 - 22h" />
|
||||
<MESSAGE value="12/07/23 - 21h" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="12/07/23 - 21h" />
|
||||
</component>
|
||||
</project>
|
|
@ -94,6 +94,16 @@ def AddStagiairetoClass(diction):
|
|||
Recuperation des info de la session de formation
|
||||
"""
|
||||
|
||||
"""
|
||||
update : 13/07/23 : gestion des prix
|
||||
|
||||
- par defaut si le champs diction['price'] est rempli, alors on prend cette valeur.
|
||||
- si cette valeur est vide ou inexistante, on va chercher le prix sur la session.
|
||||
- Si aucun prix n'est mis sur la session, on va aller cherche le prix sur la formation.
|
||||
|
||||
|
||||
"""
|
||||
new_price = "-1" # 0 ==> par defaut
|
||||
for tmp_val in MYSY_GV.dbname['session_formation'].find({"formation_session_id":str(session_id)}):
|
||||
mydata['date_du'] = tmp_val['date_debut']
|
||||
mydata['date_au'] = tmp_val['date_fin']
|
||||
|
@ -110,6 +120,11 @@ def AddStagiairetoClass(diction):
|
|||
if tmp_val['adresse']:
|
||||
mydata['adresse'] = tmp_val['adresse']
|
||||
|
||||
if ("prix_session" in tmp_val.keys()):
|
||||
if tmp_val['prix_session']:
|
||||
new_price = tmp_val['prix_session']
|
||||
mydata['price'] = tmp_val['prix_session']
|
||||
|
||||
|
||||
print(" #### mydata = "+str(mydata))
|
||||
|
||||
|
@ -167,11 +182,25 @@ def AddStagiairetoClass(diction):
|
|||
new_status = str(diction['status']).strip()
|
||||
mydata['status'] = str(new_status)
|
||||
|
||||
new_price = "0" # 0 ==> par defaut
|
||||
|
||||
if ("price" in diction.keys()):
|
||||
if diction['price']:
|
||||
new_price = str(diction['price']).strip()
|
||||
mydata['price'] = new_price
|
||||
mydata['price'] = str(diction['price']).strip()
|
||||
|
||||
# Verification des prix. si new_price = "-1" cela veut dire qu'il n'a pas de prix dans le diction ni sur la session
|
||||
# Alors on va chercher le prix (prix public sans reduction) sur la formation
|
||||
if( new_price == "-1"):
|
||||
local_class = MYSY_GV.dbname['myclass'].find_one({'internal_url':str(diction['class_internal_url']).strip(),
|
||||
'valide':'1', 'locked':'0'})
|
||||
|
||||
if( 'price' in local_class.keys()):
|
||||
mydata['price'] = str(local_class['price']).strip()
|
||||
else:
|
||||
mydata['price'] = '0'
|
||||
|
||||
|
||||
|
||||
|
||||
coll_inscription = MYSY_GV.dbname['inscription']
|
||||
|
||||
|
@ -1992,8 +2021,8 @@ def SendTrainingEvaluationEmail(diction):
|
|||
"eval_date": {"$exists": True}})
|
||||
|
||||
if (tmp_count > 0):
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " Vous avez deja evalué cette formation")
|
||||
return False, " Vous avez deja evalué cette formation"
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " Cette formation a déjà été évaluée")
|
||||
return False, " Cette formation a déjà été évaluée"
|
||||
|
||||
|
||||
RetObject = []
|
||||
|
@ -2326,7 +2355,7 @@ def PrintAttendeeCertification(diction):
|
|||
"certification_send": {"$exists": True}})
|
||||
|
||||
if (tmp_count > 0):
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " Vous avez deja evalué cette formation")
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " Vous avez deja envoyé le certificat")
|
||||
return False, " Vous avez deja envoyé le certificat"
|
||||
|
||||
# Recuperation des données du partenaire
|
||||
|
|
7575
Log/log_file.log
7575
Log/log_file.log
File diff suppressed because it is too large
Load Diff
|
@ -322,20 +322,20 @@ def Update_Abonnement(diction):
|
|||
"""
|
||||
Clés de mise à jour
|
||||
"""
|
||||
date_cle = {}
|
||||
date_cle['partner_recid'] = str(partner_recid)
|
||||
date_cle['stripe_subscription_id'] = str(stripe_subscription_id)
|
||||
date_cle['valide'] = "1"
|
||||
date_cle['locked'] = "0"
|
||||
data_cle = {}
|
||||
data_cle['partner_recid'] = str(partner_recid)
|
||||
data_cle['stripe_subscription_id'] = str(stripe_subscription_id)
|
||||
data_cle['valide'] = "1"
|
||||
data_cle['locked'] = "0"
|
||||
|
||||
inserted_id = ""
|
||||
result = MYSY_GV.dbname['abonnement'].find_one_and_update(
|
||||
date_cle,
|
||||
data_cle,
|
||||
{"$set": data},
|
||||
upsert=False,
|
||||
return_document=ReturnDocument.AFTER
|
||||
)
|
||||
if (not result.acknowledged):
|
||||
if ("_id" not in result.keys()):
|
||||
mycommon.myprint(
|
||||
" Impossible de mettre à jour l'abonnement : " + str(stripe_subscription_id))
|
||||
return False, " Impossible de mettre à jour l'abonnement: " + str(stripe_subscription_id) + " "
|
||||
|
|
628
appel_offre.py
628
appel_offre.py
|
@ -32,7 +32,8 @@ def Add_Appel_Offre(diction):
|
|||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', "external_code", "description", "date_debut", "date_fin", "contact",
|
||||
"date_deliberation", "description_critere_selection", "comment", "list_produits_appel_offre"]
|
||||
"date_deliberation", "description_critere_selection", "comment",
|
||||
"list_produits_appel_offre", "list_class"]
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
if val not in field_list:
|
||||
|
@ -96,18 +97,28 @@ def Add_Appel_Offre(diction):
|
|||
description = diction['description']
|
||||
data['description'] = diction['description']
|
||||
|
||||
# Verification s'il ya une liste de formation, et si cette liste est correcte
|
||||
list_class = ""
|
||||
if ("list_class" in diction.keys()):
|
||||
list_class = diction['comment']
|
||||
if (isinstance(list_class, list) is False):
|
||||
mycommon.myprint(
|
||||
" La liste des formation n'est pas de type list. ")
|
||||
return False, "La liste des formation n'est pas de type list. "
|
||||
|
||||
|
||||
date_debut = ""
|
||||
if ("date_debut" in diction.keys()):
|
||||
if diction['date_debut']:
|
||||
date_debut = diction['date_debut']
|
||||
data['date_debut'] = diction['date_debut']
|
||||
|
||||
local_status = mycommon.CheckisDate(date_debut)
|
||||
if (local_status is False):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " - La date debut n'est pas au format jj/mm/aaaa ")
|
||||
return False, " La date debut n'est pas au format jj/mm/aaaa "
|
||||
local_status = mycommon.CheckisDate(date_debut)
|
||||
if (local_status is False):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " - La date debut n'est pas au format jj/mm/aaaa ")
|
||||
return False, " La date debut n'est pas au format jj/mm/aaaa "
|
||||
|
||||
|
||||
date_fin = ""
|
||||
|
@ -116,24 +127,25 @@ def Add_Appel_Offre(diction):
|
|||
date_fin = diction['date_fin']
|
||||
data['date_fin'] = diction['date_fin']
|
||||
|
||||
local_status = mycommon.CheckisDate(date_fin)
|
||||
if (local_status is False):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " - La date de fin n'est pas au format jj/mm/aaaa ")
|
||||
return False, " La date de fin n'est pas au format jj/mm/aaaa "
|
||||
local_status = mycommon.CheckisDate(date_fin)
|
||||
if (local_status is False):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " - La date de fin n'est pas au format jj/mm/aaaa ")
|
||||
return False, " La date de fin n'est pas au format jj/mm/aaaa "
|
||||
|
||||
|
||||
"""
|
||||
Controle cohérence des dates debut et fin
|
||||
"""
|
||||
if (datetime.strptime(str(date_debut).strip(), '%d/%m/%Y') > datetime.strptime(
|
||||
str(date_fin).strip(), '%d/%m/%Y')):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " La date debut " + str(date_debut) +" est postérieure à la date de fin " + str(date_fin) + " ")
|
||||
if( date_debut and date_fin ):
|
||||
if (datetime.strptime(str(date_debut).strip(), '%d/%m/%Y') > datetime.strptime(
|
||||
str(date_fin).strip(), '%d/%m/%Y')):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " La date debut " + str(date_debut) +" est postérieure à la date de fin " + str(date_fin) + " ")
|
||||
|
||||
return False, " La date debut " + str(date_debut) + " est postérieure à la date de fin " + str(date_fin) + " "
|
||||
return False, " La date debut " + str(date_debut) + " est postérieure à la date de fin " + str(date_fin) + " "
|
||||
|
||||
|
||||
contact = ""
|
||||
|
@ -148,25 +160,26 @@ def Add_Appel_Offre(diction):
|
|||
date_deliberation = diction['date_deliberation']
|
||||
data['date_deliberation'] = diction['date_deliberation']
|
||||
|
||||
local_status = mycommon.CheckisDate(date_deliberation)
|
||||
if (local_status is False):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " - La date de deliberation n'est pas au format jj/mm/aaaa ")
|
||||
return False, " La date de deliberation n'est pas au format jj/mm/aaaa "
|
||||
local_status = mycommon.CheckisDate(date_deliberation)
|
||||
if (local_status is False):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " - La date de deliberation n'est pas au format jj/mm/aaaa ")
|
||||
return False, " La date de deliberation n'est pas au format jj/mm/aaaa "
|
||||
|
||||
"""
|
||||
Controle cohérence des dates debut et la date de deliberation
|
||||
"""
|
||||
if (datetime.strptime(str(date_debut).strip(), '%d/%m/%Y') > datetime.strptime(
|
||||
str(date_deliberation).strip(), '%d/%m/%Y')):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " La date debut " + str(date_debut) + " est postérieure à la date de deliberation " + str(
|
||||
date_deliberation) + " ")
|
||||
if( date_debut and date_deliberation ):
|
||||
if (datetime.strptime(str(date_debut).strip(), '%d/%m/%Y') > datetime.strptime(
|
||||
str(date_deliberation).strip(), '%d/%m/%Y')):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " La date debut " + str(date_debut) + " est postérieure à la date de deliberation " + str(
|
||||
date_deliberation) + " ")
|
||||
|
||||
return False, " La date debut " + str(date_debut) + " est postérieure à la date de deliberation " + str(
|
||||
date_deliberation) + " "
|
||||
return False, " La date debut " + str(date_debut) + " est postérieure à la date de deliberation " + str(
|
||||
date_deliberation) + " "
|
||||
|
||||
|
||||
description_critere_selection = ""
|
||||
|
@ -203,6 +216,7 @@ def Add_Appel_Offre(diction):
|
|||
data['partner_recid'] = my_partner['recid']
|
||||
data['valide'] = '1'
|
||||
data['locked'] = '0'
|
||||
data['status'] = '0'
|
||||
|
||||
inserted_id = ""
|
||||
inserted_id = MYSY_GV.dbname['appel_offre'].insert_one(data).inserted_id
|
||||
|
@ -212,6 +226,45 @@ def Add_Appel_Offre(diction):
|
|||
return False, " Impossible de créer l'appel d'offre (1) "
|
||||
|
||||
|
||||
"""
|
||||
A présent que l'appel d'offre à été créé, on va verifier s'il y a des formations associées.
|
||||
Si oui, on les ajoute à la collection ao_class
|
||||
"""
|
||||
list_class = ""
|
||||
for val in list_class :
|
||||
class_data = {}
|
||||
if ("domain" in val.keys()):
|
||||
class_data['domain'] = diction['domain']
|
||||
|
||||
if ("objectif" in val.keys()):
|
||||
class_data['objectif'] = diction['objectif']
|
||||
|
||||
if ("nb_participant" in val.keys()):
|
||||
class_data['nb_participant'] = diction['nb_participant']
|
||||
|
||||
if ("date_debut" in val.keys()):
|
||||
class_data['date_debut'] = diction['date_debut']
|
||||
|
||||
if ("date_fin" in val.keys()):
|
||||
class_data['date_fin'] = diction['date_fin']
|
||||
|
||||
if ("lieu" in val.keys()):
|
||||
class_data['lieu'] = diction['lieu']
|
||||
|
||||
if ("budget" in val.keys()):
|
||||
class_data['budget'] = diction['budget']
|
||||
|
||||
if ("comment" in val.keys()):
|
||||
class_data['comment'] = diction['comment']
|
||||
|
||||
class_data['external_code'] = str(external_code)
|
||||
class_data['partner_recid'] = str(my_partner['recid'])
|
||||
class_data['valide'] = "1"
|
||||
|
||||
MYSY_GV.dbname['ao_class'].insert_one(class_data)
|
||||
|
||||
|
||||
|
||||
return True, " L'appel d'ofre a été correctement créé"
|
||||
|
||||
except Exception as e:
|
||||
|
@ -220,19 +273,20 @@ def Add_Appel_Offre(diction):
|
|||
return False, " Impossible d'ajouter l'appel d'offre "
|
||||
|
||||
|
||||
"""
|
||||
Mise à jour d'un appel d'offre
|
||||
"""
|
||||
def Update_Appel_Offre(diction):
|
||||
|
||||
|
||||
"""
|
||||
Cette fonction ajoute et met à jour une formation associé à une appel d'offre
|
||||
"""
|
||||
def Add_Update_AO_Class(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', 'nom', 'prenom', 'email', 'tel_mobile', 'date_naissance', 'adr_rue', 'adr_ville',
|
||||
'adr_code_postal', 'adr_pays']
|
||||
field_list = ['token', "external_code", "list_class"]
|
||||
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
if val not in field_list:
|
||||
|
@ -243,7 +297,7 @@ def Update_Appel_Offre(diction):
|
|||
"""
|
||||
Verification des champs obligatoires
|
||||
"""
|
||||
field_list_obligatoire = ['token', 'email']
|
||||
field_list_obligatoire = ['token', 'external_code']
|
||||
for val in field_list_obligatoire:
|
||||
if val not in diction:
|
||||
mycommon.myprint(
|
||||
|
@ -281,54 +335,109 @@ def Update_Appel_Offre(diction):
|
|||
Recuperation des données fournies en entrée
|
||||
"""
|
||||
|
||||
data = {}
|
||||
data_update = {}
|
||||
|
||||
nom = ""
|
||||
if ("nom" in diction.keys()):
|
||||
nom = diction['nom']
|
||||
data['nom'] = diction['nom']
|
||||
external_code = ""
|
||||
if ("external_code" in diction.keys()):
|
||||
external_code = diction['external_code']
|
||||
|
||||
"""
|
||||
Clés de mise à jour
|
||||
"""
|
||||
date_cle = {}
|
||||
date_cle['email'] = str(email)
|
||||
date_cle['partner_recid'] = str(partner_recid)
|
||||
date_cle['valide'] = "1"
|
||||
date_cle['locked'] = "0"
|
||||
# Verification s'il ya une liste de formation, et si cette liste est correcte
|
||||
list_class = ""
|
||||
if ("list_class" in diction.keys()):
|
||||
list_class = diction['comment']
|
||||
if (isinstance(list_class, list) is False):
|
||||
mycommon.myprint(
|
||||
" La liste des formation n'est pas de type list. ")
|
||||
return False, "La liste des formation n'est pas de type list. "
|
||||
|
||||
inserted_id = ""
|
||||
result = MYSY_GV.dbname['candidat'].find_one_and_update(
|
||||
date_cle,
|
||||
{"$set": data},
|
||||
upsert=False,
|
||||
return_document=ReturnDocument.AFTER
|
||||
)
|
||||
if (not result.acknowledged):
|
||||
mycommon.myprint(
|
||||
" Impossible de mettre à jour l'appel d'offre: " + str(email))
|
||||
return False, " Impossible de mettre à jour l'appel d'offre: " + str(email) + " "
|
||||
ret_val_message = ""
|
||||
list_class = ""
|
||||
cpt = 0
|
||||
for val in list_class:
|
||||
cpt = cpt + 1
|
||||
class_data = {}
|
||||
if ("domain" in val.keys()):
|
||||
class_data['domain'] = diction['domain']
|
||||
|
||||
return True, " L'appel d'offre a été correctement mise à jour"
|
||||
if ("title" in val.keys()):
|
||||
class_data['title'] = diction['title']
|
||||
|
||||
if ("objectif" in val.keys()):
|
||||
class_data['objectif'] = diction['objectif']
|
||||
|
||||
if ("nb_participant" in val.keys()):
|
||||
class_data['nb_participant'] = diction['nb_participant']
|
||||
|
||||
if ("date_debut" in val.keys()):
|
||||
class_data['date_debut'] = diction['date_debut']
|
||||
|
||||
if ("date_fin" in val.keys()):
|
||||
class_data['date_fin'] = diction['date_fin']
|
||||
|
||||
if ("lieu" in val.keys()):
|
||||
class_data['lieu'] = diction['lieu']
|
||||
|
||||
if ("budget" in val.keys()):
|
||||
class_data['budget'] = diction['budget']
|
||||
|
||||
if ("comment" in val.keys()):
|
||||
class_data['comment'] = diction['comment']
|
||||
|
||||
class_data['external_code'] = str(external_code)
|
||||
class_data['partner_recid'] = str(my_partner['recid'])
|
||||
class_data['valide'] = "1"
|
||||
|
||||
ret_val = MYSY_GV.dbname['ao_class'].find_one_and_update({'external_code': str(external_code),
|
||||
'partner_recid':str(my_partner['recid']), 'valide': '1'},
|
||||
{"$set": class_data},
|
||||
upsert=True,
|
||||
return_document=ReturnDocument.AFTER
|
||||
)
|
||||
|
||||
if ("_id" not in ret_val.keys()):
|
||||
ret_val_message = ret_val_message +" - Impossible de créer / mettre à jour la formation à la ligne "+str(cpt)
|
||||
|
||||
|
||||
if(len(ret_val_message) > 2):
|
||||
return True, str(ret_val_message)
|
||||
|
||||
return True, " La formation a été ajouter à l'appel d'offre"
|
||||
|
||||
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 mettre à jour l'appel d'offre' "
|
||||
return False, " Impossible d'ajouter la formation à l'appel d'offre "
|
||||
|
||||
|
||||
"""
|
||||
fonction de recuperation d'un appel d'offre
|
||||
Mise à jour d'un appel d'offre.
|
||||
|
||||
la clé pour la mise à jour est : "external_code" et "partner_recid" issue du token
|
||||
|
||||
/!\ Le status de l'appel d'offre est comme suit :
|
||||
- 0 : Draft, en cours de conception
|
||||
- 1 : lancé / publié
|
||||
- 2 : cloturé
|
||||
|
||||
/!\ le scope : scope : public (tout internet), plateforme (que les personne enregistrées sur le mysy), restreint (l'utilisateur saisie une liste d'adresse email a qui l'envoyer)
|
||||
- 0 : Tout public
|
||||
- 1 : plateforme
|
||||
- 2 : restreint (liste email) 343
|
||||
|
||||
|
||||
"""
|
||||
def Get_Appel_Offre(diction):
|
||||
def Update_Appel_Offre(diction):
|
||||
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', 'nom', 'prenom', 'email', 'tel_mobile', 'date_naissance', 'adr_rue', 'adr_ville',
|
||||
'adr_code_postal', 'adr_pays', 'candidats_id', 'cpny']
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', "external_code", "description", "date_debut", "date_fin", "contact",
|
||||
"date_deliberation", "description_critere_selection", "comment", "list_produits_appel_offre",
|
||||
"status"]
|
||||
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
if val not in field_list:
|
||||
|
@ -339,7 +448,205 @@ def Get_Appel_Offre(diction):
|
|||
"""
|
||||
Verification des champs obligatoires
|
||||
"""
|
||||
field_list_obligatoire = ['token']
|
||||
field_list_obligatoire = ['token', 'external_code']
|
||||
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']
|
||||
|
||||
# Verifier la validité du token
|
||||
retval = mycommon.check_partner_token_validity("", token)
|
||||
|
||||
if retval is False:
|
||||
return "Err_Connexion", " La session de connexion n'est pas valide"
|
||||
|
||||
partner_recid = mycommon.get_parnter_recid_from_token(token)
|
||||
if (partner_recid is False):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " - partner_recid est KO. Les données de connexion sont incorrectes ")
|
||||
return False, " Vous n'etes pas autorisé à utiliser cette API "
|
||||
|
||||
# Recuperation des données du partenaire
|
||||
local_status, my_partner = mycommon.get_partner_data_from_recid(partner_recid)
|
||||
if (local_status is False):
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - impossible de recuperer les données du partenaire")
|
||||
return False, str(inspect.stack()[0][3]) + " - impossible de recuperer les données du partenaire. "
|
||||
|
||||
"""
|
||||
Recuperation des données fournies en entrée
|
||||
"""
|
||||
|
||||
data_update = {}
|
||||
|
||||
external_code = ""
|
||||
if ("external_code" in diction.keys()):
|
||||
external_code = diction['external_code']
|
||||
|
||||
"""
|
||||
Clés de mise à jour
|
||||
"""
|
||||
data_cle = {}
|
||||
data_cle['external_code'] = str(external_code)
|
||||
data_cle['partner_recid'] = str(my_partner['recid'])
|
||||
data_cle['valide'] = "1"
|
||||
data_cle['locked'] = "0"
|
||||
|
||||
description = ""
|
||||
if ("description" in diction.keys()):
|
||||
data_update['description'] = diction['description']
|
||||
|
||||
contact = ""
|
||||
if ("contact" in diction.keys()):
|
||||
data_update['contact'] = diction['contact']
|
||||
|
||||
description_critere_selection = ""
|
||||
if ("description_critere_selection" in diction.keys()):
|
||||
data_update['description_critere_selection'] = diction['description_critere_selection']
|
||||
|
||||
comment = ""
|
||||
if ("comment" in diction.keys()):
|
||||
data_update['comment'] = diction['comment']
|
||||
|
||||
status = ""
|
||||
if ("status" in diction.keys()):
|
||||
if( str(diction['status']) not in ["0", "1", "2"]):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " - Le statut de l'appel d'offre doit etre 0, 1 ou 2. Information fournie :"+str(diction['status']) )
|
||||
return False, " - Le statut de l'appel d'offre doit etre 0, 1 ou 2. Information fournie :"+str(diction['status'])+" "
|
||||
|
||||
data_update['status'] = diction['status']
|
||||
|
||||
|
||||
list_produits_appel_offre = ""
|
||||
if ("list_produits_appel_offre" in diction.keys()):
|
||||
data_update['list_produits_appel_offre'] = diction['list_produits_appel_offre']
|
||||
|
||||
date_debut = ""
|
||||
if ("date_debut" in diction.keys()):
|
||||
date_debut = diction['date_debut']
|
||||
|
||||
local_status = mycommon.CheckisDate(date_debut)
|
||||
if (local_status is False):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " - La date debut n'est pas au format jj/mm/aaaa ")
|
||||
return False, " La date debut n'est pas au format jj/mm/aaaa "
|
||||
|
||||
data_update['date_debut'] = diction['date_debut']
|
||||
|
||||
date_fin = ""
|
||||
if ("date_fin" in diction.keys()):
|
||||
date_fin = diction['date_fin']
|
||||
|
||||
local_status = mycommon.CheckisDate(date_fin)
|
||||
if (local_status is False):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " - La date de fin n'est pas au format jj/mm/aaaa ")
|
||||
return False, " La date de fin n'est pas au format jj/mm/aaaa "
|
||||
|
||||
data_update['date_fin'] = diction['date_fin']
|
||||
|
||||
"""
|
||||
Controle cohérence des dates debut et fin
|
||||
"""
|
||||
if (date_debut and date_fin):
|
||||
if (datetime.strptime(str(date_debut).strip(), '%d/%m/%Y') > datetime.strptime(
|
||||
str(date_fin).strip(), '%d/%m/%Y')):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " La date debut " + str(date_debut) + " est postérieure à la date de fin " + str(
|
||||
date_fin) + " ")
|
||||
|
||||
return False, " La date debut " + str(date_debut) + " est postérieure à la date de fin " + str(
|
||||
date_fin) + " "
|
||||
|
||||
|
||||
date_deliberation = ""
|
||||
if ("date_deliberation" in diction.keys()):
|
||||
if diction['date_deliberation']:
|
||||
date_deliberation = diction['date_deliberation']
|
||||
|
||||
|
||||
local_status = mycommon.CheckisDate(date_deliberation)
|
||||
if (local_status is False):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " - La date de deliberation n'est pas au format jj/mm/aaaa ")
|
||||
return False, " La date de deliberation n'est pas au format jj/mm/aaaa "
|
||||
|
||||
data_update['date_deliberation'] = diction['date_deliberation']
|
||||
|
||||
data_update['date_update'] = str(datetime.now())
|
||||
"""
|
||||
Controle cohérence des dates debut et la date de deliberation
|
||||
"""
|
||||
if (date_debut and date_deliberation):
|
||||
if (datetime.strptime(str(date_debut).strip(), '%d/%m/%Y') > datetime.strptime(
|
||||
str(date_deliberation).strip(), '%d/%m/%Y')):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " La date debut " + str(
|
||||
date_debut) + " est postérieure à la date de deliberation " + str(
|
||||
date_deliberation) + " ")
|
||||
|
||||
return False, " La date debut " + str(date_debut) + " est postérieure à la date de deliberation " + str(
|
||||
date_deliberation) + " "
|
||||
|
||||
|
||||
inserted_id = ""
|
||||
result = MYSY_GV.dbname['appel_offre'].find_one_and_update(
|
||||
data_cle,
|
||||
{"$set": data_update},
|
||||
upsert=False,
|
||||
return_document=ReturnDocument.AFTER
|
||||
)
|
||||
if ("_id" not in result.keys()):
|
||||
mycommon.myprint(
|
||||
" Impossible de mettre à jour l'appel d'offre: external_code = " + str(external_code))
|
||||
return False, " Impossible de mettre à jour l'appel d'offre "
|
||||
|
||||
return True, " L'appel d'offre a été correctement 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 mettre à jour l'appel d'offre "
|
||||
|
||||
|
||||
"""
|
||||
fonction de recuperation d'un appel d'offre donné
|
||||
"""
|
||||
def Get_Given_Appel_Offre(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', 'external_code']
|
||||
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")
|
||||
return False, " Les informations fournies sont incorrectes",
|
||||
|
||||
"""
|
||||
Verification des champs obligatoires
|
||||
"""
|
||||
field_list_obligatoire = ['token', 'external_code']
|
||||
for val in field_list_obligatoire:
|
||||
if val not in diction:
|
||||
mycommon.myprint(
|
||||
|
@ -362,13 +669,34 @@ def Get_Appel_Offre(diction):
|
|||
return "Err_Connexion", " La session de connexion n'est pas valide"
|
||||
|
||||
# Recuperation des données du partenaire
|
||||
local_status, my_user = mycommon.get_user_data_from_token(token)
|
||||
local_status, my_partner = mycommon.get_user_data_from_token(token)
|
||||
if (local_status is False):
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - impossible de recuperer les données de l'utilisateur ")
|
||||
return False, str(inspect.stack()[0][3]) + " - impossible de recuperer les données de l'utilisateur. "
|
||||
|
||||
external_code = ""
|
||||
if ("external_code" in diction.keys()):
|
||||
external_code = diction['external_code']
|
||||
|
||||
"""
|
||||
Clés de mise à jour
|
||||
"""
|
||||
data_cle = {}
|
||||
data_cle['external_code'] = str(external_code)
|
||||
data_cle['partner_recid'] = str(my_partner['recid'])
|
||||
data_cle['valide'] = "1"
|
||||
data_cle['locked'] = "0"
|
||||
|
||||
RetObject = []
|
||||
nb_val = 0
|
||||
val_tmp = 1
|
||||
|
||||
print(" #### data_cle 01= " + str(data_cle))
|
||||
|
||||
for retval in MYSY_GV.dbname[''].find(data_cle):
|
||||
user = retval
|
||||
user['id'] = str(val_tmp)
|
||||
val_tmp = val_tmp + 1
|
||||
RetObject.append(mycommon.JSONEncoder().encode(user))
|
||||
|
||||
|
||||
return True, RetObject
|
||||
|
@ -376,6 +704,154 @@ def Get_Appel_Offre(diction):
|
|||
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 liste des candidats "
|
||||
return False, " Impossible de recuperer l'appel d'offre "
|
||||
|
||||
|
||||
"""
|
||||
Fonction retourne une liste de d'appel d'offre d'un partenaire
|
||||
"""
|
||||
def Get_List_Appel_Offre(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', 'status']
|
||||
|
||||
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")
|
||||
return False, " Les informations fournies sont incorrectes",
|
||||
|
||||
"""
|
||||
Verification des champs obligatoires
|
||||
"""
|
||||
field_list_obligatoire = ['token', 'external_code']
|
||||
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']
|
||||
|
||||
# Verifier la validité du token
|
||||
retval = mycommon.check_partner_token_validity("", token)
|
||||
|
||||
if retval is False:
|
||||
return "Err_Connexion", " La session de connexion n'est pas valide"
|
||||
|
||||
# Recuperation des données du partenaire
|
||||
local_status, my_partner = mycommon.get_user_data_from_token(token)
|
||||
if (local_status is False):
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - impossible de recuperer les données de l'utilisateur ")
|
||||
return False, str(inspect.stack()[0][3]) + " - impossible de recuperer les données de l'utilisateur. "
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Clés de mise à jour
|
||||
"""
|
||||
data_cle = {}
|
||||
data_cle['partner_recid'] = str(my_partner['recid'])
|
||||
data_cle['valide'] = "1"
|
||||
data_cle['locked'] = "0"
|
||||
|
||||
status = ""
|
||||
if ("status" in diction.keys()):
|
||||
if (str(diction['status']) not in ["0", "1", "2"]):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " - Le statut de l'appel d'offre doit etre 0, 1 ou 2. Information fournie :" + str(
|
||||
diction['status']))
|
||||
return False, " - Le statut de l'appel d'offre doit etre 0, 1 ou 2. Information fournie :" + str(diction['status'])+" "
|
||||
|
||||
|
||||
data_cle['status'] = diction['status']
|
||||
|
||||
|
||||
RetObject = []
|
||||
val_tmp = 1
|
||||
|
||||
print(" #### data_cle 01= " + str(data_cle))
|
||||
|
||||
for retval in MYSY_GV.dbname[''].find(data_cle):
|
||||
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 recuperer la liste des appels d'offre "
|
||||
|
||||
|
||||
"""
|
||||
Cette fonction effectue une manifestation d'interet d'un institut de formation pour l'AO
|
||||
"""
|
||||
def Add_Manifestation_Interet_Appel_Offre(diction):
|
||||
try:
|
||||
return True, ""
|
||||
|
||||
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 créer la manifestation d'interet pour l'appel d'offre "
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Recuperation de list des manifesations d'interet pour un AO
|
||||
"""
|
||||
def Get_List_Manifestation_Interet_Appel_Offre(diction):
|
||||
try:
|
||||
return True, ""
|
||||
|
||||
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 recupérer la liste des manifestations d'interet pour l'appel d'offre "
|
||||
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Cette fonction effectue une réponse à l'AO d'un institut de formation
|
||||
"""
|
||||
def Add_Reponse_Appel_Offre(diction):
|
||||
try:
|
||||
return True, ""
|
||||
|
||||
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 créer la réponse pour l'appel d'offre "
|
||||
|
||||
|
||||
"""
|
||||
Recuperation de list des réponses à un AO
|
||||
"""
|
||||
def Get_List_Reponse_Appel_Offre(diction):
|
||||
try:
|
||||
return True, ""
|
||||
|
||||
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 recupérer la liste des réponses pour l'appel d'offre "
|
||||
|
||||
|
||||
|
|
|
@ -812,6 +812,8 @@ def SendAttestion_to_attendee_by_email(diction):
|
|||
if ("contenu_ftion" in local_session.keys()):
|
||||
contenu_ftion = str(local_session['contenu_ftion']).replace('<p>', '').replace('</p>', '').replace("\r\n", '<br/>')
|
||||
|
||||
print(" ### contenu_ftion = ", contenu_ftion)
|
||||
|
||||
|
||||
msg['From'] = MYSY_GV.O365_SMTP_COUNT_From_User
|
||||
msg['To'] = str(diction['email_participant'])
|
||||
|
@ -822,6 +824,9 @@ def SendAttestion_to_attendee_by_email(diction):
|
|||
|
||||
# msg = MIMEMultipart("alternative")
|
||||
msg = MIMEMultipart("alternative")
|
||||
|
||||
msg22 = EmailMessage()
|
||||
|
||||
smtpserver = smtplib.SMTP(MYSY_GV.O365_SMTP_COUNT_smtpsrv, MYSY_GV.O365_SMTP_COUNT_port)
|
||||
|
||||
# JINJA2
|
||||
|
@ -873,12 +878,37 @@ def SendAttestion_to_attendee_by_email(diction):
|
|||
# close output file
|
||||
resultFile.close()
|
||||
|
||||
"""
|
||||
#-----------
|
||||
|
||||
msg22.set_content(sourceHtml, subtype='html')
|
||||
msg22['From'] = MYSY_GV.O365_SMTP_COUNT_From_User
|
||||
|
||||
msg22['Bcc'] = 'contact@mysy-training.com'
|
||||
|
||||
msg22['Subject'] = 'MySy Training : Votre attestation de formation : ' + str(diction['class_title'])
|
||||
msg22['To'] = str(diction['email_participant'])
|
||||
|
||||
smtpserver.ehlo()
|
||||
smtpserver.starttls()
|
||||
smtpserver.login(MYSY_GV.O365_SMTP_COUNT_user, MYSY_GV.O365_SMTP_COUNT_password)
|
||||
|
||||
val = smtpserver.send_message(msg22)
|
||||
smtpserver.close()
|
||||
print(" Email envoyé " + str(val))
|
||||
|
||||
return True, " email envoyé ok"
|
||||
|
||||
#----------
|
||||
"""
|
||||
|
||||
|
||||
html = '''
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
|
||||
<h1> Attestation de {nom} {prenom} </h1>
|
||||
<h3> Attestation de {nom} {prenom} </h3>
|
||||
Bonjour, <br/>
|
||||
Merci de trouver votre attestation de la formation {maformation} en pièce jointe
|
||||
<br/>
|
||||
|
|
114
main.py
114
main.py
|
@ -45,6 +45,8 @@ import business_prices as business_prices
|
|||
import lms_chamilo.mysy_lms as mysy_lms
|
||||
import code_promo_mgt as code_promo_mgt
|
||||
from apscheduler.schedulers.background import BackgroundScheduler
|
||||
import appel_offre as appel_offre
|
||||
import partner_client as partner_client
|
||||
|
||||
app = Flask(__name__)
|
||||
cors = CORS(app, resources={r"/foo": {"origins": "*"}})
|
||||
|
@ -3135,6 +3137,118 @@ def test_stripe():
|
|||
localStatus, message = Stripe.test_stripe()
|
||||
return jsonify(status=localStatus,)
|
||||
|
||||
"""
|
||||
API de creation d'un appel d'offre
|
||||
"""
|
||||
@app.route('/myclass/api/Add_Appel_Offre/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Add_Appel_Offre():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Add_Appel_Offre : payload = ",payload)
|
||||
localStatus, message = appel_offre.Add_Appel_Offre(payload)
|
||||
return jsonify(status=localStatus, message=message)
|
||||
|
||||
"""
|
||||
API de mise à jour d'un appel d'offre
|
||||
"""
|
||||
@app.route('/myclass/api/Update_Appel_Offre/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Update_Appel_Offre():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Update_Appel_Offre : payload = ",payload)
|
||||
localStatus, message = appel_offre.Update_Appel_Offre(payload)
|
||||
return jsonify(status=localStatus, message=message)
|
||||
|
||||
|
||||
"""
|
||||
API de recuperation d'un appel d'offre donnée
|
||||
"""
|
||||
@app.route('/myclass/api/Get_Given_Appel_Offre/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Get_Given_Appel_Offre():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Get_Given_Appel_Offre : payload = ",payload)
|
||||
localStatus, message = appel_offre.Get_Given_Appel_Offre(payload)
|
||||
return jsonify(status=localStatus, message=message)
|
||||
|
||||
"""
|
||||
API de recuperation d'une liste d'appel d'offre d'un partenaire
|
||||
"""
|
||||
@app.route('/myclass/api/Get_List_Appel_Offre/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Get_List_Appel_Offre():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Get_List_Appel_Offre : payload = ",payload)
|
||||
localStatus, message = appel_offre.Get_List_Appel_Offre(payload)
|
||||
return jsonify(status=localStatus, message=message)
|
||||
|
||||
|
||||
"""
|
||||
API qui permet de faire une manifestation d'interet pour une AO
|
||||
"""
|
||||
@app.route('/myclass/api/Manifestation_Interet_Appel_Offre/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Add_Manifestation_Interet_Appel_Offre():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Manifestation_Interet_Appel_Offre : payload = ",payload)
|
||||
localStatus, message = appel_offre.Manifestation_Interet_Appel_Offre(payload)
|
||||
return jsonify(status=localStatus, message=message)
|
||||
|
||||
|
||||
"""
|
||||
API qui permet de faire une réponse d'interet pour une AO
|
||||
"""
|
||||
@app.route('/myclass/api/Reponse_Appel_Offre/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Add_Reponse_Appel_Offre():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Reponse_Appel_Offre : payload = ",payload)
|
||||
localStatus, message = appel_offre.Reponse_Appel_Offre(payload)
|
||||
return jsonify(status=localStatus, message=message)
|
||||
|
||||
"""
|
||||
API qui retourne la liste des manifesations d'interet pour un AO
|
||||
"""
|
||||
@app.route('/myclass/api/Get_List_Manifestation_Interet_Appel_Offre/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Get_List_Manifestation_Interet_Appel_Offre():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Get_List_Manifestation_Interet_Appel_Offre : payload = ",payload)
|
||||
localStatus, message = appel_offre.Get_List_Manifestation_Interet_Appel_Offre(payload)
|
||||
return jsonify(status=localStatus, message=message)
|
||||
|
||||
"""
|
||||
API qui retourne la liste des réponses pour un AO
|
||||
"""
|
||||
@app.route('/myclass/api/Get_List_Reponse_Appel_Offre/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Get_List_Reponse_Appel_Offre():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Get_List_Reponse_Appel_Offre : payload = ",payload)
|
||||
localStatus, message = appel_offre.Get_List_Reponse_Appel_Offre(payload)
|
||||
return jsonify(status=localStatus, message=message)
|
||||
|
||||
"""
|
||||
API de creation d'un client d'un partner
|
||||
"""
|
||||
@app.route('/myclass/api/Add_Partner_Client/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Add_Partner_Client():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Add_Partner_Client : payload = ",payload)
|
||||
localStatus, message = partner_client.Add_Partner_Client(payload)
|
||||
return jsonify(status=localStatus, message=message)
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
print(" debut api")
|
||||
|
|
|
@ -0,0 +1,241 @@
|
|||
"""
|
||||
Ce fichier permet de gerer tout qui est lié aux client d'un partenaire.
|
||||
|
||||
Cas d'utilisation :
|
||||
Un partenaire de mysy, souhaite créer (CRUD) ses clients
|
||||
Emettre des devis, bons de commandes, des factures, etc....
|
||||
"""
|
||||
|
||||
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
|
||||
import GlobalVariable as MYSY_GV
|
||||
from math import isnan
|
||||
import GlobalVariable as MYSY_GV
|
||||
import ela_index_bdd_classes as eibdd
|
||||
import email_mgt as email
|
||||
import ast
|
||||
|
||||
def Add_Partner_Client(diction):
|
||||
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', "raison_sociale", "nom", "siret", "tva", "email",
|
||||
"telephone", "website", "comment", "address", "invoice_address", "list_contact", ]
|
||||
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")
|
||||
return False, " Les informations fournies sont incorrectes",
|
||||
|
||||
"""
|
||||
Verification des champs obligatoires
|
||||
"""
|
||||
field_list_obligatoire = ['token', "raison_sociale", "nom", "email", "telephone", "address", ]
|
||||
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']
|
||||
|
||||
# Verifier la validité du token
|
||||
retval = mycommon.check_partner_token_validity("", token)
|
||||
|
||||
if retval is False:
|
||||
return "Err_Connexion", " La session de connexion n'est pas valide"
|
||||
|
||||
partner_recid = mycommon.get_parnter_recid_from_token(token)
|
||||
if (partner_recid is False):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " - partner_recid est KO. Les données de connexion sont incorrectes ")
|
||||
return False, " Vous n'etes pas autorisé à utiliser cette API "
|
||||
|
||||
# Recuperation des données du partenaire
|
||||
local_status, my_partner = mycommon.get_partner_data_from_recid(partner_recid)
|
||||
if (local_status is False):
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - impossible de recuperer les données du partenaire")
|
||||
return False, str(inspect.stack()[0][3]) + " - impossible de recuperer les données du partenaire. "
|
||||
|
||||
|
||||
"""
|
||||
Verification s'il n'existe pas un cient du partenaire qui perte le meme
|
||||
nom, ou la meme adresse email
|
||||
"""
|
||||
|
||||
qry = {'nom': str(diction['nom']), 'valide': '1', 'partner_recid': str(my_partner['recid'])}
|
||||
print(" ### qry = ", qry)
|
||||
|
||||
tmp_count = MYSY_GV.dbname['partner_client'].count_documents(qry)
|
||||
if (tmp_count > 0):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " - Cet appel d'offre est deja enregistré : nom = ", str(diction['nom']))
|
||||
|
||||
return False, " - Il existe déjà un client qui porte le même nom "
|
||||
|
||||
tmp_count = MYSY_GV.dbname['partner_client'].count_documents({'email': str(diction['email']),
|
||||
'valide': '1', 'partner_recid': my_partner['recid']})
|
||||
if (tmp_count > 0):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " - Cet appel d'offre est deja enregistré : email = ", str(diction['email']))
|
||||
|
||||
return False, " - Il existe déjà un client qui porte le même email principal "
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Recuperation des données fournies en entrée
|
||||
"""
|
||||
data = {}
|
||||
data['partner_recid'] = my_partner['recid']
|
||||
|
||||
raison_sociale = ""
|
||||
if ("raison_sociale" in diction.keys()):
|
||||
if diction['raison_sociale']:
|
||||
raison_sociale = diction['raison_sociale']
|
||||
data['raison_sociale'] = diction['raison_sociale']
|
||||
|
||||
nom = ""
|
||||
if ("nom" in diction.keys()):
|
||||
if diction['nom']:
|
||||
nom = diction['nom']
|
||||
data['nom'] = diction['nom']
|
||||
|
||||
siret = ""
|
||||
if ("siret" in diction.keys()):
|
||||
if diction['siret']:
|
||||
siret = diction['siret']
|
||||
data['siret'] = diction['siret']
|
||||
|
||||
tva = ""
|
||||
if ("tva" in diction.keys()):
|
||||
if diction['tva']:
|
||||
tva = diction['tva']
|
||||
data['tva'] = diction['tva']
|
||||
|
||||
email = ""
|
||||
if ("email" in diction.keys()):
|
||||
if diction['email']:
|
||||
email = diction['email']
|
||||
data['email'] = diction['email']
|
||||
|
||||
website = ""
|
||||
if ("website" in diction.keys()):
|
||||
if diction['website']:
|
||||
website = diction['website']
|
||||
data['website'] = diction['website']
|
||||
|
||||
comment = ""
|
||||
if ("comment" in diction.keys()):
|
||||
if diction['comment']:
|
||||
comment = diction['comment']
|
||||
data['comment'] = diction['comment']
|
||||
|
||||
address = {}
|
||||
if ("address" in diction.keys()):
|
||||
if diction['address']:
|
||||
address = ast.literal_eval(diction['address'])
|
||||
data['address'] = ast.literal_eval(diction['address'])
|
||||
|
||||
invoice_address = {}
|
||||
if ("invoice_address" in diction.keys()):
|
||||
if diction['invoice_address']:
|
||||
invoice_address = ast.literal_eval(diction['invoice_address'])
|
||||
data['invoice_address'] = ast.literal_eval(diction['invoice_address'])
|
||||
|
||||
list_contact = ""
|
||||
if ("list_contact" in diction.keys()):
|
||||
if diction['list_contact']:
|
||||
list_contact = diction['list_contact']
|
||||
data['list_contact'] = diction['list_contact']
|
||||
|
||||
|
||||
""""
|
||||
/!\ : l'adresse etant directement enregistrée sur le client, alors verification que le ligne "adresse" contient bien les champs :
|
||||
- adresse, code postal, ville, pays
|
||||
"""
|
||||
|
||||
|
||||
adresse_field_list_obligatoire = ['adresse', "code_postal", "ville", "pays", ]
|
||||
for val in adresse_field_list_obligatoire:
|
||||
if val not in address.keys():
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " - Le champ '" + val + "' est obligatoire dans l'adresse")
|
||||
return False, " Le champ '" + val + "' est obligatoire dans l'adresse",
|
||||
|
||||
|
||||
print(" les info client à enregistrer : ", str(data))
|
||||
|
||||
return True, " Le client a été correctement créé"
|
||||
|
||||
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 d'ajouter le client "
|
||||
|
||||
"""
|
||||
Mise à jour d'un client
|
||||
"""
|
||||
def Update_Partner_Client(diction):
|
||||
try:
|
||||
|
||||
return True, " Le client a été correctement 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 mettre à jour le client "
|
||||
|
||||
|
||||
"""
|
||||
Recuperation d'une liste de client d'un partenaire
|
||||
"""
|
||||
|
||||
def Get_Partner_List_Partner_Client(diction):
|
||||
try:
|
||||
|
||||
return True, " Le client a été correctement 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 mettre à jour le client "
|
||||
|
||||
|
||||
"""
|
||||
Recuperation d'un client donnée
|
||||
"""
|
||||
def Get_Given_Partner_List_Client(diction):
|
||||
try:
|
||||
|
||||
return True, " Le client a été correctement 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 mettre à jour le client "
|
Loading…
Reference in New Issue