21/12/2023 - 14h30
parent
bb3751168a
commit
d5f66144f8
|
@ -3,10 +3,8 @@
|
|||
<component name="ChangeListManager">
|
||||
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="20/12/2023 - 18h">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Inscription_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/Inscription_mgt.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Log/log_file.log" beforeDir="false" afterPath="$PROJECT_DIR$/Log/log_file.log" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/apprenant_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/apprenant_mgt.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/prj_common.py" beforeDir="false" afterPath="$PROJECT_DIR$/prj_common.py" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
|
|
1435
Log/log_file.log
1435
Log/log_file.log
File diff suppressed because it is too large
Load Diff
|
@ -9,7 +9,7 @@ from pymongo import MongoClient
|
|||
import json
|
||||
from bson import ObjectId
|
||||
import re
|
||||
from datetime import datetime
|
||||
from datetime import datetime, date
|
||||
import prj_common as mycommon
|
||||
import secrets
|
||||
import inspect
|
||||
|
@ -43,7 +43,7 @@ def Add_Apprenant(diction):
|
|||
'tuteur1_nom', 'tuteur1_prenom', 'tuteur1_email', 'tuteur1_telephone', 'tuteur1_adresse',
|
||||
'tuteur1_cp', 'tuteur1_ville', 'tuteur1_pays', 'tuteur1_include_com',
|
||||
'tuteur2_nom', 'tuteur2_prenom', 'tuteur2_email', 'tuteur2_telephone', 'tuteur2_adresse',
|
||||
'tuteur2_cp', 'tuteur2_ville', 'tuteur2_pays', 'tuteur2_include_com',
|
||||
'tuteur2_cp', 'tuteur2_ville', 'tuteur2_pays', 'tuteur2_include_com', 'civilite'
|
||||
]
|
||||
|
||||
incom_keys = diction.keys()
|
||||
|
@ -82,7 +82,25 @@ def Add_Apprenant(diction):
|
|||
if( mycommon.isEmailValide(str(diction['email'])) is False ):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " L'adresse email '"+str(diction['email'])+"' n'est pas valide")
|
||||
return False, " L'adresse email '"+str(diction['email'])+"' n'est pas valide ",
|
||||
return False, " L'adresse email '"+str(diction['email'])+"' n'est pas valide "
|
||||
|
||||
|
||||
# Verifier qu'il n'y pas un apprenant avec le mail
|
||||
qry = {'email':str(diction['email']),
|
||||
'partner_owner_recid':str(my_partner['recid']),
|
||||
'valide':'1'}
|
||||
|
||||
print(" ### qry = ", qry)
|
||||
|
||||
is_apprenant_email_exist = MYSY_GV.dbname['apprenant'].count_documents({'email':str(diction['email']),
|
||||
'partner_owner_recid':str(my_partner['recid']),
|
||||
'valide':'1'})
|
||||
|
||||
if(is_apprenant_email_exist > 0):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " Il y a déjà un apprenant avec la même adresse email : '" + str(diction['email']) + "' ")
|
||||
return False, " Il y a déjà un apprenant avec la même adresse email : '" + str(diction['email']) + "' "
|
||||
|
||||
|
||||
|
||||
# Verifier l'adresse email du tuteur 1
|
||||
|
@ -125,13 +143,27 @@ def Add_Apprenant(diction):
|
|||
str(inspect.stack()[0][3]) + " Il existe déjà un apprenant avec la même adresse email. ")
|
||||
return False, " Il existe déjà un apprenant avec la même adresse email. ",
|
||||
|
||||
|
||||
new_data = diction
|
||||
del new_data['token']
|
||||
local_token = new_data['token']
|
||||
|
||||
# Initialisation des champs non envoyés à vide
|
||||
for val in field_list:
|
||||
if val not in diction.keys():
|
||||
new_data[str(val)] = ""
|
||||
|
||||
|
||||
new_data['valide'] = '1'
|
||||
new_data['locked'] = '0'
|
||||
new_data['partner_owner_recid'] = str(my_partner['recid'])
|
||||
new_data['date_update'] = str(datetime.now())
|
||||
new_data['update_by'] = str(my_partner['_id'])
|
||||
|
||||
todays_date = str(date.today().strftime("%d/%m/%Y"))
|
||||
|
||||
new_data['date_creation'] = str(todays_date)
|
||||
|
||||
del new_data['token']
|
||||
inserted_id = MYSY_GV.dbname['apprenant'].insert_one(new_data).inserted_id
|
||||
if (not inserted_id):
|
||||
mycommon.myprint(
|
||||
|
@ -141,9 +173,9 @@ def Add_Apprenant(diction):
|
|||
## Add to log history
|
||||
now = str(datetime.now().strftime("%d/%m/%Y %H:%M:%S"))
|
||||
history_event_dict = {}
|
||||
history_event_dict['token'] = diction['token']
|
||||
history_event_dict['token'] = local_token
|
||||
history_event_dict['related_collection'] = "apprenant"
|
||||
history_event_dict['related_collection_recid'] = str(diction['inscription_id'])
|
||||
history_event_dict['related_collection_recid'] = str(inserted_id)
|
||||
history_event_dict['action_date'] = str(now)
|
||||
history_event_dict['action_description'] = "Creation"
|
||||
local_status, local_retval = mycommon.Collection_Historique.Add_Historique_Event(history_event_dict)
|
||||
|
@ -354,7 +386,7 @@ def Get_Given_Apprenant_Data(diction):
|
|||
|
||||
RetObject = []
|
||||
val_tmp = 1
|
||||
for val in MYSY_GV.dbname['apprenant'].find_one({'_id':ObjectId(str(diction['_id'])),
|
||||
for val in MYSY_GV.dbname['apprenant'].find({'_id':ObjectId(str(diction['_id'])),
|
||||
'partner_owner_recid':str(my_partner['recid']),
|
||||
'valide':'1',
|
||||
'locked':'0'}):
|
||||
|
@ -369,7 +401,8 @@ def Get_Given_Apprenant_Data(diction):
|
|||
'locked':'0'})
|
||||
user['client_nom'] = client_data['nom']
|
||||
|
||||
RetObject.append(mycommon.JSONEncoder().encode(user))
|
||||
RetObject.append(mycommon.JSONEncoder().encode(user))
|
||||
|
||||
return True, RetObject
|
||||
|
||||
except Exception as e:
|
||||
|
@ -508,7 +541,7 @@ def Get_List_Partner_Apprenant(diction):
|
|||
|
||||
RetObject = []
|
||||
val_tmp = 1
|
||||
for val in MYSY_GV.dbname['apprenant'].find_one({'partner_owner_recid': str(my_partner['recid']),
|
||||
for val in MYSY_GV.dbname['apprenant'].find({'partner_owner_recid': str(my_partner['recid']),
|
||||
'valide': '1',
|
||||
'locked': '0'}):
|
||||
user = val
|
||||
|
@ -523,7 +556,8 @@ def Get_List_Partner_Apprenant(diction):
|
|||
'locked': '0'})
|
||||
user['client_nom'] = client_data['nom']
|
||||
|
||||
RetObject.append(mycommon.JSONEncoder().encode(user))
|
||||
RetObject.append(mycommon.JSONEncoder().encode(user))
|
||||
|
||||
return True, RetObject
|
||||
|
||||
except Exception as e:
|
||||
|
|
Loading…
Reference in New Issue