diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 73d4a41..b1dd3e5 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,13 +4,12 @@
-
+
+
-
-
-
-
-
+
+
+
@@ -452,7 +451,7 @@
1747251650255
-
+
@@ -494,7 +493,6 @@
-
@@ -519,6 +517,7 @@
-
+
+
\ No newline at end of file
diff --git a/ent_student_common.py b/ent_student_common.py
new file mode 100644
index 0000000..8b093d2
--- /dev/null
+++ b/ent_student_common.py
@@ -0,0 +1,275 @@
+"""
+-- Gestion de l'espace ENT des apprenants
+Ce fichier permet de gerer les fonction de ENT ETUDIANT
+
+"""
+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
+
+"""
+Cette fonctions retourne les class_id d'un apprenant return : tab_class_id : [] - Uniquement les class_id
+"""
+
+def Get_Apprenant_Tab_Class_Id(diction):
+ try:
+ diction = mycommon.strip_dictionary(diction)
+
+ """
+ Verification des input acceptés
+ """
+ field_list = ['token', 'apprenant_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', 'apprenant_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 la liste des arguments ")
+ 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 la validité de l'apprenant
+ """
+ is_apprenant_valide_count = MYSY_GV.dbname['apprenant'].count_documents(
+ {'_id': ObjectId(str(diction['apprenant_id'])),
+ 'valide': '1',
+ 'locked': '0'})
+
+ if (is_apprenant_valide_count != 1):
+ mycommon.myprint(
+ str(inspect.stack()[0][
+ 3]) + " L'identifiant de l'apprenant est invalide ")
+ return False, " L'identifiant de l'apprenant est invalide ",
+
+ apprenant_data = MYSY_GV.dbname['apprenant'].find_one(
+ {'_id': ObjectId(str(diction['apprenant_id'])),
+ 'valide': '1',
+ 'locked': '0'})
+
+ qry = {}
+ qry['partner_owner_recid'] = apprenant_data['partner_owner_recid']
+ qry['apprenant_id'] = diction['apprenant_id']
+ qry['valide'] = "1"
+ qry['locked'] = "0"
+
+ query = [{'$match': {'$and': [qry]}},
+ {'$sort': {'_id': -1}},
+ {'$lookup':
+ {
+ 'from': 'myclass',
+ 'localField': 'class_internal_url',
+ 'foreignField': 'internal_url',
+ 'pipeline': [{'$match': {'$and': [{}, {}]}},
+ {'$project': {'_id': 1, }}],
+ 'as': 'myclass_collection'
+ }
+ },
+ {'$lookup':
+ {
+ 'from': 'apprenant',
+ "let": {'apprenant_id': "$apprenant_id", 'partner_owner_recid': '$partner_owner_recid'},
+ 'pipeline': [{'$match':
+ {'$expr': {'$and': [
+ {'$eq': ["$valide", "1"]},
+ {'$eq': ["$_id", {'$convert': {
+ 'input': "$$apprenant_id",
+ 'to': "objectId",
+ 'onError': {'error': 'true'},
+ 'onNull': {'isnull': 'true'}
+ }}]},
+
+ ]}}},
+ ], 'as': 'apprenant_collection'}}
+ ]
+
+ print("#### Get_Apprenant_Tab_Class_Id laa 01 : query = ", query)
+ RetObject = []
+ cpt = 0
+
+ for retVal in MYSY_GV.dbname['inscription'].aggregate(query):
+ val = {}
+ if ('myclass_collection' in retVal.keys() and len(retVal['myclass_collection']) > 0):
+ for class_data in retVal['myclass_collection']:
+ RetObject.append(str(class_data['_id']))
+
+ 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 la liste des class_id de l'apprenant "
+
+
+"""
+Recuperer la liste des formation d'un apprenant pour son espace ENT
+"""
+def Get_Ent_Student_List_Class(diction):
+ try:
+ diction = mycommon.strip_dictionary(diction)
+
+ """
+ Verification des input acceptés
+ """
+ field_list = ['token', 'apprenant_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', 'apprenant_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 la liste des arguments ")
+ 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 la validité de l'apprenant
+ """
+ is_apprenant_valide_count = MYSY_GV.dbname['apprenant'].count_documents({'_id':ObjectId(str(diction['apprenant_id'])),
+ 'valide':'1',
+ 'locked':'0'})
+
+ if( is_apprenant_valide_count != 1):
+ mycommon.myprint(
+ str(inspect.stack()[0][
+ 3]) + " L'identifiant de l'apprenant est invalide ")
+ return False, " L'identifiant de l'apprenant est invalide ",
+
+ apprenant_data = MYSY_GV.dbname['apprenant'].find_one(
+ {'_id': ObjectId(str(diction['apprenant_id'])),
+ 'valide': '1',
+ 'locked': '0'})
+
+
+ qry = {}
+ qry['partner_owner_recid'] = apprenant_data['partner_owner_recid']
+ qry['apprenant_id'] = diction['apprenant_id']
+ qry['valide'] = "1"
+ qry['locked'] = "0"
+
+ query = [{'$match': {'$and': [qry ]}},
+ {'$sort': {'_id': -1}},
+ {'$lookup':
+ {
+ 'from': 'myclass',
+ 'localField': 'class_internal_url',
+ 'foreignField': 'internal_url',
+ 'pipeline': [{'$match': {'$and': [{}, {}]}},
+ {'$project': {'title': 1, 'domaine': 1,
+ 'duration': 1,
+ 'duration_unit': 1,
+ '_id': 1,
+ 'recyclage_delai': 1,
+ 'recyclage_periodicite': 1,
+ 'recyclage_alert': 1}}],
+ 'as': 'myclass_collection'
+ }
+ },
+ {'$lookup':
+ {
+ 'from': 'apprenant',
+ "let": {'apprenant_id': "$apprenant_id", 'partner_owner_recid': '$partner_owner_recid'},
+ 'pipeline': [{'$match':
+ {'$expr': {'$and': [
+ {'$eq': ["$valide", "1"]},
+ {'$eq': ["$_id", {'$convert': {
+ 'input': "$$apprenant_id",
+ 'to': "objectId",
+ 'onError': {'error': 'true'},
+ 'onNull': {'isnull': 'true'}
+ }}]},
+
+ ]}}},
+ ], 'as': 'apprenant_collection'}}
+ ]
+
+ print("#### Get_Ent_Student_Class laa 01 : query = ", query)
+ RetObject = []
+ cpt = 0
+
+ for retVal in MYSY_GV.dbname['inscription'].aggregate(query):
+ val = {}
+ if ('myclass_collection' in retVal.keys() and len(retVal['myclass_collection']) > 0):
+ val['id'] = str(cpt)
+ cpt = cpt + 1
+ val['_id'] = retVal['_id']
+
+
+ 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 formations de l'apprenant "
+
diff --git a/equipe_team_mgt.py b/equipe_team_mgt.py
index ea0c02d..719f939 100644
--- a/equipe_team_mgt.py
+++ b/equipe_team_mgt.py
@@ -947,7 +947,6 @@ def Get_List_Equipe_Team(diction):
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))
diff --git a/main.py b/main.py
index f80d9a1..7abf976 100644
--- a/main.py
+++ b/main.py
@@ -100,6 +100,7 @@ import base_class_calcul_note as base_class_calcul_note
import jury_mgt as jury_mgt
import financial_caracteristique_mgt as financial_caracteristique_mgt
import reference_pedagogique_mgt as reference_pedagogique_mgt
+import ent_student_common as ent_student_common
import base_document_automatic_setup as base_document_automatic_setup
@@ -12930,6 +12931,31 @@ def Get_Ref_Pedagogique_no_filter():
return jsonify(status=status, message=retval)
+"""
+API - Gestion ENT Apprenant : Recuperation des formations d'un apprenant
+"""
+@app.route('/myclass/api/Get_Ent_Student_List_Class/', methods=['POST','GET'])
+@crossdomain(origin='*')
+def Get_Ent_Student_List_Class():
+ # On recupere le corps (payload) de la requete
+ payload = mycommon.strip_dictionary (request.form.to_dict())
+ print(" ### Get_Ent_Student_List_Class : payload = ",str(payload))
+ status, retval = ent_student_common.Get_Ent_Student_List_Class( payload)
+ return jsonify(status=status, message=retval)
+
+
+"""
+API - Gestion ENT Apprenant : Recuperation uniquement les liste de class_id de l'apprenant
+"""
+@app.route('/myclass/api/Get_Apprenant_Tab_Class_Id/', methods=['POST','GET'])
+@crossdomain(origin='*')
+def Get_Apprenant_Tab_Class_Id():
+ # On recupere le corps (payload) de la requete
+ payload = mycommon.strip_dictionary (request.form.to_dict())
+ print(" ### Get_Apprenant_Tab_Class_Id : payload = ",str(payload))
+ status, retval = ent_student_common.Get_Apprenant_Tab_Class_Id( payload)
+ return jsonify(status=status, message=retval)
+
if __name__ == '__main__':
diff --git a/prj_common.py b/prj_common.py
index 4d4140c..91a71f4 100644
--- a/prj_common.py
+++ b/prj_common.py
@@ -587,7 +587,7 @@ def get_connected_data_from_token(connected_token = ""):
"""
tmp_val = None
- if( token_data and "type" in token_data.keys() and str(token_data['type']) == "user"):
+ if( token_data and "type" in token_data.keys() and ( str(token_data['type']) == "user" or str(token_data['type']) == "student" ) ):
coll_token = MYSY_GV.dbname['user_account']
tmp_val = coll_token.find_one({'token': str(connected_token), 'active': '1', 'locked': '0'})
@@ -595,7 +595,6 @@ def get_connected_data_from_token(connected_token = ""):
coll_token = MYSY_GV.dbname['partnair_account']
tmp_val = coll_token.find_one({'token': str(connected_token), 'active': '1', 'locked': '0'})
-
return True, tmp_val
except Exception as e: