30/07/23 - 17h

master
cherif 2023-07-30 17:37:38 +02:00
parent f220c189e6
commit 3796da55ab
8 changed files with 4423 additions and 82 deletions

View File

@ -1,12 +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="28/07/23 - 19h">
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="29/07/23 - 29h">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Activite.py" beforeDir="false" afterPath="$PROJECT_DIR$/Activite.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Contact.py" beforeDir="false" afterPath="$PROJECT_DIR$/Contact.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/GlobalVariable.py" beforeDir="false" afterPath="$PROJECT_DIR$/GlobalVariable.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$/Session_Formation.py" beforeDir="false" afterPath="$PROJECT_DIR$/Session_Formation.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/email_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/email_mgt.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/lms_chamilo/mysy_lms.py" beforeDir="false" afterPath="$PROJECT_DIR$/lms_chamilo/mysy_lms.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/class_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/class_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" />
@ -71,13 +73,6 @@
<option name="presentableId" value="Default" />
<updated>1680804787304</updated>
</task>
<task id="LOCAL-00006" summary="15/04/23 - 14h">
<created>1681566348906</created>
<option name="number" value="00006" />
<option name="presentableId" value="LOCAL-00006" />
<option name="project" value="LOCAL" />
<updated>1681566348906</updated>
</task>
<task id="LOCAL-00007" summary="15/04/23 - 22h">
<created>1681588140722</created>
<option name="number" value="00007" />
@ -414,7 +409,14 @@
<option name="project" value="LOCAL" />
<updated>1690566255686</updated>
</task>
<option name="localTasksCounter" value="55" />
<task id="LOCAL-00055" summary="29/07/23 - 29h">
<created>1690661811531</created>
<option name="number" value="00055" />
<option name="presentableId" value="LOCAL-00055" />
<option name="project" value="LOCAL" />
<updated>1690661811531</updated>
</task>
<option name="localTasksCounter" value="56" />
<servers />
</component>
<component name="Vcs.Log.Tabs.Properties">
@ -429,7 +431,6 @@
</option>
</component>
<component name="VcsManagerConfiguration">
<MESSAGE value="30/05/23 - 22h" />
<MESSAGE value="02/06/23 - 22h" />
<MESSAGE value="05/06/23 - 15h" />
<MESSAGE value="06/06/23 - 19h" />
@ -454,6 +455,7 @@
<MESSAGE value="26/07/23 - 23h" />
<MESSAGE value="27/07/23 - 23h" />
<MESSAGE value="28/07/23 - 19h" />
<option name="LAST_COMMIT_MESSAGE" value="28/07/23 - 19h" />
<MESSAGE value="29/07/23 - 29h" />
<option name="LAST_COMMIT_MESSAGE" value="29/07/23 - 29h" />
</component>
</project>

View File

