30/09/2023 - 18h
parent
2c77645276
commit
87a35adbaa
|
@ -1,14 +1,13 @@
|
|||
<?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="28/09/23 - 23h">
|
||||
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="30/09/2023 - 14h">
|
||||
<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$/email_inscription_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/email_inscription_mgt.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/email_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/email_mgt.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" />
|
||||
|
@ -72,13 +71,6 @@
|
|||
<option name="presentableId" value="Default" />
|
||||
<updated>1680804787304</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00067" summary="13/08/23 - 21h30">
|
||||
<created>1691955829352</created>
|
||||
<option name="number" value="00067" />
|
||||
<option name="presentableId" value="LOCAL-00067" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1691955829354</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00068" summary="14/08/23 - 16h30">
|
||||
<created>1692023863799</created>
|
||||
<option name="number" value="00068" />
|
||||
|
@ -415,7 +407,14 @@
|
|||
<option name="project" value="LOCAL" />
|
||||
<updated>1695932550733</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="116" />
|
||||
<task id="LOCAL-00116" summary="30/09/2023 - 14h">
|
||||
<created>1696076203877</created>
|
||||
<option name="number" value="00116" />
|
||||
<option name="presentableId" value="LOCAL-00116" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1696076203877</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="117" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="Vcs.Log.Tabs.Properties">
|
||||
|
@ -430,7 +429,6 @@
|
|||
</option>
|
||||
</component>
|
||||
<component name="VcsManagerConfiguration">
|
||||
<MESSAGE value="30/08/23 - 14h" />
|
||||
<MESSAGE value="30/08/23 - 17h" />
|
||||
<MESSAGE value="30/08/23 - 22h" />
|
||||
<MESSAGE value="01/09/23 - 19h" />
|
||||
|
@ -455,6 +453,7 @@
|
|||
<MESSAGE value="26/09/23 - 19h" />
|
||||
<MESSAGE value="26/09/23 - 23h" />
|
||||
<MESSAGE value="28/09/23 - 23h" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="28/09/23 - 23h" />
|
||||
<MESSAGE value="30/09/2023 - 14h" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="30/09/2023 - 14h" />
|
||||
</component>
|
||||
</project>
|
2068
Log/log_file.log
2068
Log/log_file.log
File diff suppressed because it is too large
Load Diff
|
@ -1456,3 +1456,115 @@ def LMS_Credential_Sending_mail(diction):
|
|||
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
|
||||
return False, " Impossible d'envoyer l'email de notification "
|
||||
|
||||
"""
|
||||
Fonction qui envoi les identifiant de connexion à un employé dont on vient de créer le compte
|
||||
utilisateur
|
||||
"""
|
||||
def Employee_Credential_Sending_mail(diction):
|
||||
try:
|
||||
|
||||
"""
|
||||
Verification de la liste des champs obligatoires
|
||||
"""
|
||||
field_list_obligatoire = ['nom', 'prenom', 'email', 'login', 'pwd', 'mysy_url',
|
||||
'email_bcc', 'partner_owner_recid' ]
|
||||
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 d'envoyer les information de connexion à la plateforme LMS"
|
||||
"""
|
||||
local_status, is_account_exist = mycommon.is_LMS_user_exist(diction)
|
||||
|
||||
if( local_status is False or is_account_exist is False):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " - Le compte LMS n'est pas valide ")
|
||||
return False, "Le compte LMS n'est pas valide"
|
||||
|
||||
"""
|
||||
tomorrow = datetime.date.today() + datetime.timedelta(days=1)
|
||||
tomorrow_day = tomorrow.strftime("%A")
|
||||
|
||||
print("debut envoi mail de test ")
|
||||
|
||||
# on rentre les renseignements pris sur le site du fournisseur
|
||||
|
||||
# msg = MIMEMultipart("alternative")
|
||||
smtpserver = smtplib.SMTP(MYSY_GV.O365_SMTP_COUNT_smtpsrv, MYSY_GV.O365_SMTP_COUNT_port)
|
||||
msg = EmailMessage()
|
||||
|
||||
# JINJA2
|
||||
# This data can come from database query
|
||||
body = {}
|
||||
|
||||
body = {
|
||||
|
||||
"params": {"nom": str(diction['nom']),
|
||||
"prenom": str(diction['prenom']),
|
||||
"email": str(diction['email']),
|
||||
"login": str(diction['login']),
|
||||
"pwd": str(diction['pwd']),
|
||||
"mysy_url": str(diction['mysy_url']),
|
||||
},
|
||||
}
|
||||
|
||||
#------------------
|
||||
partner_document_EMPLOYEE_CREDENTIALS_data_qry = {'partner_owner_recid': str(diction['partner_owner_recid']),
|
||||
'valide': '1', 'locked': '0', 'ref_interne': 'EMPLOYEE_CREDENTIALS'}
|
||||
|
||||
print(" ### partner_document_EMPLOYEE_CREDENTIALS_data_qry = ", partner_document_EMPLOYEE_CREDENTIALS_data_qry)
|
||||
|
||||
partner_document_EMPLOYEE_CREDENTIALS_data = MYSY_GV.dbname['courrier_template'].find_one(partner_document_EMPLOYEE_CREDENTIALS_data_qry)
|
||||
|
||||
|
||||
if (partner_document_EMPLOYEE_CREDENTIALS_data is None):
|
||||
# Il n'existe pas de personnalisation de la preinscription pour ce partenaire, on va aller récupérer la presinscription pa defaut
|
||||
partner_document_EMPLOYEE_CREDENTIALS_data = MYSY_GV.dbname['courrier_template'].find_one(
|
||||
{'partner_owner_recid': 'default',
|
||||
'valide': '1', 'locked': '0', 'ref_interne': 'EMPLOYEE_CREDENTIALS'})
|
||||
|
||||
if (partner_document_EMPLOYEE_CREDENTIALS_data is None):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][
|
||||
3]) + "-Impossible d'envoyer l'email de notification des accès. Aucun document parametré ")
|
||||
return False, " Impossible d'envoyer l'email de notification des accès. Aucun document parametré "
|
||||
|
||||
if ("contenu_doc" not in partner_document_EMPLOYEE_CREDENTIALS_data or len(
|
||||
str(partner_document_EMPLOYEE_CREDENTIALS_data['contenu_doc'])) <= 0):
|
||||
mycommon.myprint(str(inspect.stack()[0][
|
||||
3]) + " -Impossible d'envoyer l'email de notification des accès. Le parametrage du document est invalide")
|
||||
return False, " Impossible d'envoyer l'email de notification des accès. Le parametrage du document est invalide "
|
||||
|
||||
EMPLOYEE_CREDENTIALS_contenu_doc_Template = jinja2.Template(
|
||||
str(partner_document_EMPLOYEE_CREDENTIALS_data['contenu_doc']))
|
||||
|
||||
sourceHtml = EMPLOYEE_CREDENTIALS_contenu_doc_Template.render(params=body["params"])
|
||||
|
||||
# print(" ### PRE_INSCRIPTION_contenu_doc = ",str(sourceHtml))
|
||||
msg.set_content(sourceHtml, subtype='html')
|
||||
|
||||
smtpserver = smtplib.SMTP(MYSY_GV.O365_SMTP_COUNT_smtpsrv, MYSY_GV.O365_SMTP_COUNT_port)
|
||||
|
||||
|
||||
msg['From'] = MYSY_GV.O365_SMTP_COUNT_From_User
|
||||
#msg['Bcc'] = 'contact@mysy-training.com'
|
||||
msg['Subject'] = '[MySy Training]: Vos identifiants de connexion'
|
||||
msg['To'] = str(diction['email'])
|
||||
msg['Bcc'] = str(diction['email_bcc'])
|
||||
|
||||
#-----------------
|
||||
|
||||
smtpserver.ehlo()
|
||||
smtpserver.starttls()
|
||||
smtpserver.login(MYSY_GV.O365_SMTP_COUNT_user, MYSY_GV.O365_SMTP_COUNT_password)
|
||||
val = smtpserver.send_message(msg)
|
||||
smtpserver.close()
|
||||
print(" Email EMPLOYEE_CREDENTIALS envoyé " + str(val))
|
||||
|
||||
|
||||
return True, " Email d'identification de connexion envoyé "
|
||||
|
||||
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 d'envoyer l'email de notification "
|
||||
|
|
|
@ -1369,6 +1369,7 @@ def Pro_Account_Token_Pass(account_mail, my_token):
|
|||
data_employe_admin['is_partner_admin_account'] = "1"
|
||||
data_employe_admin['account_partner_id'] = str(my_partner['_id'])
|
||||
|
||||
|
||||
print(" #### data_employe_admin = ", str(data_employe_admin))
|
||||
local_status, local_retval_inserted_id = ressources_humaines.Add_Partner_Admin_Ressource_Humaine_No_Toke(data_employe_admin)
|
||||
|
||||
|
|
15
partners.py
15
partners.py
|
@ -797,6 +797,7 @@ def update_partner_account(file_logo=None, file_cachet=None, Folder=None, dictio
|
|||
if(len(str(Parnter_Data['ressource_humaine_id'])) > 2 ):
|
||||
is_valide_rh_compte = True
|
||||
|
||||
|
||||
if( is_valide_rh_compte is False):
|
||||
data_employe_admin = {}
|
||||
data_employe_admin['partner_recid'] = str(Parnter_Data['recid'])
|
||||
|
@ -972,13 +973,14 @@ def get_partner_account(diction):
|
|||
coll_token = MYSY_GV.dbname['partner_token']
|
||||
tmp = coll_token.find({ 'token': str(token_value), 'valide': '1'})
|
||||
partnere_recid = tmp[0]['recid']
|
||||
parnter_account_id = tmp[0]['partner_account_id']
|
||||
|
||||
#print(" #### parters RECID = "+str(partnere_recid))
|
||||
|
||||
is_first_connexion = True
|
||||
|
||||
RetObject = []
|
||||
for retVal in coll_name.find({'recid': str(partnere_recid)}):
|
||||
for retVal in coll_name.find({'_id': ObjectId(str(parnter_account_id)), 'active':'1', 'locked':'0'}):
|
||||
#mycommon.myprint (str(retVal))
|
||||
if ("firstconnexion" in retVal.keys()):
|
||||
if retVal['firstconnexion'] and str(retVal['firstconnexion'] == "0"):
|
||||
|
@ -999,7 +1001,7 @@ def get_partner_account(diction):
|
|||
else:
|
||||
my_new_data = {'lastconnexion': now}
|
||||
|
||||
ret_val = coll_name.find_one_and_update({'recid': str(partnere_recid)},
|
||||
ret_val = coll_name.find_one_and_update({'_id': ObjectId(str(parnter_account_id)), 'active':'1', 'locked':'0'},
|
||||
{"$set": my_new_data},
|
||||
upsert=False,
|
||||
return_document=ReturnDocument.AFTER
|
||||
|
@ -1185,13 +1187,14 @@ def partner_login(diction):
|
|||
# 1 - Vu le login et passe sont valident, alors on va aller desactier un eventuel token qui existerait
|
||||
local_now = str(datetime.now())
|
||||
local_result = MYSY_GV.dbname['partner_token'].update_many(
|
||||
{"recid": partner_recid, 'valide': '1'},
|
||||
{'valide': '1', 'partner_account_id':str(my_partner['_id'])},
|
||||
{
|
||||
"$set": {"valide": '0', 'end_date': str(datetime.now()), 'date_update': str(datetime.now())}
|
||||
})
|
||||
|
||||
# Enregistrement du nouveau token
|
||||
tokenfield = {}
|
||||
tokenfield['partner_account_id'] = str(my_partner['_id'])
|
||||
tokenfield['email'] = email
|
||||
tokenfield['recid'] = partner_recid
|
||||
tokenfield['date_update'] = str(datetime.now())
|
||||
|
@ -1243,7 +1246,7 @@ def partner_login(diction):
|
|||
return_data = {}
|
||||
return_data['token'] = str(my_token)
|
||||
|
||||
print(" ### token partner = ", str(my_token))
|
||||
#print(" ### token partner = ", str(my_token))
|
||||
|
||||
|
||||
"""
|
||||
|
@ -1252,7 +1255,7 @@ def partner_login(diction):
|
|||
"""
|
||||
return_data['user_access_right'] = []
|
||||
qry = {'valide':'1', 'locked':'0','partner_owner_recid':str(partner_recid),'user_id':str(ressource_humaine_id)}
|
||||
print(" #### qry = ", qry)
|
||||
#print(" #### qry = ", qry)
|
||||
|
||||
for retval in MYSY_GV.dbname['user_access_right'].find(qry):
|
||||
local_access_right = {}
|
||||
|
@ -1270,7 +1273,7 @@ def partner_login(diction):
|
|||
|
||||
RetObject = []
|
||||
|
||||
print(" #### partner_login : return_data = ", return_data)
|
||||
#print(" #### partner_login : return_data = ", return_data)
|
||||
RetObject.append(JSONEncoder().encode(return_data))
|
||||
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ from math import isnan
|
|||
import GlobalVariable as MYSY_GV
|
||||
import ela_index_bdd_classes as eibdd
|
||||
import email_mgt as email
|
||||
|
||||
import email_inscription_mgt as email_inscription_mgt
|
||||
"""
|
||||
Cette fonction crée le compte employé administrateur.
|
||||
Ceci est fait à l'activation du compte, donc à ce moment il n'y pas de token de connexion.
|
||||
|
@ -44,7 +44,8 @@ def Add_Partner_Admin_Ressource_Humaine_No_Toke(diction):
|
|||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['partner_recid', "nom", "email", "comment", 'is_partner_admin_account', 'account_partner_id']
|
||||
field_list = ['partner_recid', "nom", "email", "comment", 'is_partner_admin_account', 'account_partner_id',
|
||||
'is_partner_admin_account']
|
||||
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
|
@ -85,7 +86,12 @@ def Add_Partner_Admin_Ressource_Humaine_No_Toke(diction):
|
|||
nom = diction['nom']
|
||||
data['nom'] = diction['nom']
|
||||
|
||||
data['is_partner_admin_account'] = "1"
|
||||
is_partner_admin_account = "0"
|
||||
if ("is_partner_admin_account" in diction.keys()):
|
||||
if (diction['is_partner_admin_account'] and str(diction['is_partner_admin_account']) in ['0', '1']):
|
||||
is_partner_admin_account = diction['is_partner_admin_account']
|
||||
data['is_partner_admin_account'] = is_partner_admin_account
|
||||
|
||||
|
||||
data['ismanager'] = "0"
|
||||
|
||||
|
@ -133,10 +139,8 @@ def Add_Partner_Admin_Ressource_Humaine_No_Toke(diction):
|
|||
Un fois le compte rh créer, on met à jour la collection partner_account, champ : 'ressource_humaine_id' avec le bon is
|
||||
"""
|
||||
MYSY_GV.dbname['partnair_account'].update_one({'recid': str(diction['partner_recid'])},
|
||||
{'$set': {'ressource_humaine_id': str(inserted_id)}})
|
||||
|
||||
|
||||
|
||||
{'$set': {'ressource_humaine_id': str(inserted_id),
|
||||
'is_partner_admin_account':is_partner_admin_account}})
|
||||
|
||||
|
||||
"""
|
||||
|
@ -167,7 +171,7 @@ def Add_Partner_Admin_Ressource_Humaine_No_Toke(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 créer la compte adminstrateur du partenaire (2) "
|
||||
return False, " Impossible de créer la compte administrateur du partenaire (2) "
|
||||
|
||||
|
||||
def Add_Ressource_Humaine(diction):
|
||||
|
@ -2797,7 +2801,7 @@ def Get_Given_Affectation_Ressource_Humaine_Poste(diction):
|
|||
'_id': ObjectId(str(diction['affectation_id'])),
|
||||
'valide': '1', 'locked': '0'}
|
||||
|
||||
print(" ### qry_affectation = ", qry_affectation)
|
||||
#print(" ### qry_affectation = ", qry_affectation)
|
||||
|
||||
RetObject = []
|
||||
val_tmp = 1
|
||||
|
@ -3021,6 +3025,7 @@ def Add_Update_Employee_Login_Pass(diction):
|
|||
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['is_partner_admin_account'] = '0'
|
||||
|
||||
|
||||
mydata['active'] = '1'
|
||||
|
@ -3081,24 +3086,45 @@ def Add_Update_Employee_Login_Pass(diction):
|
|||
"""
|
||||
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'])},
|
||||
employee = 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())}})
|
||||
|
||||
employee_data = MYSY_GV.dbname['ressource_humaine'].find_one({'_id':ObjectId(str(ressource_humaine_id))})
|
||||
|
||||
|
||||
if( count_existe_with_correct_ressource_humaine_id is True):
|
||||
# Mise à jour d'un compte existant,
|
||||
print(" ### Envoyer le mail de MISE A JOUR ")
|
||||
|
||||
#print(" #### le compte : ", result)
|
||||
data_for_mail = {}
|
||||
if( "nom" in employee_data.keys()):
|
||||
data_for_mail['nom'] = employee_data['nom']
|
||||
else:
|
||||
# Creation d'un compte utilisateur
|
||||
print(" ### Envoyer le mail de CREATION COMPTE UTILISATEUR ")
|
||||
data_for_mail['nom'] = ""
|
||||
|
||||
print(" #### le compte : ", result)
|
||||
if ("prenom" in employee_data.keys()):
|
||||
data_for_mail['prenom'] = employee_data['prenom']
|
||||
else:
|
||||
data_for_mail['prenom'] = ""
|
||||
|
||||
if ("email" in employee_data.keys()):
|
||||
data_for_mail['email'] = employee_data['email']
|
||||
else:
|
||||
data_for_mail['email'] = ""
|
||||
|
||||
return True, " Les accès ont été crée. Le login et le mot de passe envoyé à xxxx"
|
||||
data_for_mail['partner_owner_recid'] = employee_data['partner_recid']
|
||||
|
||||
data_for_mail['mysy_url'] = str(MYSY_GV.CLIENT_URL_BASE)
|
||||
data_for_mail['login'] = result['email']
|
||||
data_for_mail['pwd'] = result['pwd']
|
||||
if( str(result['contact_mail']) != "" ):
|
||||
data_for_mail['email_bcc'] = str(result['email'])+","+str(result['contact_mail'])
|
||||
else:
|
||||
data_for_mail['email_bcc'] = str(result['email'])
|
||||
|
||||
#print(" #### data_for_mail = ", data_for_mail)
|
||||
|
||||
email_inscription_mgt.Employee_Credential_Sending_mail(data_for_mail)
|
||||
|
||||
return True, " Les accès ont été créées. Les emails de notification envoyés"
|
||||
|
||||
except Exception as e:
|
||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||
|
|
Loading…
Reference in New Issue