06/05/2024 - 22h30
parent
984fb39a07
commit
09d50b4b8d
|
@ -1,8 +1,16 @@
|
|||
<?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="05/05/2024 - 13h30">
|
||||
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="05/05/2024 - 17h30">
|
||||
<change afterPath="$PROJECT_DIR$/categorie_formation_mgt.py" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/domaine_formation_mgt.py" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/metier_formation_mgt.py" afterDir="false" />
|
||||
<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$/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$/paiement_condition.py" beforeDir="false" afterPath="$PROJECT_DIR$/paiement_condition.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" />
|
||||
|
@ -27,14 +35,14 @@
|
|||
<option name="hideEmptyMiddlePackages" value="true" />
|
||||
<option name="showLibraryContents" value="true" />
|
||||
</component>
|
||||
<component name="PropertiesComponent">{
|
||||
"keyToString": {
|
||||
"RunOnceActivity.OpenProjectViewOnStart": "true",
|
||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||
"last_opened_file_path": "C:/Users/billa/Documents/Projet_X/projet_w_siteweb/developpement/PrjX_back",
|
||||
"settings.editor.selected.configurable": "preferences.lookFeel"
|
||||
<component name="PropertiesComponent"><![CDATA[{
|
||||
"keyToString": {
|
||||
"RunOnceActivity.OpenProjectViewOnStart": "true",
|
||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||
"last_opened_file_path": "C:/Users/billa/Documents/myclass.com/Siteweb/Production/Ela_back/Back_Office",
|
||||
"settings.editor.selected.configurable": "preferences.lookFeel"
|
||||
}
|
||||
}</component>
|
||||
}]]></component>
|
||||
<component name="RecentsManager">
|
||||
<key name="CopyFile.RECENT_KEYS">
|
||||
<recent name="C:\Users\billa\Documents\myclass.com\Siteweb\Production\Ela_back\Back_Office" />
|
||||
|
@ -72,13 +80,6 @@
|
|||
<option name="presentableId" value="Default" />
|
||||
<updated>1680804787304</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00237" summary="ssdqs">
|
||||
<created>1709821854106</created>
|
||||
<option name="number" value="00237" />
|
||||
<option name="presentableId" value="LOCAL-00237" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1709821854108</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00238" summary="07/03/2024 - 22h30">
|
||||
<created>1709847739473</created>
|
||||
<option name="number" value="00238" />
|
||||
|
@ -415,7 +416,14 @@
|
|||
<option name="project" value="LOCAL" />
|
||||
<updated>1714909797953</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="286" />
|
||||
<task id="LOCAL-00286" summary="05/05/2024 - 17h30">
|
||||
<created>1714923761168</created>
|
||||
<option name="number" value="00286" />
|
||||
<option name="presentableId" value="LOCAL-00286" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1714923761168</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="287" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="Vcs.Log.Tabs.Properties">
|
||||
|
@ -457,7 +465,6 @@
|
|||
</option>
|
||||
</component>
|
||||
<component name="VcsManagerConfiguration">
|
||||
<MESSAGE value="06/04/2024 - 21h19" />
|
||||
<MESSAGE value="07/04/2024 - 13h19" />
|
||||
<MESSAGE value="07/04/2024 - 19h19" />
|
||||
<MESSAGE value="09/04/2024 - 15h19" />
|
||||
|
@ -482,6 +489,7 @@
|
|||
<MESSAGE value="vvvv" />
|
||||
<MESSAGE value="04/05/2024 - 20h30" />
|
||||
<MESSAGE value="05/05/2024 - 13h30" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="05/05/2024 - 13h30" />
|
||||
<MESSAGE value="05/05/2024 - 17h30" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="05/05/2024 - 17h30" />
|
||||
</component>
|
||||
</project>
|
4981
Log/log_file.log
4981
Log/log_file.log
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,465 @@
|
|||
"""
|
||||
Ce fichier permet de gerer les categories de formation
|
||||
|
||||
Une categorie est rattachées à un et un seul domaine
|
||||
et est defini par :
|
||||
- code categorie
|
||||
- nom categorie
|
||||
- description
|
||||
- domaine_id
|
||||
|
||||
la clé fonctionnelle est le code
|
||||
"""
|
||||
import bson
|
||||
import pymongo
|
||||
from pymongo import MongoClient
|
||||
import json
|
||||
from bson import ObjectId
|
||||
import re
|
||||
from datetime import datetime
|
||||
import prj_common as mycommon
|
||||
import secrets
|
||||
import inspect
|
||||
import sys, os
|
||||
import csv
|
||||
import pandas as pd
|
||||
from pymongo import ReturnDocument
|
||||
import GlobalVariable as MYSY_GV
|
||||
from math import isnan
|
||||
import GlobalVariable as MYSY_GV
|
||||
import ela_index_bdd_classes as eibdd
|
||||
import email_mgt as email
|
||||
import jinja2
|
||||
from flask import send_file
|
||||
from xhtml2pdf import pisa
|
||||
from email.message import EmailMessage
|
||||
from email.mime.text import MIMEText
|
||||
from email import encoders
|
||||
import smtplib
|
||||
from email.mime.multipart import MIMEMultipart
|
||||
from email.mime.text import MIMEText
|
||||
from email.mime.base import MIMEBase
|
||||
from email import encoders
|
||||
|
||||
|
||||
"""
|
||||
Ajout d'une categorie
|
||||
"""
|
||||
|
||||
def Add_Class_Categorie(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', 'code', 'nom', 'description', 'class_domaine_id']
|
||||
|
||||
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 = ['token', 'code', 'nom', 'class_domaine_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
|
||||
|
||||
|
||||
# Verifier que ce code n'existe pas déjà
|
||||
is_existe_class_categorie = MYSY_GV.dbname['class_categorie'].count_documents({'code':str(diction['code']),
|
||||
'valide':'1',
|
||||
'partner_owner_recid':str(my_partner['recid'])})
|
||||
|
||||
|
||||
if( is_existe_class_categorie > 0 ):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " Une catégorie avec le code '" + str(diction['code']) + "' existe déjà ")
|
||||
return False, " Une catégorie avec le code '" + str(diction['code']) + "' existe déjà "
|
||||
|
||||
|
||||
"""
|
||||
Verifier que le domaine_id exist et est valide
|
||||
"""
|
||||
is_class_domaine_id_count = MYSY_GV.dbname['class_domaine'].count_documents({'_id':ObjectId(str(diction['class_domaine_id'])),
|
||||
'valide':'1',
|
||||
'locked':'0'})
|
||||
|
||||
if (is_class_domaine_id_count != 1) :
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " L'identifiant du domaine de formation n'est pas valide ")
|
||||
return False, " L'identifiant du domaine de formation n'est pas valide "
|
||||
|
||||
|
||||
|
||||
new_data = diction
|
||||
del diction['token']
|
||||
|
||||
new_data['valide'] = "1"
|
||||
new_data['locked'] = "0"
|
||||
|
||||
new_data['date_update'] = str(datetime.now())
|
||||
new_data['update_by'] = str(my_partner['_id'])
|
||||
new_data['partner_owner_recid'] = str(my_partner['recid'])
|
||||
|
||||
inserted_id = MYSY_GV.dbname['class_categorie'].insert_one(new_data).inserted_id
|
||||
if (not inserted_id):
|
||||
mycommon.myprint(
|
||||
" Impossible de créer la catégorie de formation (2) ")
|
||||
return False, " Impossible de créer la catégorie de formation (2) "
|
||||
|
||||
|
||||
return True, " La categorie a été correctement ajoutée"
|
||||
|
||||
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, " IImpossible de créer la catégorie de formation "
|
||||
|
||||
|
||||
"""
|
||||
Mise à jour d'une categorie de formation
|
||||
"""
|
||||
|
||||
def Update_Class_Categorie(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', '_id', 'code', 'nom', 'description', 'class_domaine_id']
|
||||
|
||||
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 = ['token', '_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
|
||||
|
||||
new_data = diction
|
||||
|
||||
# Verifier que la categorie
|
||||
is_existe_cdtion_paiement = MYSY_GV.dbname['class_categorie'].count_documents(
|
||||
{'_id': ObjectId(str(diction['_id'])),
|
||||
'valide': '1',
|
||||
'partner_owner_recid': str(my_partner['recid'])})
|
||||
|
||||
if (is_existe_cdtion_paiement < 0):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " L'identifiant de la catégorie est invalide ")
|
||||
return False, " L'identifiant de la catégorie est invalide "
|
||||
|
||||
|
||||
|
||||
local_id = str(diction['_id'])
|
||||
|
||||
del diction['token']
|
||||
del diction['_id']
|
||||
|
||||
|
||||
new_data['date_update'] = str(datetime.now())
|
||||
new_data['update_by'] = str(my_partner['_id'])
|
||||
|
||||
data_cle = {}
|
||||
data_cle['partner_owner_recid'] = str(my_partner['recid'])
|
||||
data_cle['_id'] = ObjectId(local_id)
|
||||
data_cle['valide'] = "1"
|
||||
data_cle['locked'] = "0"
|
||||
|
||||
result = MYSY_GV.dbname['class_categorie'].find_one_and_update(
|
||||
data_cle,
|
||||
{"$set": new_data},
|
||||
upsert=False,
|
||||
return_document=ReturnDocument.AFTER
|
||||
)
|
||||
|
||||
if ("_id" not in result.keys()):
|
||||
mycommon.myprint(
|
||||
" Impossible de mettre à jour la catégorie de formation (2) ")
|
||||
return False, " Impossible de mettre à jour la catégorie de formation (2) "
|
||||
|
||||
return True, " Laatégorie de formation a été correctement mise à 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 mettre à jour la catégorie de formation "
|
||||
|
||||
|
||||
"""
|
||||
Suppression d'une categorie de formation
|
||||
regles :
|
||||
Si la condition (_id) n'est pas utiliser dans les collection
|
||||
- myclasss
|
||||
"""
|
||||
|
||||
def Delete_Class_Categorie(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', '_id',]
|
||||
|
||||
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 = ['token', '_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
|
||||
|
||||
|
||||
# Verifier que la codition de paiement existe
|
||||
is_existe_class_categorie = MYSY_GV.dbname['class_categorie'].count_documents(
|
||||
{'_id': ObjectId(str(diction['_id'])),
|
||||
'valide': '1',
|
||||
'partner_owner_recid': str(my_partner['recid'])})
|
||||
|
||||
if (is_existe_class_categorie < 0):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " L'identifiant de la catégorie de formation n'est pas valide ")
|
||||
return False, " L'identifiant de la catégorie de formation n'est pas valide "
|
||||
|
||||
|
||||
"""
|
||||
Verifier que la categorie de formation n'est pas utilisée (collection : myclass)
|
||||
"""
|
||||
is_categorie_in_myclass = MYSY_GV.dbname['myclass'].count_documents({'partner_owner_recid':my_partner['recid'],
|
||||
'valide':'1',
|
||||
'class_categorie_id':str(diction['_id'])})
|
||||
|
||||
|
||||
if( is_categorie_in_myclass > 0 ):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " Cette catégorie de formation est utilisée dans "+str(is_categorie_in_myclass)+" formations ")
|
||||
return False, " Cette catégorie de formation est utilisée dans "+str(is_categorie_in_myclass)+" formations "
|
||||
|
||||
|
||||
|
||||
|
||||
delete = MYSY_GV.dbname['class_categorie'].delete_one({'_id': ObjectId(str(diction['_id'])),
|
||||
'partner_owner_recid': str(my_partner['recid']),
|
||||
}, )
|
||||
|
||||
|
||||
|
||||
return True, " La catégorie de formation a été correctement supprimée"
|
||||
|
||||
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 la catégorie de formation "
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Recuperer la liste des categorie de formation d'un partenaire
|
||||
"""
|
||||
def Get_List_Class_Categorie(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['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'existe pas")
|
||||
return False, " Les informations fournies sont incorrectes",
|
||||
|
||||
"""
|
||||
Verification des champs obligatoires
|
||||
"""
|
||||
field_list_obligatoire = ['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
|
||||
|
||||
"""
|
||||
Clés de mise à jour
|
||||
"""
|
||||
data_cle = {}
|
||||
data_cle['partner_owner_recid'] = str(my_partner['recid'])
|
||||
data_cle['valide'] = "1"
|
||||
data_cle['locked'] = "0"
|
||||
|
||||
|
||||
RetObject = []
|
||||
val_tmp = 0
|
||||
|
||||
for retval in MYSY_GV.dbname['class_categorie'].find(data_cle):
|
||||
user = retval
|
||||
user['id'] = str(val_tmp)
|
||||
val_tmp = val_tmp + 1
|
||||
RetObject.append(mycommon.JSONEncoder().encode(user))
|
||||
|
||||
return True, RetObject
|
||||
|
||||
|
||||
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 récupérer la liste des categories de formation "
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Recuperer les données d'une categorie de formtion donnée
|
||||
"""
|
||||
def Get_Given_Class_Categorie(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', '_id']
|
||||
|
||||
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', '_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
|
||||
|
||||
"""
|
||||
Clés de mise à jour
|
||||
"""
|
||||
data_cle = {}
|
||||
data_cle['partner_owner_recid'] = str(my_partner['recid'])
|
||||
data_cle['valide'] = "1"
|
||||
data_cle['locked'] = "0"
|
||||
data_cle['_id'] = ObjectId(str(diction['_id']))
|
||||
|
||||
|
||||
RetObject = []
|
||||
val_tmp = 0
|
||||
|
||||
for retval in MYSY_GV.dbname['class_categorie'].find(data_cle):
|
||||
user = retval
|
||||
user['id'] = str(val_tmp)
|
||||
val_tmp = val_tmp + 1
|
||||
RetObject.append(mycommon.JSONEncoder().encode(user))
|
||||
|
||||
return True, RetObject
|
||||
|
||||
|
||||
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 récupérer les données de la categorie de formation "
|
||||
|
||||
|
54
class_mgt.py
54
class_mgt.py
|
@ -57,7 +57,8 @@ def add_class(diction):
|
|||
'internal_url', 'zone_diffusion', 'metier', 'published', 'img_url', 'objectif',
|
||||
'programme', 'prerequis', 'note', 'cpf', 'certif', 'class_inscription_url', 'pourqui',
|
||||
'support', 'img_banner_detail_class', 'source', 'lms_class_code', 'formateur_id',
|
||||
'class_level', 'methode_pedagogique', 'condition_handicape', 'suivi_eval', 'class_id']
|
||||
'class_level', 'methode_pedagogique', 'condition_handicape', 'suivi_eval', 'class_id',
|
||||
'version', 'categorie']
|
||||
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
|
@ -444,6 +445,18 @@ def add_class(diction):
|
|||
domaine = diction['domaine']
|
||||
mydata['domaine'] = domaine
|
||||
|
||||
version = ""
|
||||
if ("version" in diction.keys()):
|
||||
if diction['version']:
|
||||
version = diction['version']
|
||||
mydata['version'] = version
|
||||
|
||||
categorie = ""
|
||||
if ("categorie" in diction.keys()):
|
||||
if diction['categorie']:
|
||||
categorie = diction['categorie']
|
||||
mydata['categorie'] = categorie
|
||||
|
||||
# Traitement de l'url imag
|
||||
if ("img_url" in diction.keys()):
|
||||
if diction['img_url']:
|
||||
|
@ -659,7 +672,7 @@ def update_class(diction):
|
|||
'published', 'img_url', 'objectif', 'programme', 'prerequis', 'note',
|
||||
'cpf', 'certif', 'class_inscription_url','pourqui', 'support', 'img_banner_detail_class',
|
||||
'duration_unit', 'source', 'lms_class_code', 'formateur_id', 'class_level','methode_pedagogique',
|
||||
'condition_handicape', 'suivi_eval', 'class_id']
|
||||
'condition_handicape', 'suivi_eval', 'class_id', 'version', 'categorie']
|
||||
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
|
@ -952,6 +965,15 @@ def update_class(diction):
|
|||
if diction['domaine']:
|
||||
mydata['domaine'] = diction['domaine']
|
||||
|
||||
if ("version" in diction.keys()):
|
||||
if diction['version']:
|
||||
mydata['version'] = diction['version']
|
||||
|
||||
if ("categorie" in diction.keys()):
|
||||
if diction['categorie']:
|
||||
mydata['categorie'] = diction['categorie']
|
||||
|
||||
|
||||
if ("zone_diffusion" in diction.keys()):
|
||||
|
||||
if(len(str(diction['zone_diffusion'])) == 0 ):
|
||||
|
@ -3021,7 +3043,7 @@ def add_class_mass(file=None, Folder=None, diction=None):
|
|||
'mots_cle', 'zone_diffusion', 'metier', 'publie', 'img_url',
|
||||
'objectif', 'programme', 'prerequis', 'formateur', 'note', 'cpf', 'certif',
|
||||
'class_inscription_url', 'pourqui', 'support', 'img_banner_detail_class', 'formateur_email',
|
||||
'methode_pedagogique', 'condition_handicape', 'suivi_eval']
|
||||
'methode_pedagogique', 'condition_handicape', 'suivi_eval', 'version', 'categorie']
|
||||
|
||||
total_rows = len(df)
|
||||
|
||||
|
@ -3112,6 +3134,18 @@ def add_class_mass(file=None, Folder=None, diction=None):
|
|||
institut_formation = str(df['institut_formation'].values[n]).strip()
|
||||
mydata['institut_formation'] = institut_formation
|
||||
|
||||
version = ""
|
||||
if ("version" in df.keys()):
|
||||
if (str(df['version'].values[n])):
|
||||
version = str(df['version'].values[n]).strip()
|
||||
mydata['version'] = version
|
||||
|
||||
categorie = ""
|
||||
if ("categorie" in df.keys()):
|
||||
if (str(df['categorie'].values[n])):
|
||||
categorie = str(df['categorie'].values[n]).strip()
|
||||
mydata['categorie'] = categorie
|
||||
|
||||
|
||||
#mydata['duration'] = float(str(df['duree'].values[n]))
|
||||
|
||||
|
@ -3474,7 +3508,7 @@ def Controle_add_class_mass(saved_file=None, Folder=None, diction=None):
|
|||
'mots_cle', 'zone_diffusion', 'metier', 'publie', 'img_url',
|
||||
'objectif', 'programme', 'prerequis', 'formateur', 'note', 'cpf', 'certif',
|
||||
'class_inscription_url', 'pourqui', 'support', 'img_banner_detail_class', 'formateur_email' ,'methode_pedagogique',
|
||||
'condition_handicape', 'suivi_eval']
|
||||
'condition_handicape', 'suivi_eval', 'version', 'categorie']
|
||||
|
||||
total_rows = len(df)
|
||||
|
||||
|
@ -3595,6 +3629,18 @@ def Controle_add_class_mass(saved_file=None, Folder=None, diction=None):
|
|||
institut_formation = str(df['institut_formation'].values[n]).strip()
|
||||
mydata['institut_formation'] = institut_formation
|
||||
|
||||
version = ""
|
||||
if ("version" in df.keys()):
|
||||
if (str(df['version'].values[n])):
|
||||
version = str(df['version'].values[n]).strip()
|
||||
mydata['version'] = version
|
||||
|
||||
categorie = ""
|
||||
if ("categorie" in df.keys()):
|
||||
if (str(df['categorie'].values[n])):
|
||||
categorie = str(df['categorie'].values[n]).strip()
|
||||
mydata['categorie'] = categorie
|
||||
|
||||
|
||||
# Verifier que l'adresse email du formateur est valide
|
||||
formateur_email = ""
|
||||
|
|
|
@ -0,0 +1,454 @@
|
|||
"""
|
||||
Ce fichier permet de gerer les domaines de formation
|
||||
|
||||
un domaineest rattachées à un et un seul domaine
|
||||
et est defini par :
|
||||
- code domaine
|
||||
- nom domaine
|
||||
- description
|
||||
|
||||
|
||||
la clé fonctionnelle est le code
|
||||
"""
|
||||
import bson
|
||||
import pymongo
|
||||
from pymongo import MongoClient
|
||||
import json
|
||||
from bson import ObjectId
|
||||
import re
|
||||
from datetime import datetime
|
||||
import prj_common as mycommon
|
||||
import secrets
|
||||
import inspect
|
||||
import sys, os
|
||||
import csv
|
||||
import pandas as pd
|
||||
from pymongo import ReturnDocument
|
||||
import GlobalVariable as MYSY_GV
|
||||
from math import isnan
|
||||
import GlobalVariable as MYSY_GV
|
||||
import ela_index_bdd_classes as eibdd
|
||||
import email_mgt as email
|
||||
import jinja2
|
||||
from flask import send_file
|
||||
from xhtml2pdf import pisa
|
||||
from email.message import EmailMessage
|
||||
from email.mime.text import MIMEText
|
||||
from email import encoders
|
||||
import smtplib
|
||||
from email.mime.multipart import MIMEMultipart
|
||||
from email.mime.text import MIMEText
|
||||
from email.mime.base import MIMEBase
|
||||
from email import encoders
|
||||
|
||||
|
||||
"""
|
||||
Ajout d'une domaine
|
||||
"""
|
||||
|
||||
def Add_Class_Domaine(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', 'code', 'nom', 'description',]
|
||||
|
||||
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 = ['token', 'code', 'nom', 'class_domaine_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
|
||||
|
||||
|
||||
# Verifier que ce code n'existe pas déjà
|
||||
is_existe_class_domaine = MYSY_GV.dbname['class_domaine'].count_documents({'code':str(diction['code']),
|
||||
'valide':'1',
|
||||
'partner_owner_recid':str(my_partner['recid'])})
|
||||
|
||||
|
||||
if( is_existe_class_domaine > 0 ):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " Un domaine avec le code '" + str(diction['code']) + "' existe déjà ")
|
||||
return False, " Un domaine avec le code '" + str(diction['code']) + "' existe déjà "
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
new_data = diction
|
||||
del diction['token']
|
||||
|
||||
new_data['valide'] = "1"
|
||||
new_data['locked'] = "0"
|
||||
|
||||
new_data['date_update'] = str(datetime.now())
|
||||
new_data['update_by'] = str(my_partner['_id'])
|
||||
new_data['partner_owner_recid'] = str(my_partner['recid'])
|
||||
|
||||
inserted_id = MYSY_GV.dbname['class_domaine'].insert_one(new_data).inserted_id
|
||||
if (not inserted_id):
|
||||
mycommon.myprint(
|
||||
" Impossible de créer le domaine de formation (2) ")
|
||||
return False, " Impossible de créer le domaine de formation (2) "
|
||||
|
||||
|
||||
return True, " La domaine a été correctement ajoutée"
|
||||
|
||||
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, " IImpossible de créer le domaine de formation "
|
||||
|
||||
|
||||
"""
|
||||
Mise à jour d'un domainede formation
|
||||
"""
|
||||
|
||||
def Update_Class_domaine(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', '_id', 'code', 'nom', 'description',]
|
||||
|
||||
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 = ['token', '_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
|
||||
|
||||
new_data = diction
|
||||
|
||||
# Verifier que la domaine
|
||||
is_existe_cdtion_paiement = MYSY_GV.dbname['class_domaine'].count_documents(
|
||||
{'_id': ObjectId(str(diction['_id'])),
|
||||
'valide': '1',
|
||||
'partner_owner_recid': str(my_partner['recid'])})
|
||||
|
||||
if (is_existe_cdtion_paiement < 0):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " L'identifiant de le domaine est invalide ")
|
||||
return False, " L'identifiant de le domaine est invalide "
|
||||
|
||||
|
||||
|
||||
local_id = str(diction['_id'])
|
||||
|
||||
del diction['token']
|
||||
del diction['_id']
|
||||
|
||||
|
||||
new_data['date_update'] = str(datetime.now())
|
||||
new_data['update_by'] = str(my_partner['_id'])
|
||||
|
||||
data_cle = {}
|
||||
data_cle['partner_owner_recid'] = str(my_partner['recid'])
|
||||
data_cle['_id'] = ObjectId(local_id)
|
||||
data_cle['valide'] = "1"
|
||||
data_cle['locked'] = "0"
|
||||
|
||||
result = MYSY_GV.dbname['class_domaine'].find_one_and_update(
|
||||
data_cle,
|
||||
{"$set": new_data},
|
||||
upsert=False,
|
||||
return_document=ReturnDocument.AFTER
|
||||
)
|
||||
|
||||
if ("_id" not in result.keys()):
|
||||
mycommon.myprint(
|
||||
" Impossible de mettre à jour le domaine de formation (2) ")
|
||||
return False, " Impossible de mettre à jour le domaine de formation (2) "
|
||||
|
||||
return True, " Le domaine de formation a été correctement mise à 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 mettre à jour le domaine de formation "
|
||||
|
||||
|
||||
"""
|
||||
Suppression d'un domainede formation
|
||||
regles :
|
||||
Si la condition (_id) n'est pas utiliser dans les collection
|
||||
- myclasss
|
||||
"""
|
||||
|
||||
def Delete_Class_domaine(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', '_id',]
|
||||
|
||||
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 = ['token', '_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
|
||||
|
||||
|
||||
# Verifier que la codition de paiement existe
|
||||
is_existe_class_domaine = MYSY_GV.dbname['class_domaine'].count_documents(
|
||||
{'_id': ObjectId(str(diction['_id'])),
|
||||
'valide': '1',
|
||||
'partner_owner_recid': str(my_partner['recid'])})
|
||||
|
||||
if (is_existe_class_domaine < 0):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " L'identifiant de le domaine de formation n'est pas valide ")
|
||||
return False, " L'identifiant de le domaine de formation n'est pas valide "
|
||||
|
||||
|
||||
"""
|
||||
Verifier que la domaine de formation n'est pas utilisée (collection : myclass)
|
||||
"""
|
||||
is_domaine_in_myclass = MYSY_GV.dbname['myclass'].count_documents({'partner_owner_recid':my_partner['recid'],
|
||||
'valide':'1',
|
||||
'class_domaine_id':str(diction['_id'])})
|
||||
|
||||
|
||||
if( is_domaine_in_myclass > 0 ):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " Cette catégorie de formation est utilisée dans "+str(is_domaine_in_myclass)+" formations ")
|
||||
return False, " Cette catégorie de formation est utilisée dans "+str(is_domaine_in_myclass)+" formations "
|
||||
|
||||
|
||||
|
||||
|
||||
delete = MYSY_GV.dbname['class_domaine'].delete_one({'_id': ObjectId(str(diction['_id'])),
|
||||
'partner_owner_recid': str(my_partner['recid']),
|
||||
}, )
|
||||
|
||||
|
||||
|
||||
return True, " le domaine de formation a été correctement supprimée"
|
||||
|
||||
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 domaine de formation "
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Recuperer la liste des domaine de formation d'un partenaire
|
||||
"""
|
||||
def Get_List_Class_domaine(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['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'existe pas")
|
||||
return False, " Les informations fournies sont incorrectes",
|
||||
|
||||
"""
|
||||
Verification des champs obligatoires
|
||||
"""
|
||||
field_list_obligatoire = ['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
|
||||
|
||||
"""
|
||||
Clés de mise à jour
|
||||
"""
|
||||
data_cle = {}
|
||||
#data_cle['partner_owner_recid'] = str(my_partner['recid'])
|
||||
data_cle['valide'] = "1"
|
||||
data_cle['locked'] = "0"
|
||||
|
||||
|
||||
RetObject = []
|
||||
val_tmp = 0
|
||||
|
||||
for retval in MYSY_GV.dbname['class_domaine'].find(data_cle):
|
||||
user = retval
|
||||
user['id'] = str(val_tmp)
|
||||
val_tmp = val_tmp + 1
|
||||
RetObject.append(mycommon.JSONEncoder().encode(user))
|
||||
|
||||
return True, RetObject
|
||||
|
||||
|
||||
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 récupérer la liste des domaines de formation "
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Recuperer les données d'un domainede formtion donnée
|
||||
"""
|
||||
def Get_Given_Class_domaine(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', '_id']
|
||||
|
||||
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', '_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
|
||||
|
||||
"""
|
||||
Clés de mise à jour
|
||||
"""
|
||||
data_cle = {}
|
||||
data_cle['partner_owner_recid'] = str(my_partner['recid'])
|
||||
data_cle['valide'] = "1"
|
||||
data_cle['locked'] = "0"
|
||||
data_cle['_id'] = ObjectId(str(diction['_id']))
|
||||
|
||||
|
||||
RetObject = []
|
||||
val_tmp = 0
|
||||
|
||||
for retval in MYSY_GV.dbname['class_domaine'].find(data_cle):
|
||||
user = retval
|
||||
user['id'] = str(val_tmp)
|
||||
val_tmp = val_tmp + 1
|
||||
RetObject.append(mycommon.JSONEncoder().encode(user))
|
||||
|
||||
return True, RetObject
|
||||
|
||||
|
||||
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 récupérer les données de la domaine de formation "
|
||||
|
||||
|
217
main.py
217
main.py
|
@ -82,7 +82,9 @@ import competence as competence
|
|||
import formulaire_mgt as formulaire_mgt
|
||||
import survey_mgt as survey_mgt
|
||||
import unite_enseignement_mgt as unite_enseignement_mgt
|
||||
|
||||
import metier_formation_mgt as metier_formation_mgt
|
||||
import categorie_formation_mgt as categorie_formation_mgt
|
||||
import domaine_formation_mgt as domaine_formation_mgt
|
||||
|
||||
app = Flask(__name__)
|
||||
cors = CORS(app, resources={r"/foo": {"origins": "*"}})
|
||||
|
@ -8788,6 +8790,219 @@ def Create_Automatic_Sequence_From_Month_Model():
|
|||
|
||||
|
||||
|
||||
"""
|
||||
API Pour ajouter une categorie de formation
|
||||
"""
|
||||
@app.route('/myclass/api/Add_Class_Categorie/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Add_Class_Categorie():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Add_Class_Categorie payload = ",payload)
|
||||
status, retval = categorie_formation_mgt.Add_Class_Categorie(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
"""
|
||||
API Pour mettre à jour une categorie de formation
|
||||
"""
|
||||
@app.route('/myclass/api/Update_Class_Categorie/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Update_Class_Categorie():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Update_Class_Categorie payload = ",payload)
|
||||
status, retval = categorie_formation_mgt.Update_Class_Categorie(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
|
||||
"""
|
||||
API Pour supprimer une categorie de formation
|
||||
"""
|
||||
@app.route('/myclass/api/Delete_Class_Categorie/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Delete_Class_Categorie():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Delete_Class_Categorie payload = ",payload)
|
||||
status, retval = categorie_formation_mgt.Delete_Class_Categorie(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
|
||||
"""
|
||||
API Pour recuperer la liste des categories de formation
|
||||
"""
|
||||
@app.route('/myclass/api/Get_List_Class_Categorie/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Get_List_Class_Categorie():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Get_List_Class_Categorie payload = ",payload)
|
||||
status, retval = categorie_formation_mgt.Get_List_Class_Categorie(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
"""
|
||||
API Pour recuperer les données d'une categories de formation
|
||||
"""
|
||||
@app.route('/myclass/api/Get_Given_Class_Categorie/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Get_Given_Class_Categorie():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Get_Given_Class_Categorie payload = ",payload)
|
||||
status, retval = categorie_formation_mgt.Get_Given_Class_Categorie(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
"""
|
||||
API Pour ajouter un metier de formation
|
||||
"""
|
||||
@app.route('/myclass/api/Add_class_metier/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Add_class_metier():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Add_class_metier payload = ",payload)
|
||||
status, retval = metier_formation_mgt.Add_class_metier(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
"""
|
||||
API Pour mettre à jour un metier de formation
|
||||
"""
|
||||
@app.route('/myclass/api/Update_class_metier/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Update_class_metier():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Update_class_metier payload = ",payload)
|
||||
status, retval = metier_formation_mgt.Update_class_metier(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
|
||||
"""
|
||||
API Pour supprimer un metier de formation
|
||||
"""
|
||||
@app.route('/myclass/api/Delete_class_metier/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Delete_class_metier():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Delete_class_metier payload = ",payload)
|
||||
status, retval = metier_formation_mgt.Delete_class_metier(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
"""
|
||||
API Pour recuperer la liste des metiers de formation d'un partenaire
|
||||
"""
|
||||
@app.route('/myclass/api/Get_List_class_metier/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Get_List_class_metier():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Get_List_class_metier payload = ",payload)
|
||||
status, retval = metier_formation_mgt.Get_List_class_metier(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
|
||||
"""
|
||||
API Pour recuperer les données d'un metiers de formation d'un partenaire
|
||||
"""
|
||||
@app.route('/myclass/api/Get_Given_class_metier/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Get_Given_class_metier():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Get_Given_class_metier payload = ",payload)
|
||||
status, retval = metier_formation_mgt.Get_Given_class_metier(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
"""
|
||||
API Pour recuperer la liste des domaines metier (V2 : utilisation de la collection: class_domaine)
|
||||
"""
|
||||
@app.route('/myclass/api/get_List_domaine_formation_V2/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def get_List_domaine_formation_V2():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### get_List_domaine_formation_V2 payload = ",payload)
|
||||
status, retval = mycommon.get_List_domaine_formation_V2(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
|
||||
|
||||
"""
|
||||
API Pour ajouter un domaine de formation
|
||||
"""
|
||||
@app.route('/myclass/api/Add_Class_Domaine/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Add_Class_Domaine():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Add_Class_Domaine payload = ",payload)
|
||||
status, retval = domaine_formation_mgt.Add_Class_Domaine(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
"""
|
||||
API Pour mettre à jour un domaine de formation
|
||||
"""
|
||||
@app.route('/myclass/api/Update_Class_domaine/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Update_Class_domaine():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Update_Class_domaine payload = ",payload)
|
||||
status, retval = domaine_formation_mgt.Update_Class_domaine(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
|
||||
"""
|
||||
API Pour supprimer un domaine de formation
|
||||
"""
|
||||
@app.route('/myclass/api/Delete_Class_domaine/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Delete_Class_domaine():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Delete_Class_domaine payload = ",payload)
|
||||
status, retval = domaine_formation_mgt.Delete_Class_domaine(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
"""
|
||||
API Pour recuperer la liste des domaines de formation d'un partenaire
|
||||
"""
|
||||
@app.route('/myclass/api/Get_List_Class_domaine/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Get_List_Class_domaine():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Get_List_Class_domaine payload = ",payload)
|
||||
status, retval = domaine_formation_mgt.Get_List_Class_domaine(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
|
||||
"""
|
||||
API Pour recuperer les données d'un metiers de formation d'un partenaire
|
||||
"""
|
||||
@app.route('/myclass/api/Get_Given_Class_domaine/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Get_Given_Class_domaine():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = mycommon.strip_dictionary (request.form.to_dict())
|
||||
print(" ### Get_Given_Class_domaine payload = ",payload)
|
||||
status, retval = domaine_formation_mgt.Get_Given_Class_domaine(payload)
|
||||
return jsonify(status=status, message=retval)
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
@ -0,0 +1,465 @@
|
|||
"""
|
||||
Ce fichier permet de gerer les metiers de formation
|
||||
|
||||
Une metier est rattachées à un et un seul domaine
|
||||
et est defini par :
|
||||
- code metier
|
||||
- nom metier
|
||||
- description
|
||||
- domaine_id
|
||||
|
||||
la clé fonctionnelle est le code
|
||||
"""
|
||||
import bson
|
||||
import pymongo
|
||||
from pymongo import MongoClient
|
||||
import json
|
||||
from bson import ObjectId
|
||||
import re
|
||||
from datetime import datetime
|
||||
import prj_common as mycommon
|
||||
import secrets
|
||||
import inspect
|
||||
import sys, os
|
||||
import csv
|
||||
import pandas as pd
|
||||
from pymongo import ReturnDocument
|
||||
import GlobalVariable as MYSY_GV
|
||||
from math import isnan
|
||||
import GlobalVariable as MYSY_GV
|
||||
import ela_index_bdd_classes as eibdd
|
||||
import email_mgt as email
|
||||
import jinja2
|
||||
from flask import send_file
|
||||
from xhtml2pdf import pisa
|
||||
from email.message import EmailMessage
|
||||
from email.mime.text import MIMEText
|
||||
from email import encoders
|
||||
import smtplib
|
||||
from email.mime.multipart import MIMEMultipart
|
||||
from email.mime.text import MIMEText
|
||||
from email.mime.base import MIMEBase
|
||||
from email import encoders
|
||||
|
||||
|
||||
"""
|
||||
Ajout d'une metier
|
||||
"""
|
||||
|
||||
def Add_class_metier(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', 'code', 'nom', 'description', 'class_domaine_id']
|
||||
|
||||
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 = ['token', 'code', 'nom', 'class_domaine_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
|
||||
|
||||
|
||||
# Verifier que ce code n'existe pas déjà
|
||||
is_existe_class_metier = MYSY_GV.dbname['class_metier'].count_documents({'code':str(diction['code']),
|
||||
'valide':'1',
|
||||
'partner_owner_recid':str(my_partner['recid'])})
|
||||
|
||||
|
||||
if( is_existe_class_metier > 0 ):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " Un métier avec le code '" + str(diction['code']) + "' existe déjà ")
|
||||
return False, " Un métier avec le code '" + str(diction['code']) + "' existe déjà "
|
||||
|
||||
|
||||
"""
|
||||
Verifier que le domaine_id exist et est valide
|
||||
"""
|
||||
is_class_domaine_id_count = MYSY_GV.dbname['class_domaine'].count_documents({'_id':ObjectId(str(diction['class_domaine_id'])),
|
||||
'valide':'1',
|
||||
'locked':'0'})
|
||||
|
||||
if (is_class_domaine_id_count != 1) :
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " L'identifiant du metier de formation n'est pas valide ")
|
||||
return False, " L'identifiant du metier de formation n'est pas valide "
|
||||
|
||||
|
||||
|
||||
new_data = diction
|
||||
del diction['token']
|
||||
|
||||
new_data['valide'] = "1"
|
||||
new_data['locked'] = "0"
|
||||
|
||||
new_data['date_update'] = str(datetime.now())
|
||||
new_data['update_by'] = str(my_partner['_id'])
|
||||
new_data['partner_owner_recid'] = str(my_partner['recid'])
|
||||
|
||||
inserted_id = MYSY_GV.dbname['class_metier'].insert_one(new_data).inserted_id
|
||||
if (not inserted_id):
|
||||
mycommon.myprint(
|
||||
" Impossible de créer la metier de formation (2) ")
|
||||
return False, " Impossible de créer le métier de formation (2) "
|
||||
|
||||
|
||||
return True, " La metier a été correctement ajoutée"
|
||||
|
||||
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, " IImpossible de créer le métier de formation "
|
||||
|
||||
|
||||
"""
|
||||
Mise à jour d'une metier de formation
|
||||
"""
|
||||
|
||||
def Update_class_metier(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', '_id', 'code', 'nom', 'description', 'class_domaine_id']
|
||||
|
||||
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 = ['token', '_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
|
||||
|
||||
new_data = diction
|
||||
|
||||
# Verifier que la metier
|
||||
is_existe_cdtion_paiement = MYSY_GV.dbname['class_metier'].count_documents(
|
||||
{'_id': ObjectId(str(diction['_id'])),
|
||||
'valide': '1',
|
||||
'partner_owner_recid': str(my_partner['recid'])})
|
||||
|
||||
if (is_existe_cdtion_paiement < 0):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " L'identifiant du métier est invalide ")
|
||||
return False, " L'identifiant du métier est invalide "
|
||||
|
||||
|
||||
|
||||
local_id = str(diction['_id'])
|
||||
|
||||
del diction['token']
|
||||
del diction['_id']
|
||||
|
||||
|
||||
new_data['date_update'] = str(datetime.now())
|
||||
new_data['update_by'] = str(my_partner['_id'])
|
||||
|
||||
data_cle = {}
|
||||
data_cle['partner_owner_recid'] = str(my_partner['recid'])
|
||||
data_cle['_id'] = ObjectId(local_id)
|
||||
data_cle['valide'] = "1"
|
||||
data_cle['locked'] = "0"
|
||||
|
||||
result = MYSY_GV.dbname['class_metier'].find_one_and_update(
|
||||
data_cle,
|
||||
{"$set": new_data},
|
||||
upsert=False,
|
||||
return_document=ReturnDocument.AFTER
|
||||
)
|
||||
|
||||
if ("_id" not in result.keys()):
|
||||
mycommon.myprint(
|
||||
" Impossible de mettre à jour le métier de formation (2) ")
|
||||
return False, " Impossible de mettre à jour le métier de formation (2) "
|
||||
|
||||
return True, " Laatégorie de formation a été correctement mise à 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 mettre à jour le métier de formation "
|
||||
|
||||
|
||||
"""
|
||||
Suppression d'une metier de formation
|
||||
regles :
|
||||
Si la condition (_id) n'est pas utiliser dans les collection
|
||||
- myclasss
|
||||
"""
|
||||
|
||||
def Delete_class_metier(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', '_id',]
|
||||
|
||||
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 = ['token', '_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
|
||||
|
||||
|
||||
# Verifier que la codition de paiement existe
|
||||
is_existe_class_metier = MYSY_GV.dbname['class_metier'].count_documents(
|
||||
{'_id': ObjectId(str(diction['_id'])),
|
||||
'valide': '1',
|
||||
'partner_owner_recid': str(my_partner['recid'])})
|
||||
|
||||
if (is_existe_class_metier < 0):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " L'identifiant du métier de formation n'est pas valide ")
|
||||
return False, " L'identifiant du métier de formation n'est pas valide "
|
||||
|
||||
|
||||
"""
|
||||
Verifier que la metier de formation n'est pas utilisée (collection : myclass)
|
||||
"""
|
||||
is_metier_in_myclass = MYSY_GV.dbname['myclass'].count_documents({'partner_owner_recid':my_partner['recid'],
|
||||
'valide':'1',
|
||||
'class_metier_id':str(diction['_id'])})
|
||||
|
||||
|
||||
if( is_metier_in_myclass > 0 ):
|
||||
mycommon.myprint(
|
||||
str(inspect.stack()[0][3]) + " Ce métier de formation est utilisée dans "+str(is_metier_in_myclass)+" formations ")
|
||||
return False, " Ce métier de formation est utilisée dans "+str(is_metier_in_myclass)+" formations "
|
||||
|
||||
|
||||
|
||||
|
||||
delete = MYSY_GV.dbname['class_metier'].delete_one({'_id': ObjectId(str(diction['_id'])),
|
||||
'partner_owner_recid': str(my_partner['recid']),
|
||||
}, )
|
||||
|
||||
|
||||
|
||||
return True, " Le métier de formation a été correctement supprimée"
|
||||
|
||||
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 métier de formation "
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Recuperer la liste des metier de formation d'un partenaire
|
||||
"""
|
||||
def Get_List_class_metier(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['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'existe pas")
|
||||
return False, " Les informations fournies sont incorrectes",
|
||||
|
||||
"""
|
||||
Verification des champs obligatoires
|
||||
"""
|
||||
field_list_obligatoire = ['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
|
||||
|
||||
"""
|
||||
Clés de mise à jour
|
||||
"""
|
||||
data_cle = {}
|
||||
data_cle['partner_owner_recid'] = str(my_partner['recid'])
|
||||
data_cle['valide'] = "1"
|
||||
data_cle['locked'] = "0"
|
||||
|
||||
|
||||
RetObject = []
|
||||
val_tmp = 0
|
||||
|
||||
for retval in MYSY_GV.dbname['class_metier'].find(data_cle):
|
||||
user = retval
|
||||
user['id'] = str(val_tmp)
|
||||
val_tmp = val_tmp + 1
|
||||
RetObject.append(mycommon.JSONEncoder().encode(user))
|
||||
|
||||
return True, RetObject
|
||||
|
||||
|
||||
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 récupérer la liste des metiers de formation "
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Recuperer les données d'une metier de formtion donnée
|
||||
"""
|
||||
def Get_Given_class_metier(diction):
|
||||
try:
|
||||
diction = mycommon.strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', '_id']
|
||||
|
||||
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', '_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
|
||||
|
||||
"""
|
||||
Clés de mise à jour
|
||||
"""
|
||||
data_cle = {}
|
||||
data_cle['partner_owner_recid'] = str(my_partner['recid'])
|
||||
data_cle['valide'] = "1"
|
||||
data_cle['locked'] = "0"
|
||||
data_cle['_id'] = ObjectId(str(diction['_id']))
|
||||
|
||||
|
||||
RetObject = []
|
||||
val_tmp = 0
|
||||
|
||||
for retval in MYSY_GV.dbname['class_metier'].find(data_cle):
|
||||
user = retval
|
||||
user['id'] = str(val_tmp)
|
||||
val_tmp = val_tmp + 1
|
||||
RetObject.append(mycommon.JSONEncoder().encode(user))
|
||||
|
||||
return True, RetObject
|
||||
|
||||
|
||||
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 récupérer les données de la metier de formation "
|
||||
|
||||
|
|
@ -254,6 +254,8 @@ def Update_Paiement_Condition(diction):
|
|||
return False, " Impossible de mettre à jour la condition de paiement "
|
||||
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Suppression d'une condition de paiement
|
||||
regles :
|
||||
|
|
|
@ -3697,6 +3697,77 @@ def GetAttendeeDetail_perSession(diction):
|
|||
return False, " Impossible de récupérer les informations detaillées"
|
||||
|
||||
|
||||
"""
|
||||
Cette fonction retourne la liste des domaines
|
||||
de formation avec la version utilisant : "class_domaine"
|
||||
"""
|
||||
def get_List_domaine_formation_V2(diction):
|
||||
try:
|
||||
diction = strip_dictionary(diction)
|
||||
|
||||
"""
|
||||
Verification des input acceptés
|
||||
"""
|
||||
field_list = ['token', ]
|
||||
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
if val not in field_list and val.startswith('my_') is False:
|
||||
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', ]
|
||||
|
||||
for val in field_list_obligatoire:
|
||||
if val not in diction:
|
||||
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 = Check_Connexion_And_Return_Partner_Data(diction)
|
||||
if (local_status is not True):
|
||||
return local_status, my_partner
|
||||
|
||||
coll_liste_domaine_metier = MYSY_GV.dbname['class_domaine']
|
||||
|
||||
myquery = {}
|
||||
myquery['valide'] = "1"
|
||||
myquery['partner_owner_recid'] = str(my_partner['recid'])
|
||||
|
||||
RetObject = []
|
||||
val_tmp = 0
|
||||
|
||||
for retval in coll_liste_domaine_metier.find(myquery):
|
||||
user = retval
|
||||
user['id'] = val_tmp
|
||||
val_tmp = val_tmp + 1
|
||||
|
||||
RetObject.append(user)
|
||||
|
||||
return True, RetObject
|
||||
|
||||
except Exception as e:
|
||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||
print(str(inspect.stack()[0][3]) + " -" + str(e) + " - ERRORRRR AT Line : " + str(exc_tb.tb_lineno))
|
||||
return False, " Impossible de récupérer la liste de domaines de formation"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
""" Cette fonction retourne la liste des domaines
|
||||
de formation
|
||||
"""
|
||||
|
@ -3721,7 +3792,8 @@ def get_List_domaine_formation():
|
|||
return False, " Impossible de récupérer la liste de domaines de formation"
|
||||
|
||||
|
||||
""" Cette fonction retourne la liste des domaines
|
||||
"""
|
||||
Cette fonction retourne la liste des domaines
|
||||
de formation en mode JSON
|
||||
"""
|
||||
def get_List_domaine_formation_JSON():
|
||||
|
|
Loading…
Reference in New Issue