13/11/2023 - 22h30

master
cherif 2023-11-13 21:58:36 +01:00
parent fa3f2163cf
commit cf62d00da9
5 changed files with 1672 additions and 13 deletions

View File

@ -1,11 +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="11/11/2023 - 23h">
<list default="true" id="c6d0259a-16e1-410d-91a1-830590ee2a08" name="Changes" comment="13/11/2023 - 12h30">
<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$/agenda.py" beforeDir="false" afterPath="$PROJECT_DIR$/agenda.py" 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$/ressources_humaines.py" beforeDir="false" afterPath="$PROJECT_DIR$/ressources_humaines.py" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -75,13 +76,6 @@
<option name="presentableId" value="Default" />
<updated>1680804787304</updated>
</task>
<task id="LOCAL-00096" summary="05/09/23 - 20h30">
<created>1693939153001</created>
<option name="number" value="00096" />
<option name="presentableId" value="LOCAL-00096" />
<option name="project" value="LOCAL" />
<updated>1693939153001</updated>
</task>
<task id="LOCAL-00097" summary="06/09/2023 - 11h">
<created>1693991026076</created>
<option name="number" value="00097" />
@ -418,7 +412,14 @@
<option name="project" value="LOCAL" />
<updated>1699740510546</updated>
</task>
<option name="localTasksCounter" value="145" />
<task id="LOCAL-00145" summary="13/11/2023 - 12h30">
<created>1699876222238</created>
<option name="number" value="00145" />
<option name="presentableId" value="LOCAL-00145" />
<option name="project" value="LOCAL" />
<updated>1699876222242</updated>
</task>
<option name="localTasksCounter" value="146" />
<servers />
</component>
<component name="Vcs.Log.Tabs.Properties">
@ -433,7 +434,6 @@
</option>
</component>
<component name="VcsManagerConfiguration">
<MESSAGE value="30/09/2023 - 19h" />
<MESSAGE value="01/10/2023 - 23h" />
<MESSAGE value="02/10/2023 - 11h" />
<MESSAGE value="02/10/2023 - 13h30" />
@ -458,6 +458,7 @@
<MESSAGE value="sdds" />
<MESSAGE value="11/11/2023 - 17h" />
<MESSAGE value="11/11/2023 - 23h" />
<option name="LAST_COMMIT_MESSAGE" value="11/11/2023 - 23h" />
<MESSAGE value="13/11/2023 - 12h30" />
<option name="LAST_COMMIT_MESSAGE" value="13/11/2023 - 12h30" />
</component>
</project>

File diff suppressed because it is too large Load Diff

View File

