13/05/23 - 17h
parent
1c9be3861e
commit
0b79324237
|
@ -1,10 +1,12 @@
|
|||
<?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/23 - 21h">
|
||||
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="12/05/23 - 19h">
|
||||
<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$/lms_chamilo/mysy_lms.py" beforeDir="false" afterPath="$PROJECT_DIR$/lms_chamilo/mysy_lms.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/prj_common.py" beforeDir="false" afterPath="$PROJECT_DIR$/prj_common.py" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
|
@ -180,7 +182,14 @@
|
|||
<option name="project" value="LOCAL" />
|
||||
<updated>1683317311856</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="18" />
|
||||
<task id="LOCAL-00018" summary="12/05/23 - 19h">
|
||||
<created>1683911749819</created>
|
||||
<option name="number" value="00018" />
|
||||
<option name="presentableId" value="LOCAL-00018" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1683911749819</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="19" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="Vcs.Log.Tabs.Properties">
|
||||
|
@ -210,6 +219,7 @@
|
|||
<MESSAGE value="28/04/23 - 21h" />
|
||||
<MESSAGE value="29/04/23 - 21h" />
|
||||
<MESSAGE value="05/05/23 - 21h" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="05/05/23 - 21h" />
|
||||
<MESSAGE value="12/05/23 - 19h" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="12/05/23 - 19h" />
|
||||
</component>
|
||||
</project>
|
|
@ -1578835,3 +1578835,37 @@ INFO:root:2023-05-12 19:11:37.654842 : Security check : IP adresse '127.0.0.1'
|
|||
INFO:werkzeug:127.0.0.1 - - [12/May/2023 19:11:37] "[32mPOST /myclass/api/Get_Lms_Themes HTTP/1.1[0m" 308 -
|
||||
INFO:root:2023-05-12 19:11:37.667951 : Security check : IP adresse '127.0.0.1' connected
|
||||
INFO:werkzeug:127.0.0.1 - - [12/May/2023 19:11:37] "POST /myclass/api/Get_Lms_Themes/ HTTP/1.1" 200 -
|
||||
INFO:root:2023-05-13 13:39:10.142456 : ++++ ENVIRONNEMENT DEVELOPPEMENT ++++
|
||||
INFO:root:2023-05-13 13:39:10.143477 : ++ DATABASE mongodb://localhost:27017/cherifdb_dev ++
|
||||
INFO:root:2023-05-13 13:39:10.143477 : ++ DBNAME Database(MongoClient(host=['localhost:27017'], document_class=dict, tz_aware=False, connect=True), 'cherifdb_dev') ++
|
||||
INFO:root:2023-05-13 13:39:10.143477 : ++ FLASK PORT 5001 ++
|
||||
INFO:root:2023-05-13 13:39:10.143477 : ++ LMS_BAS_URL mysy-training.fr/ ++
|
||||
INFO:werkzeug:[31m[1mWARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.[0m
|
||||
* Running on http://localhost:5001
|
||||
INFO:werkzeug:[33mPress CTRL+C to quit[0m
|
||||
INFO:werkzeug: * Restarting with stat
|
||||
INFO:root:2023-05-13 13:39:20.483121 : ++++ ENVIRONNEMENT DEVELOPPEMENT ++++
|
||||
INFO:root:2023-05-13 13:39:20.483121 : ++ DATABASE mongodb://localhost:27017/cherifdb_dev ++
|
||||
INFO:root:2023-05-13 13:39:20.483121 : ++ DBNAME Database(MongoClient(host=['localhost:27017'], document_class=dict, tz_aware=False, connect=True), 'cherifdb_dev') ++
|
||||
INFO:root:2023-05-13 13:39:20.483121 : ++ FLASK PORT 5001 ++
|
||||
INFO:root:2023-05-13 13:39:20.483121 : ++ LMS_BAS_URL mysy-training.fr/ ++
|
||||
WARNING:werkzeug: * Debugger is active!
|
||||
INFO:werkzeug: * Debugger PIN: 868-184-516
|
||||
INFO:root:2023-05-13 14:16:31.047041 : ++++ ENVIRONNEMENT DEVELOPPEMENT ++++
|
||||
INFO:root:2023-05-13 14:16:31.047041 : ++ DATABASE mongodb://localhost:27017/cherifdb_dev ++
|
||||
INFO:root:2023-05-13 14:16:31.048042 : ++ DBNAME Database(MongoClient(host=['localhost:27017'], document_class=dict, tz_aware=False, connect=True), 'cherifdb_dev') ++
|
||||
INFO:root:2023-05-13 14:16:31.048042 : ++ FLASK PORT 5001 ++
|
||||
INFO:root:2023-05-13 14:16:31.048042 : ++ LMS_BAS_URL mysy-training.fr/ ++
|
||||
INFO:werkzeug:[31m[1mWARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.[0m
|
||||
* Running on http://localhost:5001
|
||||
INFO:werkzeug:[33mPress CTRL+C to quit[0m
|
||||
INFO:werkzeug: * Restarting with stat
|
||||
INFO:root:2023-05-13 14:16:44.853397 : ++++ ENVIRONNEMENT DEVELOPPEMENT ++++
|
||||
INFO:root:2023-05-13 14:16:44.853397 : ++ DATABASE mongodb://localhost:27017/cherifdb_dev ++
|
||||
INFO:root:2023-05-13 14:16:44.853397 : ++ DBNAME Database(MongoClient(host=['localhost:27017'], document_class=dict, tz_aware=False, connect=True), 'cherifdb_dev') ++
|
||||
INFO:root:2023-05-13 14:16:44.853397 : ++ FLASK PORT 5001 ++
|
||||
INFO:root:2023-05-13 14:16:44.853397 : ++ LMS_BAS_URL mysy-training.fr/ ++
|
||||
WARNING:werkzeug: * Debugger is active!
|
||||
INFO:werkzeug: * Debugger PIN: 868-184-516
|
||||
INFO:werkzeug: * Detected change in 'C:\\Users\\billa\\Documents\\myclass.com\\Siteweb\\Production\\Ela_back\\Back_Office\\lms_chamilo\\mysy_lms.py', reloading
|
||||
INFO:werkzeug: * Restarting with stat
|
||||
|
|
|
@ -2642,13 +2642,6 @@ def Lms_Add_Logo_File(file=None, Folder=None, diction=None):
|
|||
return False, str(inspect.stack()[0][
|
||||
3]) + " - impossible de recuperer les données du partenaire",
|
||||
|
||||
# Recuperation des données du partenaire
|
||||
local_status, my_partner = mycommon.get_partner_data_from_recid(partner_recid)
|
||||
if (local_status is False):
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - impossible de recuperer les données du partenaire")
|
||||
return False, str(inspect.stack()[0][
|
||||
3]) + " - impossible de recuperer les données du partenaire"
|
||||
|
||||
lms_theme_name = ""
|
||||
if ("lms_theme_name" in my_partner.keys()):
|
||||
if my_partner['lms_theme_name']:
|
||||
|
@ -2744,13 +2737,6 @@ def Lms_Add_BG_File(file=None, Folder=None, diction=None):
|
|||
return False, str(inspect.stack()[0][
|
||||
3]) + " - impossible de recuperer les données du partenaire",
|
||||
|
||||
# Recuperation des données du partenaire
|
||||
local_status, my_partner = mycommon.get_partner_data_from_recid(partner_recid)
|
||||
if (local_status is False):
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - impossible de recuperer les données du partenaire")
|
||||
return False, str(inspect.stack()[0][
|
||||
3]) + " - impossible de recuperer les données du partenaire"
|
||||
|
||||
lms_theme_name = ""
|
||||
if ("lms_theme_name" in my_partner.keys()):
|
||||
if my_partner['lms_theme_name']:
|
||||
|
@ -2794,3 +2780,92 @@ def Lms_Add_BG_File(file=None, Folder=None, diction=None):
|
|||
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - Line : " + str(exc_tb.tb_lineno))
|
||||
return False, " Impossible de mettre à jour le logo "
|
||||
|
||||
|
||||
"""
|
||||
Cette fonction permet de créer et/ou publier une formation en partant depuis le lms.
|
||||
|
||||
Algorithme :
|
||||
Etape 1 :
|
||||
Depuis le lms, un bouton qui appelle le webservice en passant en argument
|
||||
- user.mysy_recid : ceci correspond au recid dans le moteur de recherche
|
||||
- le code de la formation, pour faire le lien et update plus tard.
|
||||
|
||||
Etape 2 :
|
||||
Dans mysy search (moteur), on se connecte dans le lms, pour collecter les infos et les dupliquer et publier dans mysy search
|
||||
|
||||
"""
|
||||
def Create_Update_Class_From_Lms(diction):
|
||||
try:
|
||||
'''
|
||||
# Verification que les champs reçus dans l'API sont bien dans la liste des champs autorisés
|
||||
# Cela evite le cas ou une entité tierce ajouter les valeurs inconnu dans l'API
|
||||
# Ici on doit mettre tous les champs possible (obligatoire ou non) de la BDD dans la liste
|
||||
# field_list.
|
||||
'''
|
||||
field_list = ['lms_mysy_recid', 'lms_class_code', 'lms_class_id']
|
||||
incom_keys = diction.keys()
|
||||
for val in incom_keys:
|
||||
if val not in field_list:
|
||||
mycommon.myprint(str(
|
||||
inspect.stack()[0][3]) + " Le champ '" + val + "' n'existe pas, mise à jour logo lms annulée")
|
||||
return False, " Les informations fournies sont incorrecte",
|
||||
|
||||
'''
|
||||
Une fois qu'on a controlé que toutes les clés mise dans l'API sont correcte. etape precedente,
|
||||
On controle que les champs obligatoires sont presents dans la liste
|
||||
'''
|
||||
field_list_obligatoire = ['lms_mysy_recid', 'lms_class_code', 'lms_class_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 incorrecte",
|
||||
|
||||
lms_mysy_recid = ""
|
||||
if ("lms_mysy_recid" in diction.keys()):
|
||||
if diction['lms_mysy_recid']:
|
||||
lms_mysy_recid = diction['lms_mysy_recid']
|
||||
|
||||
lms_class_code = ""
|
||||
if ("lms_class_code" in diction.keys()):
|
||||
if diction['lms_class_code']:
|
||||
lms_class_code = diction['lms_class_code']
|
||||
|
||||
lms_class_id = ""
|
||||
if ("lms_class_id" in diction.keys()):
|
||||
if diction['lms_class_id']:
|
||||
lms_class_id = diction['lms_class_id']
|
||||
|
||||
# Recuperation des données du partenaire
|
||||
local_status, my_partner = mycommon.get_partner_data_from_recid(lms_mysy_recid)
|
||||
if (local_status is False):
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - impossible de recuperer les données du partenaire")
|
||||
#return False, str(inspect.stack()[0][3]) + " - impossible de recuperer les données du partenaire",
|
||||
|
||||
|
||||
"""
|
||||
Recuperation des données de la formation dans le LMS
|
||||
"""
|
||||
conn = mariadb.connect(
|
||||
user=MYSY_GV.MYSY_MARIADB_USER,
|
||||
password=MYSY_GV.MYSY_MARIADB_USER_PASS,
|
||||
host=MYSY_GV.MYSY_MARIADB_HOST,
|
||||
port=MYSY_GV.MYSY_MARIADB_PORT,
|
||||
database=MYSY_GV.MYSY_LMS_BDD
|
||||
)
|
||||
|
||||
cur = conn.cursor()
|
||||
myquery = "SELECT * FROM c_course_description WHERE c_id='" + str(lms_class_id)+"' "
|
||||
print(" ### myquery = ", myquery)
|
||||
cur.execute(myquery)
|
||||
for courses_info in cur:
|
||||
print(" ### les information de la formation : ", str(courses_info))
|
||||
conn.close()
|
||||
|
||||
|
||||
return True, " La formation a bien été créée/mise à jour dans le moteur de recherche"
|
||||
|
||||
except Exception as e:
|
||||
exc_type, exc_obj, exc_tb = sys.exc_info()
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - Line : " + str(exc_tb.tb_lineno))
|
||||
return False, " Impossible de créer ou mettre à jour la formation dans le moteur de recherche "
|
||||
|
|
12
main.py
12
main.py
|
@ -2936,7 +2936,17 @@ def test_connexion_php_myadmin():
|
|||
return jsonify(status=localStatus, message=message)
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Cette API permet de créer et mettre à jour une formation du LMS vers le Search (de chamilo ver mysy)
|
||||
"""
|
||||
@app.route('/myclass/api/Create_Update_Class_From_Lms/', methods=['POST','GET'])
|
||||
@crossdomain(origin='*')
|
||||
def Create_Update_Class_From_Lms():
|
||||
# On recupere le corps (payload) de la requete
|
||||
payload = request.form.to_dict()
|
||||
print(" ### Create_Update_Class_From_Lms : payload = ",payload)
|
||||
localStatus, message = mysy_lms.Create_Update_Class_From_Lms(payload)
|
||||
return jsonify(status=localStatus, message=message)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
@ -171,10 +171,10 @@ def Upload_Save_IMG_PNG_File(file=None, Folder=None):
|
|||
myprint(str(inspect.stack()[0][3]) + " - : le ficier "+str(file.filename)+ ". L'extention '"+str(basename2[1])+"' n'est pas un fichier image. Les extentions autorisées sont :"+str(MYSY_GV.IMG_FORMAT))
|
||||
return False, None
|
||||
|
||||
|
||||
new_basename2 = re.sub(r'[^a-zA-Z0-9]', '', str(basename2[0]))
|
||||
|
||||
timestr = time.strftime("%Y%m%d%H%M%S")
|
||||
local_base_name = str(basename2[0]).replace('(', '').replace(')', '').replace(' ', '')
|
||||
local_base_name = str(new_basename2).replace('(', '').replace(')', '').replace(' ', '')
|
||||
new_file_name = str(local_base_name) + "_" + str(timestr) + "." + str(basename2[1])
|
||||
file.filename = new_file_name
|
||||
file.save(os.path.join(str(Folder), secure_filename(file.filename))) # t
|
||||
|
@ -417,8 +417,18 @@ def get_parnter_recid_from_token(token = ""):
|
|||
return False
|
||||
|
||||
coll_token = MYSY_GV.dbname['partner_token']
|
||||
tmp_val = coll_token.find({'token': str(token), 'valide': '1', 'locked':'0'})
|
||||
user_recid = tmp_val[0]['recid']
|
||||
tmp_val = coll_token.find_one({'token': str(token), 'valide': '1', 'locked':'0'})
|
||||
|
||||
if( tmp_val is None ):
|
||||
return False
|
||||
|
||||
if ("recid" not in tmp_val.keys()):
|
||||
return False
|
||||
|
||||
if( not tmp_val['recid'] ):
|
||||
return False
|
||||
|
||||
user_recid = tmp_val['recid']
|
||||
return user_recid
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue