30/09/2023 - 14h

master
cherif 2023-09-30 14:16:41 +02:00
parent 7eb04d433f
commit 2c77645276
7 changed files with 5557 additions and 13 deletions

View File

@ -1,11 +1,14 @@
<?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="26/09/23 - 23h">
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="28/09/23 - 23h">
<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$/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$/ressources_humaines.py" beforeDir="false" afterPath="$PROJECT_DIR$/ressources_humaines.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/ressources_materiels.py" beforeDir="false" afterPath="$PROJECT_DIR$/ressources_materiels.py" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -69,13 +72,6 @@
<option name="presentableId" value="Default" />
<updated>1680804787304</updated>
</task>
<task id="LOCAL-00066" summary="13/08/23 - 14h">
<created>1691927654529</created>
<option name="number" value="00066" />
<option name="presentableId" value="LOCAL-00066" />
<option name="project" value="LOCAL" />
<updated>1691927654530</updated>
</task>
<task id="LOCAL-00067" summary="13/08/23 - 21h30">
<created>1691955829352</created>
<option name="number" value="00067" />
@ -412,7 +408,14 @@
<option name="project" value="LOCAL" />
<updated>1695805016862</updated>
</task>
<option name="localTasksCounter" value="115" />
<task id="LOCAL-00115" summary="28/09/23 - 23h">
<created>1695932550732</created>
<option name="number" value="00115" />
<option name="presentableId" value="LOCAL-00115" />
<option name="project" value="LOCAL" />
<updated>1695932550733</updated>
</task>
<option name="localTasksCounter" value="116" />
<servers />
</component>
<component name="Vcs.Log.Tabs.Properties">
@ -427,7 +430,6 @@
</option>
</component>
<component name="VcsManagerConfiguration">
<MESSAGE value="28/08/23 - 19h30" />
<MESSAGE value="30/08/23 - 14h" />
<MESSAGE value="30/08/23 - 17h" />
<MESSAGE value="30/08/23 - 22h" />
@ -452,6 +454,7 @@
<MESSAGE value="25/09/2023 - 16h40" />
<MESSAGE value="26/09/23 - 19h" />
<MESSAGE value="26/09/23 - 23h" />
<option name="LAST_COMMIT_MESSAGE" value="26/09/23 - 23h" />
<MESSAGE value="28/09/23 - 23h" />
<option name="LAST_COMMIT_MESSAGE" value="28/09/23 - 23h" />
</component>
</project>

File diff suppressed because it is too large Load Diff

13
main.py
View File

@ -4033,6 +4033,19 @@ def Get_Related_Target_Collection_Data():
return jsonify(status=status, message=retval)
"""
API de creation de compte utilisateur (ou mise à jour) : login & pass
"""
@app.route('/myclass/api/Add_Update_Employee_Login_Pass/', methods=['POST','GET'])
@crossdomain(origin='*')
def Add_Update_Employee_Login_Pass():
# On recupere le corps (payload) de la requete
payload = mycommon.strip_dictionary (request.form.to_dict())
print(" ### Add_Update_Employee_Login_Pass payload = ",payload)
status, retval = ressources_humaines.Add_Update_Employee_Login_Pass(payload)
return jsonify(status=status, message=retval)
"""
API qui ajoute une ressource materielles
"""

View File