@ -2336,7 +2336,7 @@ def get_partner_class(diction):
RetObject.append(JSONEncoder().encode(user))
val_tmp = val_tmp + 1
print("##### str(RetObject) = ", str(RetObject))
return True, RetObject
@ -4382,3 +4382,198 @@ def get_Class_From_Url(diction):
"""
Fonction de duplication d'une formation en prenant l'_id
"""
def Duplicate_Class(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
# Verification de l'existence de la formation
is_Class_Valide = MYSY_GV.dbname["myclass"].count_documents({'_id':ObjectId(str(diction['_id'])),
'locked':'0', 'valide':'1',
'partner_owner_recid':my_partner['recid']})
if( is_Class_Valide <= 0 ):
mycommon.myprint(
str(inspect.stack()[0][3]) + " - L'identification de la formation n'est pas valide ")
return False, " L'identification de la formation n'est pas valide"
class_to_duplicate = MYSY_GV.dbname["myclass"].find_one({'_id':ObjectId(str(diction['_id'])),
'locked':'0', 'valide':'1',
'partner_owner_recid':my_partner['recid']},
{'_id': 0}
)
new_title = str(class_to_duplicate['title']) + "_dup"
new_internal_code = str(class_to_duplicate['internal_code'])+"_dup"
new_internal_url = str(class_to_duplicate['internal_url'])+"_dup"
new_external_code = str(class_to_duplicate['external_code'])+"_dup"
new_class = class_to_duplicate
new_class['title'] = new_title
new_class['internal_code'] = new_internal_code
new_class['internal_url'] = new_internal_url
new_class['external_code'] = new_external_code
inserted = MYSY_GV.dbname['myclass'].insert_one(new_class)
if (not inserted.inserted_id):
mycommon.myprint(
" Impossible de dupliquer la formation")
return False, " Impossible de dupliquer la formation "
# Indexation Title de la nouvelle formation ajoutée
training_to_index_title = {}
training_to_index_title['internal_url'] = new_external_code['internal_url']
training_to_index_title['reindex_all'] = '0'
training_to_index_title['partner_owner_recid'] = str(my_partner['recid'])
eibdd.ela_index_given_classes_title(training_to_index_title)
# Indexation Title des mots clées
if (str(new_external_code['mots_cle']).strip() != ""):
eibdd.ela_index_class_key_word(new_external_code['external_code'], "keyword", str(my_partner['recid']))
return True, " La formation a été dupliqué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 dupliquer la formation"
"""
Fonction de duplication d'une formation en prenant l'internal_url
"""
def Duplicate_Class_from_internal_url(diction):
try:
diction = mycommon.strip_dictionary(diction)
"""
Verification des input acceptés
"""
field_list = ['token', 'internal_url']
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', 'internal_url',]
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
# Verification de l'existence de la formation
is_Class_Valide = MYSY_GV.dbname["myclass"].count_documents({'internal_url':str(diction['internal_url']),
'locked':'0', 'valide':'1',
'partner_owner_recid':my_partner['recid']})
if( is_Class_Valide <= 0 ):
mycommon.myprint(
str(inspect.stack()[0][3]) + " - L'identification de la formation n'est pas valide ")
return False, " L'identification de la formation n'est pas valide"
class_to_duplicate = MYSY_GV.dbname["myclass"].find_one({'internal_url':str(diction['internal_url']),
'locked':'0', 'valide':'1',
'partner_owner_recid':my_partner['recid']},
{'_id':0}
)
new_title = str(class_to_duplicate['title']) + "_dup"
new_internal_code = str(class_to_duplicate['internal_code'])+"_dup"
new_internal_url = str(class_to_duplicate['internal_url'])+"_dup"
new_external_code = str(class_to_duplicate['external_code'])+"_dup"
new_class = class_to_duplicate
new_class['title'] = new_title
new_class['internal_code'] = new_internal_code
new_class['internal_url'] = new_internal_url
new_class['external_code'] = new_external_code
inserted = MYSY_GV.dbname['myclass'].insert_one(new_class)
if (not inserted.inserted_id):
mycommon.myprint(
" Impossible de dupliquer la formation")
return False, " Impossible de dupliquer la formation "
# Indexation Title de la nouvelle formation ajoutée
training_to_index_title = {}
training_to_index_title['internal_url'] = new_external_code['internal_url']
training_to_index_title['reindex_all'] = '0'
training_to_index_title['partner_owner_recid'] = str(my_partner['recid'])
eibdd.ela_index_given_classes_title(training_to_index_title)
# Indexation Title des mots clées
if (str(new_external_code['mots_cle']).strip() != ""):
eibdd.ela_index_class_key_word(new_external_code['external_code'], "keyword", str(my_partner['recid']))
return True, " La formation a été dupliqué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 dupliquer la formation"

27
main.py
View File

@ -2252,6 +2252,33 @@ def get_Class_From_Url():
return jsonify(status=localStatus, message=message )
"""
API pour dubliquer une formation en partant de l'_id
"""
@app.route('/myclass/api/Duplicate_Class/', methods=['POST','GET'])
@crossdomain(origin='*')
def Duplicate_Class():
# On recupere le corps (payload) de la requete
payload = mycommon.strip_dictionary (request.form.to_dict())
print(" ### Duplicate_Class : payload = ",str(payload))
localStatus, message= cm.Duplicate_Class(payload)
return jsonify(status=localStatus, message=message )
"""
API pour dubliquer une formation en partant de l'internal_url
"""
@app.route('/myclass/api/Duplicate_Class_from_internal_url/', methods=['POST','GET'])
@crossdomain(origin='*')
def Duplicate_Class_from_internal_url():
# On recupere le corps (payload) de la requete
payload = mycommon.strip_dictionary (request.form.to_dict())
print(" ### Duplicate_Class_from_internal_url : payload = ",str(payload))
localStatus, message= cm.Duplicate_Class_from_internal_url(payload)
return jsonify(status=localStatus, message=message )
"""
API d'envoi de la liste d'emargement

View File

@ -3070,6 +3070,7 @@ def Add_Update_Employee_Login_Pass(diction):
mydata['mysy_lms_user_id'] = str(my_partner['mysy_lms_user_id'])
mydata['recid'] = str(my_partner['recid'])
mydata['is_partner_admin_account'] = '0'
mydata['ispending'] = '0'
mydata['active'] = '1'