15/04/23 - 22h
parent
712d69d663
commit
1b8bec55bc
|
@ -1,11 +1,9 @@
|
|||
<?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="14/04/23 - 23h">
|
||||
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="15/04/23 - 14h">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/GlobalVariable.py" beforeDir="false" afterPath="$PROJECT_DIR$/GlobalVariable.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Log/log_file.log" beforeDir="false" afterPath="$PROJECT_DIR$/Log/log_file.log" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/email_mgt.py" beforeDir="false" afterPath="$PROJECT_DIR$/email_mgt.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/lms_chamilo/mysy_lms.py" beforeDir="false" afterPath="$PROJECT_DIR$/lms_chamilo/mysy_lms.py" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
|
@ -98,7 +96,14 @@
|
|||
<option name="project" value="LOCAL" />
|
||||
<updated>1681505500999</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="6" />
|
||||
<task id="LOCAL-00006" summary="15/04/23 - 14h">
|
||||
<created>1681566348906</created>
|
||||
<option name="number" value="00006" />
|
||||
<option name="presentableId" value="LOCAL-00006" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1681566348906</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="7" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="Vcs.Log.Tabs.Properties">
|
||||
|
@ -117,6 +122,7 @@
|
|||
<MESSAGE value="07/04/23 - 11h" />
|
||||
<MESSAGE value="10/04/23 - 17h" />
|
||||
<MESSAGE value="14/04/23 - 23h" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="14/04/23 - 23h" />
|
||||
<MESSAGE value="15/04/23 - 14h" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="15/04/23 - 14h" />
|
||||
</component>
|
||||
</project>
|
2050
Log/log_file.log
2050
Log/log_file.log
File diff suppressed because one or more lines are too long
|
@ -300,16 +300,21 @@ def Create_MySy_LMS_User(diction):
|
|||
else:
|
||||
"""
|
||||
/!\ On va l'ajouter une 2ieme fois si le compte partenaire necessite la creation d'un nouvel url.
|
||||
:!\ : on ajoute aussi le user ad
|
||||
/!\ : on ajoute aussi le user admin qui a comme user_id = 1
|
||||
"""
|
||||
virutal_host_id = local_virtualhost_id
|
||||
virutal_host_url = local_virtualhost_full_url
|
||||
my_query_access_url_rel_user = "INSERT INTO access_url_rel_user SET access_url_id='"+ str(virutal_host_id)+"' , user_id='" + str(new_lms_user_id) + "' "
|
||||
my_query_access_url_rel_user_admin = "INSERT INTO access_url_rel_user SET access_url_id='" + str(
|
||||
virutal_host_id) + "' , user_id='1' "
|
||||
|
||||
print(" ### my_query_access_url_rel_user = ", my_query_access_url_rel_user)
|
||||
print(" ### my_query_access_url_rel_user_admin = ", my_query_access_url_rel_user)
|
||||
try:
|
||||
|
||||
# cur.execute("INSERT INTO employees (first_name,last_name) VALUES (?, ?)", ("Maria", "DB"))
|
||||
cur.execute(my_query_access_url_rel_user)
|
||||
cur.execute(my_query_access_url_rel_user_admin)
|
||||
except mariadb.Error as e:
|
||||
# print(f"Error: {e}")
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " WARNING - impossible d'ajouter le user '" + str(
|
||||
|
@ -604,8 +609,8 @@ def Disable_MySy_LMS_User(diction):
|
|||
cur.execute(my_query)
|
||||
except mariadb.Error as e:
|
||||
# print(f"Error: {e}")
|
||||
mycommon.myprint(" Impossible de créer l'utilisateur LMS " + str({e}))
|
||||
return False, "Impossible de créer l'utilisateur LMS " + str({e})
|
||||
mycommon.myprint(" Impossible de desactiver l'utilisateur LMS " + str({e}))
|
||||
return False, "Impossible de desactiver l'utilisateur LMS " + str({e})
|
||||
|
||||
conn.commit()
|
||||
|
||||
|
@ -644,6 +649,122 @@ def Disable_MySy_LMS_User(diction):
|
|||
mycommon.myprint(str(inspect.stack()[0][3]) + " -" + str(e) + " - Line : " + str(exc_tb.tb_lineno))
|
||||
return False, " Impossible de desactiver le compte"
|
||||
|
||||
"""
|
||||
Cette fonction desactive le virtualHost / url d'un compte partenaire s'il en a
|
||||
"""
|
||||
def Disable_MySy_LMS_User_VirtualHost_Url(diction):
|
||||
try:
|
||||
|
||||
field_list_obligatoire = ['lms_virtualhost_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, " Toutes les informations obligatoire n'ont pas été fournies"
|
||||
|
||||
# recuperation des paramettre
|
||||
lms_virtualhost_id = ""
|
||||
if ("lms_virtualhost_id" in diction.keys()):
|
||||
if diction['lms_virtualhost_id']:
|
||||
lms_virtualhost_id = diction['lms_virtualhost_id']
|
||||
|
||||
updated_at = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
||||
|
||||
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()
|
||||
cur2 = conn.cursor()
|
||||
|
||||
# Desactivation du compte :
|
||||
# Reactivation du compte dans chamilo
|
||||
# insert information
|
||||
my_query = "UPDATE access_url SET active='0' WHERE id='" + str(lms_virtualhost_id) + "' ;"
|
||||
try:
|
||||
#print(" ### my_query update = ", my_query)
|
||||
# cur.execute("INSERT INTO employees (first_name,last_name) VALUES (?, ?)", ("Maria", "DB"))
|
||||
cur.execute(my_query)
|
||||
except mariadb.Error as e:
|
||||
# print(f"Error: {e}")
|
||||
mycommon.myprint(" Impossible de desactiver le virtualhost/url " + str({e}))
|
||||
return False, "Impossible de desactiver le virtualhost/url " + str({e})
|
||||
|
||||
conn.commit()
|
||||
|
||||
|
||||
conn.close()
|
||||
|
||||
return True, " Le virtualHost/url a été correctement desactive"
|
||||
|
||||
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 desactiver le virtualhost/url "
|
||||
|
||||
|
||||
"""
|
||||
Cette fonction Reactive le virtualHost / url d'un compte partenaire s'il en a
|
||||
"""
|
||||
def Enable_MySy_LMS_User_VirtualHost_Url(diction):
|
||||
try:
|
||||
|
||||
field_list_obligatoire = ['lms_virtualhost_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, " Toutes les informations obligatoire n'ont pas été fournies"
|
||||
|
||||
# recuperation des paramettre
|
||||
lms_virtualhost_id = ""
|
||||
if ("lms_virtualhost_id" in diction.keys()):
|
||||
if diction['lms_virtualhost_id']:
|
||||
lms_virtualhost_id = diction['lms_virtualhost_id']
|
||||
|
||||
updated_at = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
||||
|
||||
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()
|
||||
cur2 = conn.cursor()
|
||||
|
||||
# Desactivation du compte :
|
||||
# Reactivation du compte dans chamilo
|
||||
# insert information
|
||||
my_query = "UPDATE access_url SET active='1' WHERE id='" + str(lms_virtualhost_id) + "' ;"
|
||||
try:
|
||||
#print(" ### my_query update = ", my_query)
|
||||
# cur.execute("INSERT INTO employees (first_name,last_name) VALUES (?, ?)", ("Maria", "DB"))
|
||||
cur.execute(my_query)
|
||||
except mariadb.Error as e:
|
||||
# print(f"Error: {e}")
|
||||
mycommon.myprint(" Impossible de desactiver le virtualhost/url " + str({e}))
|
||||
return False, "Impossible de desactiver le virtualhost/url " + str({e})
|
||||
|
||||
conn.commit()
|
||||
|
||||
|
||||
conn.close()
|
||||
|
||||
return True, " Le virtualHost/url a été correctement desactive"
|
||||
|
||||
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 desactiver le virtualhost/url "
|
||||
|
||||
|
||||
|
||||
"""
|
||||
Cette fonction permet de desactivier les formation d'un utilisateur
|
||||
|
@ -1096,6 +1217,18 @@ def Check_MySy_LMS_Account(diction):
|
|||
mycommon.myprint(str(inspect.stack()[0][3]) + " - Impossible de reactiver le compte LSM ")
|
||||
return False, str(inspect.stack()[0][3]) + " - Impossible de reactiver le compte LSM "
|
||||
|
||||
# Reactivation du virtualHost s'il en a 1
|
||||
if( "lms_virtualhost_id" in my_partner.keys() ) :
|
||||
if( my_partner['lms_virtualhost_id'] ):
|
||||
new_diction = {}
|
||||
new_diction['lms_virtualhost_id'] = my_partner['lms_virtualhost_id']
|
||||
print(" ### Ractivation du virtualHost/url lms_virtualhost_id = ", my_partner['lms_virtualhost_id'])
|
||||
local_status, local_retval = Enable_MySy_LMS_User_VirtualHost_Url(new_diction)
|
||||
if (local_status is False):
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - Impossible de reactiver le virtualHost/url du compte ")
|
||||
return False, str(inspect.stack()[0][3]) + " - Impossible de reactiver le virtualHost/url du compte "
|
||||
|
||||
|
||||
# Mise à jour des autres info.
|
||||
new_diction = {}
|
||||
new_diction['token'] = my_partner['token']
|
||||
|
@ -1119,19 +1252,24 @@ def Check_MySy_LMS_Account(diction):
|
|||
cas il faut le desactiver
|
||||
"""
|
||||
if (mysy_lms_user_id.strip() != ""):
|
||||
print(" ### Ce partenaire a deja un compte LMS, il faut donc le desactiver ")
|
||||
print(" ### Ce partenaire a deja un compte LMS, il faut donc le desactiver, PUIS desactiver son virtualhost s'il en a ")
|
||||
"""
|
||||
Ce partenaire a deja un compte LMS, c'est donc une mise à jour qu'il faut faire
|
||||
"""
|
||||
new_diction = {}
|
||||
|
||||
new_diction['lms_user_id'] = my_partner['mysy_lms_user_id']
|
||||
|
||||
local_status, local_retval = Disable_MySy_LMS_User(new_diction)
|
||||
if (local_status is False):
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - Impossible de desactiver le compte LSM ")
|
||||
return False, str(inspect.stack()[0][3]) + " - Impossible de desactiver le compte LSM "
|
||||
|
||||
new_diction = {}
|
||||
new_diction['lms_virtualhost_id'] = my_partner['lms_virtualhost_id']
|
||||
local_status, local_retval = Disable_MySy_LMS_User_VirtualHost_Url(new_diction)
|
||||
if (local_status is False):
|
||||
mycommon.myprint(str(inspect.stack()[0][3]) + " - WARNING Impossible de desactiver le virtualHost/url ")
|
||||
|
||||
|
||||
|
||||
return True, " Creation/mise à jour du compte LSM ok"
|
||||
|
||||
|
@ -1787,6 +1925,7 @@ Elle verifie si l'abonnement du partner necessite un LMS
|
|||
- lms_user_id
|
||||
- lms_userid (login)
|
||||
- lms pwd
|
||||
- lms_virtualhost_url
|
||||
"""
|
||||
|
||||
def LMS_Get_Partner_Data(diction):
|
||||
|
@ -1859,12 +1998,14 @@ def LMS_Get_Partner_Data(diction):
|
|||
lms_user_name = ""
|
||||
lms_pwd_mask = ""
|
||||
lms_part_recid = ""
|
||||
lms_virtualhost_url = ""
|
||||
lms_url = ""
|
||||
if( lms_account == "1"):
|
||||
lms_user_id = my_partner['mysy_lms_user_id']
|
||||
lms_user_name = my_partner['email']
|
||||
lms_pwd_mask = my_partner['pwd']
|
||||
lms_part_recid = my_partner['recid']
|
||||
lms_virtualhost_url = my_partner['lms_virtualhost_url']
|
||||
lms_url = MYSY_GV.MYSY_LMS_URL
|
||||
|
||||
"""
|
||||
|
@ -1888,6 +2029,7 @@ def LMS_Get_Partner_Data(diction):
|
|||
val_tmp['lms_user_name'] = lms_user_name
|
||||
val_tmp['lms_pwd_mask'] = lms_pwd_mask
|
||||
val_tmp['lms_part_recid'] = lms_part_recid
|
||||
val_tmp['lms_virtualhost_url'] = lms_virtualhost_url
|
||||
val_tmp['lms_url'] = lms_url
|
||||
|
||||
insertObject = []
|
||||
|
|
Loading…
Reference in New Issue