@ -106,6 +106,13 @@ def add_partner_account(diction):
if diction['email']:
mydata['email'] = diction['email']
mydata['invoice_email'] = diction['email']
if (mycommon.isEmailValide(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 "
if ("telephone" in diction.keys()):
if diction['telephone']:

View File

@ -600,7 +600,7 @@ returl status et la valeur
def IsFloat(val):
try:
val = str(val).replace(",",".")
myfloat = float(val)
myfloat = round(float(val), 2)
return True, myfloat
except ValueError:
return False, 0

View File

@ -2924,5 +2924,183 @@ def Get_Related_Target_Collection_Data(diction):
return False, " Impossible de récupérer les information des cibles "
"""
Cette Fonction crée ou met à jour le login et passwd d'un employe
"""
def Add_Update_Employee_Login_Pass(diction):
try:
diction = mycommon.strip_dictionary(diction)
"""
Verification des input acceptés
"""
field_list = ['token', 'nom', 'email', 'pwd', 'telephone', 'contact_nom', 'contact_prenom', 'contact_tel',
'contact_mail', 'ressource_humaine_id']
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'est pas autorisé")
return False, " Les informations fournies sont incorrectes",
"""
Verification des champs obligatoires
"""
field_list_obligatoire = ['token', 'email', 'pwd',
'ressource_humaine_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, " Les informations fournies sont incorrectes",
"""
Verification de l'identité et autorisation de l'entité qui
appelle cette API
"""
token = ""
if ("token" in diction.keys()):
if diction['token']:
token = diction['token']
local_status, my_partner = mycommon.Check_Connexion_And_Return_Partner_Data(diction)
if (local_status is not True):
return local_status, my_partner
mydata = {}
email = ""
if ("email" in diction.keys()):
if diction['email']:
email = diction['email']
if (mycommon.isEmailValide(email) is False):
mycommon.myprint(
str(inspect.stack()[0][
3]) + " - L'adresse email " + str(email) + " n'est pas valide")
return False, " - - L'adresse email " + str(email) + " n'est pas valide "
mydata['email'] = email
pwd = ""
if ("pwd" in diction.keys()):
if diction['pwd']:
pwd = diction['pwd']
mydata['pwd'] = pwd
contact_nom = ""
if ("contact_nom" in diction.keys()):
if diction['contact_nom']:
contact_nom = diction['contact_nom']
mydata['contact_nom'] = contact_nom
contact_prenom = ""
if ("contact_prenom" in diction.keys()):
if diction['contact_prenom']:
contact_prenom = diction['contact_prenom']
mydata['contact_prenom'] = contact_prenom
contact_mail = ""
if ("contact_mail" in diction.keys()):
if diction['contact_mail']:
contact_mail = diction['contact_mail']
mydata['contact_mail'] = contact_mail
mydata['num_nda'] = ''
mydata['nom'] = str(my_partner['nom'])
mydata['pack_service'] = str(my_partner['pack_service'])
mydata['nb_formation'] = str(my_partner['nb_formation'])
mydata['stripe_account_id'] = str(my_partner['stripe_account_id'])
mydata['stripe_paymentmethod_id'] = str(my_partner['stripe_paymentmethod_id'])
mydata['lms_username'] = str(my_partner['lms_username'])
mydata['lms_virtualhost_id'] = str(my_partner['lms_virtualhost_id'])
mydata['mysy_lms_user_id'] = str(my_partner['mysy_lms_user_id'])
mydata['recid'] = str(my_partner['recid'])
mydata['active'] = '1'
mydata['locked'] = '0'
ressource_humaine_id = ""
if ("ressource_humaine_id" in diction.keys()):
if diction['ressource_humaine_id']:
ressource_humaine_id = diction['ressource_humaine_id']
mydata['ressource_humaine_id'] = ressource_humaine_id
"""
# Si le compte existe deja, verifier que l'adresse email qui est stocké (collection : partner_account) correspond
# au ressource_humaine_id.
En gros, si l'adresse email existe, sont ressource_humaine_id doit etre = au 'ressource_humaine_id' fourni, si cela
veut dire que l'email est appartient à un autre partner
"""
count_existe_with_wrong_ressource_humaine_id = False
count_existe_with_correct_ressource_humaine_id = False
count_account = 0
for retval in MYSY_GV.dbname['partnair_account'].find({'email': str(email)}):
count_account = count_account + 1
if (str(retval['ressource_humaine_id']) == str(ressource_humaine_id)):
count_existe_with_correct_ressource_humaine_id = True
else:
count_existe_with_wrong_ressource_humaine_id = True
if( count_account > 1):
mycommon.myprint(
str(inspect.stack()[0][
3]) + " - L'adresse email " + str(email) + " correspond à plusieurs utilisateurs ("+str(count_account)+") ")
return False, " - L'adresse email " + str(email) + " correspond à plusieurs utilisateurs "
if (count_existe_with_wrong_ressource_humaine_id is True):
mycommon.myprint(
str(inspect.stack()[0][
3]) + " - L'adresse email " + str(email) + " existe déjà et rattaché à un autre partenaire")
return False, " - L'adresse email " + str(email) + " existe déjà et rattaché à un autre partenaire "
inserted_id = ""
result = MYSY_GV.dbname['partnair_account'].find_one_and_update(
{'email':str(email)},
{"$set": mydata},
upsert=True,
return_document=ReturnDocument.AFTER
)
if (result is None or "_id" not in result.keys()):
mycommon.myprint(
" Impossible de créer ou mettre à jour le compte utilisateur pour " + str(diction['email']))
return False, " Impossible de créer ou mettre à jour le compte utilisateur "
"""
Mettre à jour les données de l'employé en mettant le login
"""
MYSY_GV.dbname['ressource_humaine'].update_one({'_id':ObjectId(str(ressource_humaine_id)), 'partner_recid':str(my_partner['recid'])},
{'$set':{'user_login':str(email), 'account_partner_id':str(result['_id']),
'is_partner_admin_account':'0', 'date_update':str(datetime.now())}})
if( count_existe_with_correct_ressource_humaine_id is True):
# Mise à jour d'un compte existant,
print(" ### Envoyer le mail de MISE A JOUR ")
else:
# Creation d'un compte utilisateur
print(" ### Envoyer le mail de CREATION COMPTE UTILISATEUR ")
print(" #### le compte : ", result)
return True, " Les accès ont été crée. Le login et le mot de passe envoyé à xxxx"
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 la ressource "

View File

@ -1692,7 +1692,16 @@ def Get_Related_Target_Materiel_Collection_Data(diction):
retval_data = {}
retval_data['related_target_collection'] = "ressource_humaine"
retval_data['related_target_collection_id'] = str(retval['_id'])
retval_data['related_target_collection_id_nom'] = str(str(retval['prenom'])+" "+str(retval['nom']))
nom = ""
prenom = ""
if( "nom" in retval.keys()):
nom = retval['nom']
if ("prenom" in retval.keys()):
prenom = retval['prenom']
retval_data['related_target_collection_id_nom'] = str(str(nom+" "+prenom))
RetObject.append(mycommon.JSONEncoder().encode(retval_data))