@ -2,7 +2,7 @@
Ce fichier defini les comment les activités sont gérées
Par principe, une activié peut etre faite par plusieurs entités (client, partner, user, etc).
Donc à l'image des contact, on va gerer la notion de :
- relected_collection
- related_collection
- relected_recid
- type (email, call, meeting, cmd, devis, autre),
- Description
@ -45,7 +45,7 @@ def Add_activite(diction):
Verification des input acceptés
"""
field_list = ['token', "description", "detail", "deadline", "type",
"status", 'related_collection_recid', 'related_collection_recid', ]
"status", 'related_collection', 'related_collection_owner_email', ]
incom_keys = diction.keys()
for val in incom_keys:
@ -57,7 +57,7 @@ def Add_activite(diction):
"""
Verification des champs obligatoires
"""
field_list_obligatoire = ['token', "email", 'related_collection', 'related_collection_recid',]
field_list_obligatoire = ['token', 'related_collection', 'related_collection_owner_email',]
for val in field_list_obligatoire:
if val not in diction:
@ -106,12 +106,25 @@ def Add_activite(diction):
description = diction['description']
data['description'] = diction['description']
if(len(str(description)) > 255 ):
mycommon.myprint(
str(inspect.stack()[0][3]) + " - Le champ 'description' doit faire moins de 255 caractères ")
return False, " - Le champ 'description' doit faire moins de 255 caractères "
detail = ""
if ("detail" in diction.keys()):
if diction['detail']:
detail = diction['detail']
data['detail'] = diction['detail']
if (len(str(detail)) > 500):
mycommon.myprint(
str(inspect.stack()[0][3]) + " - Le champ 'detail' doit faire moins de 500 caractères ")
return False, " - Le champ 'detail' doit faire moins de 500 caractères "
deadline = ""
if ("deadline" in diction.keys()):
if diction['deadline']:
@ -126,12 +139,15 @@ def Add_activite(diction):
return False, " - La date deadline n'est pas au format jj/mm/aaaa "
adr_adresse = ""
if ("adr_adresse" in diction.keys()):
if diction['adr_adresse']:
adr_adresse = diction['adr_adresse']
data['adr_adresse'] = diction['adr_adresse']
status = ""
if ("status" in diction.keys()):
status = diction['status']
data['status'] = diction['status']
if (status not in MYSY_GV.ACTIVITE_STATUS):
mycommon.myprint(
"- Le statut " + str(status) + " n'est pas autorisé ")
return False, "- Le statut " + str(status) + " n'est pas autorisé "
type = ""
if ("type" in diction.keys()):
@ -153,13 +169,23 @@ def Add_activite(diction):
"- La collection " + str(related_collection) + " n'accepte pas d' activite ")
return False, "- La collection " + str(related_collection) + " n'accepte pas d' activite "
if ("related_collection_owner_email" in diction.keys()):
related_collection_owner_email = str(diction['related_collection_owner_email'])
"""
Recuperation du recid associé au related_collection_owner_email dans la collection : related_collection
"""
# print(" #### on cherche le recid du mail "+ str(related_collection_owner_email)+" dans la collection "+str(diction['related_collection'])+" ." )
local_tmp_val = MYSY_GV.dbname[str(diction['related_collection'])].find_one(
{'email': related_collection_owner_email})
if (local_tmp_val is None or "recid" not in local_tmp_val.keys()):
mycommon.myprint(
str(inspect.stack()[0][3]) + " - impossible de recuperer les données de " + str(
related_collection_owner_email) + " dans la collection " + str(diction['related_collection']))
return False, str(inspect.stack()[0][3]) + " - impossible de recuperer les données de " + str(
related_collection_owner_email) + " dans la collection " + str(
diction['related_collection']) + " . "
related_collection_recid = ""
if ("related_collection_recid" in diction.keys()):
if diction['related_collection_recid']:
related_collection_recid = diction['related_collection_recid']
data['related_collection_recid'] = diction['related_collection_recid']
data['related_collection_recid'] = str(local_tmp_val['recid'])
data['valide'] = '1'
data['locked'] = '0'
@ -177,7 +203,7 @@ def Add_activite(diction):
return False, " Impossible de créer l'activité "
return True, " L'activité a été correctement créé"
return True, " L'activité a été correctement créée"
except Exception as e:
exc_type, exc_obj, exc_tb = sys.exc_info()
@ -200,7 +226,7 @@ def Update_activite(diction):
Verification des input acceptés
"""
field_list = ['token', "description", "detail", "deadline", "type",
"status",'related_collection_recid', 'related_collection_recid', ]
"status",'activite_recid' ]
incom_keys = diction.keys()
@ -213,7 +239,7 @@ def Update_activite(diction):
"""
Verification des champs obligatoires
"""
field_list_obligatoire = ['token', 'related_collection', 'related_collection_recid' ]
field_list_obligatoire = ['token', 'activite_recid' ]
for val in field_list_obligatoire:
if val not in diction:
@ -253,9 +279,8 @@ def Update_activite(diction):
nom, ou la meme adresse email
"""
qry_update = {'valide': '1', 'partner_recid': str(my_partner['recid']),
'related_collection':str(diction['related_collection']),
'related_collection_recid':str(diction['related_collection_recid'])}
qry_update = {'valide': '1', 'locked':'0', 'partner_recid': str(my_partner['recid']),
'recid':str(diction['activite_recid']),}
@ -285,15 +310,46 @@ def Update_activite(diction):
description = diction['description']
data_update['description'] = diction['description']
if (len(str(description)) > 255):
mycommon.myprint(
str(inspect.stack()[0][3]) + " - Le champ 'description' doit faire moins de 255 caractères ")
return False, " - Le champ 'description' doit faire moins de 255 caractères "
detail = ""
if ("detail" in diction.keys()):
detail = diction['detail']
data_update['detail'] = diction['detail']
if (len(str(detail)) > 500):
mycommon.myprint(
str(inspect.stack()[0][3]) + " - Le champ 'detail' doit faire moins de 500 caractères ")
return False, " - Le champ 'detail' doit faire moins de 500 caractères "
deadline = ""
if ("deadline" in diction.keys()):
if diction['deadline']:
deadline = diction['deadline']
data_update['deadline'] = diction['deadline']
local_status = mycommon.CheckisDate(deadline)
if (local_status is False):
mycommon.myprint(
str(inspect.stack()[0][3]) + " - La date deadline n'est pas au format jj/mm/aaaa ")
return False, " - La date deadline n'est pas au format jj/mm/aaaa "
status = ""
if ("status" in diction.keys()):
status = diction['status']
data_update['status'] = diction['status']
if (status not in MYSY_GV.ACTIVITE_STATUS):
mycommon.myprint(
"- Le statut " + str(status) + " n'est pas autorisé ")
return False, "- Le statut " + str(status) + " n'est pas autorisé "
type = ""
if ("type" in diction.keys()):
@ -304,24 +360,6 @@ def Update_activite(diction):
"- Le type d' activite " + str(type) + " n'est pas autorisé")
return False, "- Le type d' activite " + str(type) + " n'est pas autorisé"
related_collection = ""
if ("related_collection" in diction.keys()):
related_collection = diction['related_collection']
data_update['related_collection'] = diction['related_collection']
if (related_collection not in MYSY_GV.ACTIVITE_COLLECTION):
mycommon.myprint(
"- La collection " + str(related_collection) + " n'accepte pas d' activite ")
return False, "- La collection " + str(related_collection) + " n'accepte pas d' activite "
status = ""
if ("status" in diction.keys()):
status = diction['status']
data_update['status'] = diction['status']
if (type not in MYSY_GV.ACTIVITE_STATUS):
mycommon.myprint(
"- Le statut "+str(status)+" n'est pas autorisé ")
return False, "- Le statut "+str(status)+" n'est pas autorisé "
data_update['valide'] = '1'
data_update['locked'] = '0'
@ -332,8 +370,7 @@ def Update_activite(diction):
"""
data_cle = {}
data_cle['partner_recid'] = str(my_partner['recid'])
data_cle['related_collection'] = str(diction['related_collection'])
data_cle['related_collection_recid'] = str(diction['related_collection_recid'])
data_cle['recid'] = str(diction['activite_recid'])
data_cle['valide'] = "1"
data_cle['locked'] = "0"
@ -359,7 +396,7 @@ def Update_activite(diction):
"""
Recuperation de la liste des activité d'une entité en se basant sur
- relected_collection
- related_collection
- token (partner_recid)
- related_collection_recid (s'il est fourni)
"""
@ -370,7 +407,7 @@ def Get_List_Entity_Activite(diction):
"""
Verification des input acceptés
"""
field_list = ['token', 'relected_collection', 'related_collection_recid']
field_list = ['token', 'related_collection', 'related_collection_owner_email']
incom_keys = diction.keys()
for val in incom_keys:
@ -382,7 +419,7 @@ def Get_List_Entity_Activite(diction):
"""
Verification des champs obligatoires
"""
field_list_obligatoire = ['token', 'relected_collection']
field_list_obligatoire = ['token', 'related_collection']
for val in field_list_obligatoire:
if val not in diction:
mycommon.myprint(
@ -415,11 +452,26 @@ def Get_List_Entity_Activite(diction):
"""
data_cle = {}
data_cle['partner_recid'] = str(my_partner['recid'])
data_cle['relected_collection'] = str(diction['relected_collection'])
data_cle['related_collection'] = str(diction['related_collection'])
if ("related_collection_recid" in diction.keys()):
data_cle['related_collection_recid'] = str(diction['related_collection_recid'])
if ("related_collection_owner_email" in diction.keys()):
related_collection_owner_email = str(diction['related_collection_owner_email'])
"""
Recuperation du recid associé au related_collection_owner_email dans la collection : related_collection
"""
local_tmp_val = MYSY_GV.dbname[str(diction['related_collection'])].find_one(
{'email': related_collection_owner_email})
if (local_tmp_val is None or "recid" not in local_tmp_val.keys()):
mycommon.myprint(
str(inspect.stack()[0][3]) + " - impossible de recuperer les données de " + str(
related_collection_owner_email) + " dans la collection " + str(diction['related_collection']))
return False, str(inspect.stack()[0][3]) + " - impossible de recuperer les données de " + str(
related_collection_owner_email) + " dans la collection " + str(
diction['related_collection']) + " . "
data_cle['related_collection_recid'] = str(local_tmp_val['recid'])
data_cle['locked'] = "0"
@ -496,7 +548,7 @@ def Get_Given_Activite(diction):
"""
data_cle = {}
data_cle['partner_recid'] = str(my_partner['recid'])
data_cle['activite_recid'] = str(diction['activite_recid'])
data_cle['recid'] = str(diction['activite_recid'])
data_cle['valide'] = "1"
data_cle['locked'] = "0"

View File

@ -54,7 +54,7 @@ def Add_Contact(diction):
"telephone", "website", "comment",'adr_adresse', 'adr_code_postal',
'adr_ville', 'adr_pays', 'type', 'telephone_mobile', 'linkedin',
'facebook', 'twitter', 'related_collection', 'related_collection_owner_email',
'prenom']
'prenom', 'fonction', 'civilite']
incom_keys = diction.keys()
for val in incom_keys:
@ -148,6 +148,20 @@ def Add_Contact(diction):
prenom = diction['prenom']
data['prenom'] = diction['prenom']
fonction = ""
if ("fonction" in diction.keys()):
if diction['fonction']:
fonction = diction['fonction']
data['fonction'] = diction['fonction']
civilite = ""
if ("civilite" in diction.keys()):
if diction['civilite']:
civilite = diction['civilite']
data['civilite'] = diction['civilite']
adr_adresse = ""
if ("adr_adresse" in diction.keys()):
if diction['adr_adresse']:
@ -309,10 +323,10 @@ def Update_Contact(diction):
"""
Verification des input acceptés
"""
field_list = ['token', "raison_sociale", "nom", "siret", "tva", "email",
field_list = ['token', "raison_sociale", "nom", "prenom", "siret", "tva", "email",
"telephone", "website", "comment",'adr_adresse', 'adr_code_postal',
'adr_ville', 'adr_pays', 'type', 'telephone_mobile', 'linkedin',
'facebook', 'twitter', 'related_collection_recid', 'related_collection_recid', ]
'facebook', 'twitter', 'contact_recid', 'prenom', 'fonction', 'civilite']
incom_keys = diction.keys()
@ -325,7 +339,7 @@ def Update_Contact(diction):
"""
Verification des champs obligatoires
"""
field_list_obligatoire = ['token', "email", 'related_collection', ]
field_list_obligatoire = ['token', "email", 'contact_recid', ]
for val in field_list_obligatoire:
if val not in diction:
@ -366,8 +380,8 @@ def Update_Contact(diction):
"""
qry_update = {'email': str(diction['email']),
'valide': '1', 'partner_recid': str(my_partner['recid']),
'related_collection':str(diction['related_collection'])}
'valide': '1', 'locked':'0', 'partner_recid': str(my_partner['recid']),
'recid':str(diction['contact_recid'])}
@ -400,13 +414,38 @@ def Update_Contact(diction):
nom = ""
if ("nom" in diction.keys()):
nom = diction['nom']
# data_update['nom'] = diction['nom'] - on ne modifie pas le nom
data_update['nom'] = diction['nom']
fonction = ""
if ("fonction" in diction.keys()):
fonction = diction['fonction']
data_update['fonction'] = diction['fonction']
civilite = ""
if ("civilite" in diction.keys()):
civilite = diction['civilite']
data_update['civilite'] = diction['civilite']
prenom = ""
if ("prenom" in diction.keys()):
prenom = diction['prenom']
data_update['prenom'] = diction['prenom']
siret = ""
if ("siret" in diction.keys()):
siret = diction['siret']
data_update['siret'] = diction['siret']
fonction = ""
if ("fonction" in diction.keys()):
fonction = diction['fonction']
data_update['fonction'] = diction['fonction']
civilite = ""
if ("civilite" in diction.keys()):
civilite = diction['civilite']
data_update['civilite'] = diction['civilite']
adr_adresse = ""
if ("adr_adresse" in diction.keys()):
adr_adresse = diction['adr_adresse']
@ -494,12 +533,10 @@ def Update_Contact(diction):
"""
Clés de mise à jour
"""
data_cle = {}
data_cle['partner_recid'] = str(my_partner['recid'])
data_cle['email'] = str(diction['email'])
data_cle['nom'] = str(diction['nom'])
data_cle['valide'] = "1"
data_cle['locked'] = "0"
data_cle = {'email': str(diction['email']),
'valide': '1', 'locked': '0', 'partner_recid': str(my_partner['recid']),
'recid': str(diction['contact_recid'])}
inserted_id = ""
result = MYSY_GV.dbname['contact'].find_one_and_update(
@ -508,7 +545,7 @@ def Update_Contact(diction):
upsert=False,
return_document=ReturnDocument.AFTER
)
if ("_id" not in result.keys()):
if (result is None or "_id" not in result.keys()):
mycommon.myprint(
" Impossible de mettre à jour le contact : email = " + str(diction['email']))
return False, " Impossible de mettre à jour le client "
@ -588,9 +625,7 @@ def Get_List_Entity_Contact(diction):
"""
Recuperation du recid associé au related_collection_owner_email dans la collection : related_collection
"""
print(" #### on cherche le recid du mail "+ str(related_collection_owner_email)+" dans la collection "+str(diction['related_collection'])+" ." )
local_tmp_val = MYSY_GV.dbname[str(diction['related_collection'])].find_one({'email':related_collection_owner_email})
print(" #### local_tmp_val = ", local_tmp_val)
if (local_tmp_val is None or "recid" not in local_tmp_val.keys()):
mycommon.myprint(
str(inspect.stack()[0][3]) + " - impossible de recuperer les données de "+ str(related_collection_owner_email)+" dans la collection "+str(diction['related_collection']) )

View File

@ -441,5 +441,7 @@ fait : 1
annulé : -1
"""
ACTIVITE_COLLECTION = ['0', '-1', '1']
ACTIVITE_STATUS = ['0', '-1', '1']

File diff suppressed because one or more lines are too long

View File

@ -2261,8 +2261,6 @@ def get_partner_class(diction):
"""
Cette fonction recherche des formations avec une recherche large (like %value%)
"""
def find_partner_class_like(diction):
try:
'''

View File

@ -3386,7 +3386,7 @@ def Add_activite():
# On recupere le corps (payload) de la requete
payload = mycommon.strip_dictionary (request.form.to_dict())
print(" ### Add_activite : payload = ",payload)
localStatus, message = Activite.Add_Contact(payload)
localStatus, message = Activite.Add_activite(payload)
return jsonify(status=localStatus, message=message)
"""

View File

@ -3150,7 +3150,7 @@ def Clean_For_SQL(sentence):
try:
h = html.parser
sentence = h.unescape(sentence)
sentence = sentence.replace("'", "\'").replace('"', ' ').replace("", "\").replace("'", " ")
sentence = sentence.replace("'", "\\'").replace('"', ' ').replace("", "\")
return sentence