22/10/2023 - 22h
parent
beb3d87aad
commit
5680b69aa2
|
@ -1,11 +1,11 @@
|
|||
<?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="22/10/2023 - 12h">
|
||||
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="22/10/2023 - 18h00">
|
||||
<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$/GlobalVariable.py" beforeDir="false" afterPath="$PROJECT_DIR$/GlobalVariable.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/base_specific_fields.py" beforeDir="false" afterPath="$PROJECT_DIR$/base_specific_fields.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/ressources_humaines.py" beforeDir="false" afterPath="$PROJECT_DIR$/ressources_humaines.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
|
@ -75,13 +75,6 @@
|
|||
<option name="presentableId" value="Default" />
|
||||
<updated>1680804787304</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00085" summary="27/08/23 - 13h">
|
||||
<created>1693136101567</created>
|
||||
<option name="number" value="00085" />
|
||||
<option name="presentableId" value="LOCAL-00085" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1693136101569</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00086" summary="27/08/23 - 22h">
|
||||
<created>1693168933560</created>
|
||||
<option name="number" value="00086" />
|
||||
|
@ -418,7 +411,14 @@
|
|||
<option name="project" value="LOCAL" />
|
||||
<updated>1697981083215</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="134" />
|
||||
<task id="LOCAL-00134" summary="22/10/2023 - 18h00">
|
||||
<created>1697992615131</created>
|
||||
<option name="number" value="00134" />
|
||||
<option name="presentableId" value="LOCAL-00134" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1697992615134</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="135" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="Vcs.Log.Tabs.Properties">
|
||||
|
@ -433,7 +433,6 @@
|
|||
</option>
|
||||
</component>
|
||||
<component name="VcsManagerConfiguration">
|
||||
<MESSAGE value="15/09/2023 - 18h" />
|
||||
<MESSAGE value="22/09/2023 - 12h53" />
|
||||
<MESSAGE value="22/09/2023 - 18h53" />
|
||||
<MESSAGE value="25/09/2023 - 12h40" />
|
||||
|
@ -458,6 +457,7 @@
|
|||
<MESSAGE value="17/10/2023 - 22h45" />
|
||||
<MESSAGE value="zzz" />
|
||||
<MESSAGE value="22/10/2023 - 12h" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="22/10/2023 - 12h" />
|
||||
<MESSAGE value="22/10/2023 - 18h00" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="22/10/2023 - 18h00" />
|
||||
</component>
|
||||
</project>
|
|
@ -511,4 +511,12 @@ PARTNER_QUOTATION_STATUS = ['-1', '0', '1', '2']
|
|||
"""
|
||||
Pour mettre en place un système de configuration global, on va definir les valeur acceptée
|
||||
"""
|
||||
PARTNER_BASE_CONFIG_NAME = ['tva', 'smtp_server', 'smtp_user', 'smtp_user_pwd', 'smtp_count_from_name' ]
|
||||
PARTNER_BASE_CONFIG_NAME = ['tva', 'smtp_server', 'smtp_user', 'smtp_user_pwd', 'smtp_count_from_name' ]
|
||||
|
||||
|
||||
"""
|
||||
Pour la personnalisation des champ, seuls certains objet metier / collection
|
||||
sont autorisés
|
||||
"""
|
||||
PERSONALISATION_AUTORIZED_COLLECTION = ['ressource_humaine', 'ressource_materielle', 'partner_client',
|
||||
'myclass', 'session_formation', 'inscription']
|
|
@ -39,33 +39,333 @@ from email import encoders
|
|||
"""
|
||||
Ajout d'un champs spécifique"""
|
||||
|
||||
def add_specific_field(diction):
|
||||
def Add_specific_field(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
field_list = ['related_collection', 'field_type', 'is_mandatory', 'field_label', 'field_name',
|
||||
'is_displayed','field_value', 'token']
|
||||
|
||||
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, " Les informations fournies sont incorrectes",
|
||||
|
||||
"""
|
||||
Verification des champs obligatoires
|
||||
"""
|
||||
field_list_obligatoire = ['related_collection', 'field_type', 'is_mandatory', 'field_label', 'field_name',
|
||||
'is_displayed','field_value', 'token']
|
||||
|
||||
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, False
|
||||
|
||||
"""
|
||||
Recuperation des données fournies en entrée
|
||||
"""
|
||||
data = {}
|
||||
data['partner_owner_recid'] = str(my_partner['recid'])
|
||||
data['valide'] = str(my_partner['recid'])
|
||||
data['locked'] = str(my_partner['recid'])
|
||||
data['date_update'] = str(datetime.now())
|
||||
data['field_value'] = ""
|
||||
|
||||
|
||||
return True, " Le champ a été correctement ajouté "
|
||||
related_collection = ""
|
||||
if ("related_collection" in diction.keys()):
|
||||
if diction['related_collection']:
|
||||
related_collection = diction['related_collection']
|
||||
if( str(related_collection) not in MYSY_GV.PERSONALISATION_AUTORIZED_COLLECTION ):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " - La valeur '" + str(related_collection) + "' n'est pas autorisée pour la personnalisation ")
|
||||
return False, " La valeur '" + str(related_collection) + "' n'est pas autorisée pour la personnalisation",
|
||||
|
||||
data['related_collection'] = related_collection
|
||||
|
||||
field_type = ""
|
||||
if ("field_type" in diction.keys()):
|
||||
if diction['field_type']:
|
||||
field_type = diction['field_type']
|
||||
|
||||
if (str(field_type) not in ['float', 'string']):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " - La valeur '" + str(
|
||||
field_type) + "' n'est pas autorisée pour la personnalisation ")
|
||||
return False, " La valeur '" + str(field_type) + "' n'est pas autorisée pour la personnalisation",
|
||||
|
||||
data['field_type'] = field_type
|
||||
|
||||
is_mandatory = ""
|
||||
if ("is_mandatory" in diction.keys()):
|
||||
if diction['is_mandatory']:
|
||||
is_mandatory = diction['is_mandatory']
|
||||
|
||||
if (str(is_mandatory) not in ['0', '1']):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " - La valeur '" + str(
|
||||
is_mandatory) + "' n'est pas autorisée pour la personnalisation ")
|
||||
return False, " La valeur '" + str(is_mandatory) + "' n'est pas autorisée pour la personnalisation",
|
||||
data['is_mandatory'] = is_mandatory
|
||||
|
||||
field_label = ""
|
||||
if ("field_label" in diction.keys()):
|
||||
if diction['field_label']:
|
||||
field_label = diction['field_label']
|
||||
|
||||
if (len(str(field_label)) > 50 ):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " - La valeur '" + str(
|
||||
field_label) + "' n'est pas autorisée pour la personnalisation. Il fait plus de 50 caractères ")
|
||||
return False, " La valeur '" + str(field_label) + "' n'est pas autorisée pour la personnalisation. Il fait plus de 50 caractères",
|
||||
|
||||
data['field_label'] = field_label
|
||||
|
||||
field_name = ""
|
||||
if ("field_name" in diction.keys()):
|
||||
if diction['field_name']:
|
||||
field_name = diction['field_name']
|
||||
|
||||
if (str(field_name).startswith("my_") is False):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " - La valeur '" + str(
|
||||
field_name) + "' n'est pas autorisée pour la personnalisation ")
|
||||
return False, " La valeur '" + str(field_name) + "' n'est pas autorisée pour la personnalisation",
|
||||
|
||||
if (len(str(field_name)) > 50):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " - La valeur '" + str(
|
||||
field_name) + "' n'est pas autorisée pour la personnalisation. Il fait plus de 50 caractères ")
|
||||
return False, " La valeur '" + str(
|
||||
field_name) + "' n'est pas autorisée pour la personnalisation. Il fait plus de 50 caractères",
|
||||
|
||||
data['field_name'] = field_name
|
||||
|
||||
|
||||
is_displayed = ""
|
||||
if ("is_displayed" in diction.keys()):
|
||||
if diction['is_displayed']:
|
||||
is_displayed = diction['is_displayed']
|
||||
|
||||
if (str(is_displayed) not in ['0', '1']):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " - La valeur '" + str(
|
||||
is_displayed) + "' n'est pas autorisée pour la personnalisation ")
|
||||
return False, " La valeur '" + str(is_displayed) + "' n'est pas autorisée pour la personnalisation",
|
||||
|
||||
data['is_displayed'] = is_displayed
|
||||
|
||||
|
||||
# Verification que le champ n'existe pas
|
||||
# la clé est le nom
|
||||
is_personalisez_field_count = MYSY_GV.dbname['base_specific_fields'].count_documents({'related_collection':str(diction['related_collection']),
|
||||
'partner_owner_recid':str(my_partner['recid']),
|
||||
'field_name':str(diction['field_name']),
|
||||
'valide':'1',
|
||||
})
|
||||
|
||||
if( is_personalisez_field_count > 0):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " - Cette personnalisation existe déjà ")
|
||||
return False, "Cette personnalisation existe déjà ",
|
||||
|
||||
inserted_id = ""
|
||||
inserted_id = MYSY_GV.dbname['base_specific_fields'].insert_one(data).inserted_id
|
||||
if (not inserted_id):
|
||||
mycommon.myprint(
|
||||
" Impossible de créer le champ personnalisé ")
|
||||
return False, " Impossible de créer le champ personnalisé "
|
||||
|
||||
|
||||
return True, " Le champ personnalisé a été correctement ajouté "
|
||||
|
||||
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 le nouveau champ "
|
||||
return False, " Impossible d'ajouter le nouveau champ personnalisé"
|
||||
|
||||
|
||||
"""
|
||||
Modification d'un champ spécifique
|
||||
"""
|
||||
def update_specific_field(diction):
|
||||
def Update_specific_field(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
field_list = ['related_collection', 'field_type', 'is_mandatory', 'field_label', 'field_name',
|
||||
'is_displayed', 'field_value', '_id', 'token']
|
||||
|
||||
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, " Les informations fournies sont incorrectes",
|
||||
|
||||
"""
|
||||
Verification des champs obligatoires
|
||||
"""
|
||||
field_list_obligatoire = ['_id', 'token']
|
||||
|
||||
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, False
|
||||
|
||||
"""
|
||||
Recuperation des données fournies en entrée
|
||||
"""
|
||||
data = {}
|
||||
data['partner_owner_recid'] = str(my_partner['recid'])
|
||||
data['valide'] = str(my_partner['recid'])
|
||||
data['locked'] = str(my_partner['recid'])
|
||||
data['date_update'] = str(datetime.now())
|
||||
data['field_value'] = ""
|
||||
|
||||
related_collection = ""
|
||||
if ("related_collection" in diction.keys()):
|
||||
related_collection = diction['related_collection']
|
||||
if (str(related_collection) not in MYSY_GV.PERSONALISATION_AUTORIZED_COLLECTION):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " - La valeur '" + str(
|
||||
related_collection) + "' n'est pas autorisée pour la personnalisation ")
|
||||
return False, " La valeur '" + str(related_collection) + "' n'est pas autorisée pour la personnalisation",
|
||||
|
||||
data['related_collection'] = related_collection
|
||||
|
||||
field_type = ""
|
||||
if ("field_type" in diction.keys()):
|
||||
field_type = diction['field_type']
|
||||
|
||||
if (str(field_type) not in ['float', 'string']):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " - La valeur '" + str(
|
||||
field_type) + "' n'est pas autorisée pour la personnalisation ")
|
||||
return False, " La valeur '" + str(field_type) + "' n'est pas autorisée pour la personnalisation",
|
||||
|
||||
data['field_type'] = field_type
|
||||
|
||||
is_mandatory = ""
|
||||
if ("is_mandatory" in diction.keys()):
|
||||
is_mandatory = diction['is_mandatory']
|
||||
|
||||
if (str(is_mandatory) not in ['0', '1']):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " - La valeur '" + str(
|
||||
is_mandatory) + "' n'est pas autorisée pour la personnalisation ")
|
||||
return False, " La valeur '" + str(is_mandatory) + "' n'est pas autorisée pour la personnalisation",
|
||||
data['is_mandatory'] = is_mandatory
|
||||
|
||||
field_label = ""
|
||||
if ("field_label" in diction.keys()):
|
||||
field_label = diction['field_label']
|
||||
|
||||
if (len(str(field_label)) > 50):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " - La valeur '" + str(
|
||||
field_label) + "' n'est pas autorisée pour la personnalisation. Il fait plus de 50 caractères ")
|
||||
return False, " La valeur '" + str(
|
||||
field_label) + "' n'est pas autorisée pour la personnalisation. Il fait plus de 50 caractères",
|
||||
|
||||
data['field_label'] = field_label
|
||||
|
||||
field_name = ""
|
||||
if ("field_name" in diction.keys()):
|
||||
field_name = diction['field_name']
|
||||
|
||||
if (str(field_name).startswith("my_") is False):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " - La valeur '" + str(
|
||||
field_name) + "' n'est pas autorisée pour la personnalisation ")
|
||||
return False, " La valeur '" + str(field_name) + "' n'est pas autorisée pour la personnalisation",
|
||||
|
||||
if (len(str(field_name)) > 50):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " - La valeur '" + str(
|
||||
field_name) + "' n'est pas autorisée pour la personnalisation. Il fait plus de 50 caractères ")
|
||||
return False, " La valeur '" + str(
|
||||
field_name) + "' n'est pas autorisée pour la personnalisation. Il fait plus de 50 caractères",
|
||||
|
||||
data['field_name'] = field_name
|
||||
|
||||
is_displayed = ""
|
||||
if ("is_displayed" in diction.keys()):
|
||||
is_displayed = diction['is_displayed']
|
||||
|
||||
if (str(is_displayed) not in ['0', '1']):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " - La valeur '" + str(
|
||||
is_displayed) + "' n'est pas autorisée pour la personnalisation ")
|
||||
return False, " La valeur '" + str(is_displayed) + "' n'est pas autorisée pour la personnalisation",
|
||||
|
||||
data['is_displayed'] = is_displayed
|
||||
|
||||
# Verification que le champ n'existe pas
|
||||
# la clé est le nom
|
||||
is_personalisez_field_count = MYSY_GV.dbname['base_specific_fields'].count_documents(
|
||||
{'_id': ObjectId(str(diction['_id'])),
|
||||
'valide': '1',
|
||||
})
|
||||
|
||||
if (is_personalisez_field_count <= 0):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " - Cette personnalisation n'existe pas ")
|
||||
return False, "Cette personnalisation n'existe pas ",
|
||||
|
||||
ret_val2 = MYSY_GV.dbname['base_specific_fields'].find_one_and_update(
|
||||
{'_id': ObjectId(str(diction['_id'])),
|
||||
'valide': '1',},
|
||||
{"$set": data},
|
||||
return_document=ReturnDocument.AFTER,
|
||||
upsert=False,
|
||||
)
|
||||
|
||||
|
||||
return True, " Le champ a été correctement modifié "
|
||||
inserted_id = ""
|
||||
inserted_id = MYSY_GV.dbname['base_specific_fields'].insert_one(data).inserted_id
|
||||
if (ret_val2 is None ):
|
||||
mycommon.myprint(
|
||||
" Impossible de mettre à jour le champ personnalisé ")
|
||||
return False, " Impossible de mettre à jour le champ personnalisé "
|
||||
|
||||
|
||||
return True, " Le champ personnalisé a été correctement mis à jour "
|
||||
|
||||
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 modifier le champ "
|
||||
return False, " Impossible de mettre à jour le champ personnalisé "
|
||||
|
||||
|
||||
"""
|
||||
|
@ -74,29 +374,157 @@ Recuperation d'un champ spécifique donné en partant de l'_id
|
|||
def get_given_specific_field(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
field_list = ['_id', 'token']
|
||||
|
||||
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, " Les informations fournies sont incorrectes",
|
||||
|
||||
"""
|
||||
Verification des champs obligatoires
|
||||
"""
|
||||
field_list_obligatoire = ['_id', 'token']
|
||||
|
||||
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, False
|
||||
|
||||
"""
|
||||
Clés de mise à jour
|
||||
"""
|
||||
data_cle = {}
|
||||
data_cle['partner_owner_recid'] = str(my_partner['recid'])
|
||||
data_cle['_id'] = ObjectId(str(diction['_id']))
|
||||
data_cle['valide'] = "1"
|
||||
data_cle['locked'] = "0"
|
||||
|
||||
|
||||
RetObject = []
|
||||
val_tmp = 1
|
||||
for retval in MYSY_GV.dbname['base_specific_fields'].find(data_cle):
|
||||
user = retval
|
||||
user['id'] = str(val_tmp)
|
||||
val_tmp = val_tmp + 1
|
||||
|
||||
RetObject.append(mycommon.JSONEncoder().encode(user))
|
||||
|
||||
# print(" ### RetObject = ", RetObject)
|
||||
return True, RetObject
|
||||
|
||||
|
||||
return True, " Le champ a été correctement modifié "
|
||||
|
||||
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 modifier le champ "
|
||||
return False, " Impossible de récuperer le champ personnalisé "
|
||||
|
||||
"""
|
||||
Suppression d'un champ spécifique
|
||||
Suppression d'un champ spécifique.
|
||||
Pour qu'un champ personnalisé soit supprimable, il faut qu'il existe aucun enregistrement avec une valeur pour ce champs.
|
||||
|
||||
la requete de controle est : { "mon_champs" : { $exists : true, $ne: "" } }, si existe alors PAS de suppression
|
||||
|
||||
"""
|
||||
def delete_given_specific_field(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
field_list = ['_id', 'token']
|
||||
|
||||
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, " Les informations fournies sont incorrectes",
|
||||
|
||||
"""
|
||||
Verification des champs obligatoires
|
||||
"""
|
||||
field_list_obligatoire = ['_id', 'token']
|
||||
|
||||
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, False
|
||||
|
||||
"""
|
||||
Clés de mise à jour
|
||||
"""
|
||||
data_cle = {}
|
||||
data_cle['partner_owner_recid'] = str(my_partner['recid'])
|
||||
data_cle['_id'] = ObjectId(str(diction['_id']))
|
||||
data_cle['valide'] = "1"
|
||||
data_cle['locked'] = "0"
|
||||
|
||||
"""
|
||||
Recuperation des données du champ à surprimer
|
||||
"""
|
||||
personnalized_field_data = MYSY_GV.dbname['base_specific_fields'].find_one({'_id':ObjectId(str(diction['_id'])),
|
||||
'valide':'1',
|
||||
'partner_owner_recid':str(my_partner['recid'])})
|
||||
|
||||
if( personnalized_field_data is None):
|
||||
mycommon.myprint(str(
|
||||
inspect.stack()[0][3]) + " L'identification du champ n'est pas valide ")
|
||||
return False, "L'identification du champ n'est pas valide ",
|
||||
|
||||
"""
|
||||
Verification qu'il n'existe aucun enregistrement avec une valeur pour ce champ
|
||||
"""
|
||||
local_qry = { str(personnalized_field_data['field_name']) : { '$exists' : True, '$ne': "" } }
|
||||
print(" #### delete_given_specific_field local_qry = ", local_qry)
|
||||
is_record_exist_count = MYSY_GV.dbname[str(personnalized_field_data['related_collection'])].count_documents(local_qry)
|
||||
|
||||
if( is_record_exist_count > 0 ):
|
||||
mycommon.myprint(str(
|
||||
inspect.stack()[0][3]) + " Le champs est déjà utilisé, impossible de le supprimer ")
|
||||
return False, "Le champs est déjà utilisé, impossible de le supprimer ",
|
||||
|
||||
|
||||
return True, " Le champ a été correctement modifié "
|
||||
MYSY_GV.dbname['base_specific_fields'].delete_one({'_id':ObjectId(str(diction['_id']))})
|
||||
|
||||
|
||||
return True, " Le champ personnalisé a été correctement supprimé "
|
||||
|
||||
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 supprimer le champ "
|
||||
return False, " Impossible de supprimer le champ personnalisé "
|
||||
|
||||
|
||||
|
||||
|
@ -107,13 +535,68 @@ Recuperation de liste des champs spécifiques d'un partenaire
|
|||
def get_list_specific_field_partner(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', 'object_name']
|
||||
|
||||
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'existe pas")
|
||||
return False, " Les informations fournies sont incorrectes",
|
||||
|
||||
"""
|
||||
Verification des champs obligatoires
|
||||
"""
|
||||
field_list_obligatoire = ['token', 'object_name']
|
||||
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
|
||||
|
||||
data_cle = {}
|
||||
data_cle['partner_owner_recid'] = str(my_partner['recid'])
|
||||
data_cle['is_displayed'] = "1"
|
||||
data_cle['valide'] = "1"
|
||||
data_cle['locked'] = "0"
|
||||
|
||||
RetObject = []
|
||||
val_tmp = 1
|
||||
|
||||
# print(" ### qtry = ", data_cle)
|
||||
|
||||
for retval in MYSY_GV.dbname['base_specific_fields'].find(data_cle):
|
||||
user = retval
|
||||
user['id'] = str(val_tmp)
|
||||
val_tmp = val_tmp + 1
|
||||
|
||||
RetObject.append(mycommon.JSONEncoder().encode(user))
|
||||
|
||||
return True, RetObject
|
||||
|
||||
return True, " Le champ a été correctement modifié "
|
||||
|
||||
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 modifier le champ "
|
||||
return False, " Impossible de récuperer la liste des champs personnalisés "
|
||||
|
||||
|
||||
"""
|
||||
|
|
73
main.py
73
main.py
|
@ -5110,7 +5110,7 @@ API de recuperation de la liste des fichiers attaché à
|
|||
def Get_object_owner_collection_Stored_Files():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Get_List_object_owner_collection_Stored_Files : payload la = ",payload)
|
||||
print(" ### Get_List_object_owner_collection_Stored_Files : payload = ",payload)
|
||||
status, retval = attached_file_mgt.Get_List_object_owner_collection_Stored_Files(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
@ -5123,7 +5123,7 @@ API de suppression d'un fichier stocké
|
|||
def Delete_Stored_Downloaded_File():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Delete_Stored_Downloaded_File : payload la = ",payload)
|
||||
print(" ### Delete_Stored_Downloaded_File : payload = ",payload)
|
||||
status, retval = attached_file_mgt.Delete_Stored_Downloaded_File(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
@ -5173,15 +5173,80 @@ def Get_Stored_Downloaded_File(token, file_name):
|
|||
return retval
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Recuperation de liste de champs spécifique d'un objet pou un partenaire
|
||||
API d'ajout d'un champ personnalisé
|
||||
"""
|
||||
@app.route('/myclass/api/Add_specific_field/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Add_specific_field():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Add_specific_field : payload = ",payload)
|
||||
status, retval = base_specific_fields.Add_specific_field(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
"""
|
||||
API de mise à jour d'un champ personnalisé
|
||||
"""
|
||||
@app.route('/myclass/api/Update_specific_field/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Update_specific_field():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Update_specific_field : payload = ",payload)
|
||||
status, retval = base_specific_fields.Update_specific_field(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
"""
|
||||
API de recuperation d'un champ personnalisé donné
|
||||
"""
|
||||
@app.route('/myclass/api/get_given_specific_field/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def get_given_specific_field():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### get_given_specific_field : payload = ",payload)
|
||||
status, retval = base_specific_fields.get_given_specific_field(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
"""
|
||||
API de suppression d'un champ personnalisé donnée si toutes les regles sont remplies
|
||||
"""
|
||||
@app.route('/myclass/api/delete_given_specific_field/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def delete_given_specific_field():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### delete_given_specific_field : payload = ",payload)
|
||||
status, retval = base_specific_fields.delete_given_specific_field(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
"""
|
||||
API de recuperation de liste des champs spécifique d'un partenaire
|
||||
"""
|
||||
@app.route('/myclass/api/get_list_specific_field_partner/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def get_list_specific_field_partner():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### get_list_specific_field_partner : payload = ",payload)
|
||||
status, retval = base_specific_fields.get_list_specific_field_partner(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
|
||||
"""
|
||||
API de Recuperation de liste de champs spécifique d'un objet pou un partenaire
|
||||
"""
|
||||
@app.route('/myclass/api/get_list_specific_field_partner_by_object/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def get_list_specific_field_partner_by_object():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### get_list_specific_field_partner_by_object : payload la = ",payload)
|
||||
print(" ### get_list_specific_field_partner_by_object : payload = ",payload)
|
||||
status, retval = base_specific_fields.get_list_specific_field_partner_by_object(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
|
Loading…
Reference in New Issue