dddss
parent
d3db7a0f7c
commit
55f8fc300b
|
@ -4,8 +4,9 @@
|
|||
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="ddd">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Log/log_file.log" beforeDir="false" afterPath="$PROJECT_DIR$/Log/log_file.log" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Session_Formation.py" beforeDir="false" afterPath="$PROJECT_DIR$/Session_Formation.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/model_planning_sequence_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/model_planning_sequence_mgt.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/partner_order.py" beforeDir="false" afterPath="$PROJECT_DIR$/partner_order.py" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
|
|
|
@ -45,7 +45,6 @@ import partner_base_setup as partner_base_setup
|
|||
"""
|
||||
Fonction de creation et mise à jour d'une session de formation.
|
||||
|
||||
|
||||
/!\ : le champ 'source' definit la source de la creation de la session
|
||||
|
||||
si le champ 'session_id' est renseigné alors c'est une mise à jour.
|
||||
|
@ -12512,3 +12511,196 @@ def Client_Update_Liste_Attendee_No_Token(diction):
|
|||
|
||||
|
||||
|
||||
"""
|
||||
Cette fonction permet de créer une session de formation
|
||||
à partir d'une ligne de devis
|
||||
"""
|
||||
"""
|
||||
Fonction de creation et mise à jour d'une session de formation.
|
||||
|
||||
/!\ : le champ 'source' definit la source de la creation de la session
|
||||
|
||||
si le champ 'session_id' est renseigné alors c'est une mise à jour.
|
||||
"""
|
||||
|
||||
|
||||
def Add_SessionFormation_From_Quotation_Line(diction):
|
||||
try:
|
||||
|
||||
'''
|
||||
# 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.
|
||||
'''
|
||||
field_list = ['token', 'date_debut', 'date_fin', 'nb_participant', 'adresse',
|
||||
'code_postal', 'ville', 'code_session',
|
||||
'class_id', 'session_status', 'date_debut_inscription', 'date_fin_inscription',
|
||||
'attestation_certif', "distantiel", "presentiel", "prix_session", 'contenu_ftion',
|
||||
'lms_class_code',
|
||||
'session_ondemande', 'source', 'session_etape', 'pays', 'formateur_id',
|
||||
'titre', 'location_type', 'is_bpf', 'site_formation_id', 'price_by',
|
||||
'quotation_line_id']
|
||||
|
||||
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'est pas autorisé.")
|
||||
return False, " Toutes les informations fournies ne sont pas valables"
|
||||
|
||||
"""
|
||||
Verification de la liste des champs obligatoires
|
||||
"""
|
||||
field_list_obligatoire = ['token', 'date_debut', 'date_fin', 'nb_participant',
|
||||
'class_id','code_session', 'quotation_line_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, "Toutes les informations necessaires n'ont pas été fournies"
|
||||
|
||||
mydata = {}
|
||||
query_key = {}
|
||||
|
||||
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 la validation de la formation
|
||||
"""
|
||||
is_valide_class_id_count = MYSY_GV.dbname['myclass'].count_documents({'_id':ObjectId(str(diction['class_id'])),
|
||||
'valide':'1',
|
||||
'locked':'0',
|
||||
'partner_owner_recid':str(my_partner['recid'])})
|
||||
|
||||
if( is_valide_class_id_count != 1 ):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " L'identifiant de la formation est invalide ")
|
||||
return False, " L'identifiant de la formation est invalide "
|
||||
|
||||
class_id_data = MYSY_GV.dbname['myclass'].find_one({'_id':ObjectId(str(diction['class_id'])),
|
||||
'valide':'1',
|
||||
'locked':'0',
|
||||
'partner_owner_recid':str(my_partner['recid'])},
|
||||
{'_id':1, 'internal_url':1, 'price':1, 'presentiel':1})
|
||||
|
||||
"""
|
||||
Verifier que le devis est valide
|
||||
"""
|
||||
|
||||
is_valide_quotation_count = MYSY_GV.dbname['partner_order_line'].count_documents({'_id':ObjectId(str(diction['quotation_line_id'])),
|
||||
'valide':'1',
|
||||
'locked':'0',
|
||||
'partner_owner_recid':str(my_partner['recid']),
|
||||
'order_line_type':'devis',
|
||||
'order_line_status': {
|
||||
'$in': ['1', '3']}
|
||||
})
|
||||
|
||||
if( is_valide_quotation_count != 1 ):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " Le devis n'est pas valide ")
|
||||
return False, " Le devis n'est pas valide "
|
||||
|
||||
mydata = diction
|
||||
|
||||
|
||||
del diction['token']
|
||||
|
||||
|
||||
|
||||
# Initialisation des champs non envoyés à vide
|
||||
for val in field_list:
|
||||
if val not in mydata.keys():
|
||||
mydata[str(val)] = ""
|
||||
|
||||
mydata['titre'] = str(mydata['code_session'])
|
||||
mydata['class_internal_url'] = str(class_id_data['internal_url'])
|
||||
mydata['prix_session'] = str(class_id_data['price'])
|
||||
mydata['price_by'] = "persession"
|
||||
mydata['session_status'] = "1"
|
||||
|
||||
mydata['date_update'] = str(datetime.now())
|
||||
mydata['update_by'] = str(my_partner['_id'])
|
||||
mydata['partner_owner_recid'] = str(my_partner['recid'])
|
||||
mydata['valide'] = "1"
|
||||
mydata['locked'] = "0"
|
||||
|
||||
|
||||
|
||||
# Controle de cohérence sur les dates
|
||||
local_status = mycommon.CheckisDate(str(diction['date_debut'])[0:10])
|
||||
if (local_status is False):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " La date de debut n'est pas au format jj/mm/aaaa ")
|
||||
|
||||
return False, " La date de debut n'est pas au format jj/mm/aaaa "
|
||||
|
||||
local_status = mycommon.CheckisDate(str(diction['date_fin'])[0:10])
|
||||
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 "
|
||||
|
||||
if (datetime.strptime(str(diction['date_debut'])[0:10], '%d/%m/%Y') > datetime.strptime(
|
||||
str(diction['date_fin'])[0:10], '%d/%m/%Y')):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + " Session de Formation : La date debut " + str(
|
||||
diction['date_debut'])[0:10] +
|
||||
" est postérieure à la date de fin " + str(diction['date_fin'])[0:10])
|
||||
|
||||
return False, " Session de Formation : La date debut de formation " + str(diction['date_debut'])[0:10] + \
|
||||
" est postérieure à la date de fin de formation " + str(diction['date_fin'])[0:10] + " "
|
||||
|
||||
|
||||
# Fin Controle de cohérence sur les dates
|
||||
|
||||
|
||||
|
||||
# La session n'existe pas, on fait une simple creation
|
||||
|
||||
|
||||
coll_name = MYSY_GV.dbname['session_formation']
|
||||
ret_val = coll_name.insert_one(mydata)
|
||||
|
||||
local_inserted_id = ret_val.inserted_id
|
||||
|
||||
if (ret_val is None or not hasattr(ret_val, 'inserted_id')):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " Impossible d'ajouter la session '" + str(
|
||||
diction['code_session']) + "' ")
|
||||
return False, "Impossible d'ajouter la session '" + str(diction['code_session']) + "' "
|
||||
|
||||
"""
|
||||
Apres la creation de la session, on met à jour la ligne du devis en ajoutant l'id de la session
|
||||
"""
|
||||
update_quotation_line_id = MYSY_GV.dbname['partner_order_line'].find_one_and_update(
|
||||
{'_id': ObjectId(str(diction['quotation_line_id'])),
|
||||
'partner_owner_recid': str(my_partner['recid']),
|
||||
'valide': '1',
|
||||
'locked': '0'},
|
||||
{"$set": {'order_line_session_id':str(local_inserted_id)}},
|
||||
return_document=ReturnDocument.AFTER,
|
||||
upsert=False,
|
||||
)
|
||||
|
||||
|
||||
return True, " La session de formation à bien été créée"
|
||||
|
||||
|
||||
except Exception as e:
|
||||
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))
|
||||
return False, "Impossible de créer la session de formation"
|
||||
|
|
13
main.py
13
main.py
|
@ -3677,6 +3677,19 @@ def Client_Update_Liste_Attendee_No_Token():
|
|||
return jsonify(status=localStatus, message=message )
|
||||
|
||||
|
||||
"""
|
||||
API permet de créer une session de formation en partant d'un devis
|
||||
"""
|
||||
@app.route('/myclass/api/Add_SessionFormation_From_Quotation_Line/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Add_SessionFormation_From_Quotation_Line():
|
||||
# On CancelAttendeeInscription le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Add_SessionFormation_From_Quotation_Line : payload = ",payload)
|
||||
localStatus, message= SF.Add_SessionFormation_From_Quotation_Line(payload)
|
||||
return jsonify(status=localStatus, message=message )
|
||||
|
||||
|
||||
|
||||
"""
|
||||
API de validation d'une inscription d'un stagiaire
|
||||
|
|
|
@ -3431,6 +3431,9 @@ def Get_Given_Partner_Order_Lines(diction):
|
|||
user['title'] = retval['myclass_collection'][0]['title']
|
||||
user['order_line_formation_external_code'] = retval['myclass_collection'][0]['external_code']
|
||||
|
||||
user['class_id'] = str(retval['myclass_collection'][0]['_id'])
|
||||
|
||||
|
||||
if( "domaine" in retval['myclass_collection'][0].keys() ):
|
||||
user['domaine'] = retval['myclass_collection'][0]['domaine']
|
||||
else:
|
||||
|
@ -3768,6 +3771,8 @@ def Get_Given_Partner_Order_Lines_From_order_ref_interne(diction):
|
|||
user['title'] = retval['myclass_collection'][0]['title']
|
||||
user['order_line_formation_external_code'] = retval['myclass_collection'][0]['external_code']
|
||||
|
||||
user['class_id'] = str(retval['myclass_collection'][0]['_id'])
|
||||
|
||||
if ("domaine" in retval['myclass_collection'][0].keys()):
|
||||
user['domaine'] = retval['myclass_collection'][0]['domaine']
|
||||
else:
|
||||
|
@ -4583,6 +4588,7 @@ def Get_Given_Line_Of_Partner_Order_Lines(diction):
|
|||
|
||||
user['title'] = retval['myclass_collection'][0]['title']
|
||||
user['order_line_formation_external_code'] = retval['myclass_collection'][0]['external_code']
|
||||
user['class_id'] = str(retval['myclass_collection'][0]['_id'])
|
||||
|
||||
if ("domaine" in retval['myclass_collection'][0].keys()):
|
||||
user['domaine'] = retval['myclass_collection'][0]['domaine']
|
||||
|
@ -5241,6 +5247,7 @@ def GerneratePDF_Partner_Order(diction):
|
|||
|
||||
user['title'] = retval['myclass_collection'][0]['title']
|
||||
user['order_line_formation_external_code'] = retval['myclass_collection'][0]['external_code']
|
||||
user['class_id'] = str(retval['myclass_collection'][0]['_id'])
|
||||
|
||||
if( "domaine" in retval['myclass_collection'][0].keys() ):
|
||||
user['domaine'] = retval['myclass_collection'][0]['domaine']
|
||||
|
@ -5726,6 +5733,7 @@ def Gernerate_Stock_PDF_Partner_Order(diction):
|
|||
|
||||
user['title'] = retval['myclass_collection'][0]['title']
|
||||
user['order_line_formation_external_code'] = retval['myclass_collection'][0]['external_code']
|
||||
user['class_id'] = str(retval['myclass_collection'][0]['_id'])
|
||||
|
||||
if( "domaine" in retval['myclass_collection'][0].keys() ):
|
||||
user['domaine'] = retval['myclass_collection'][0]['domaine']
|
||||
|
@ -6210,6 +6218,7 @@ def Send_Partner_Order_By_Email(diction):
|
|||
|
||||
user['title'] = retval['myclass_collection'][0]['title']
|
||||
user['order_line_formation_external_code'] = retval['myclass_collection'][0]['external_code']
|
||||
user['class_id'] = str(retval['myclass_collection'][0]['_id'])
|
||||
|
||||
if ("domaine" in retval['myclass_collection'][0].keys()):
|
||||
user['domaine'] = retval['myclass_collection'][0]['domaine']
|
||||
|
@ -8082,6 +8091,7 @@ def Send_Quotation_Remind_Level1(diction):
|
|||
|
||||
user['title'] = retval['myclass_collection'][0]['title']
|
||||
user['order_line_formation_external_code'] = retval['myclass_collection'][0]['external_code']
|
||||
user['class_id'] = str(retval['myclass_collection'][0]['_id'])
|
||||
|
||||
if ("domaine" in retval['myclass_collection'][0].keys()):
|
||||
user['domaine'] = retval['myclass_collection'][0]['domaine']
|
||||
|
|
Loading…
Reference in New Issue