Clonage formations. Close #444

This commit is contained in:
Emmanuel Viennet 2022-07-13 19:23:55 +02:00
parent 48e31b5f39
commit fb9571dde2
2 changed files with 7 additions and 4 deletions

View File

@ -86,6 +86,7 @@ _ueEditor = ndb.EditableTable(
"coefficient", "coefficient",
"coef_rcue", "coef_rcue",
"color", "color",
"niveau_competence_id",
), ),
sortkey="numero", sortkey="numero",
input_formators={ input_formators={

View File

@ -31,7 +31,7 @@ from operator import itemgetter
import xml.dom.minidom import xml.dom.minidom
import flask import flask
from flask import g, url_for, request from flask import flash, g, url_for, request
from flask_login import current_user from flask_login import current_user
import app.scodoc.sco_utils as scu import app.scodoc.sco_utils as scu
@ -65,6 +65,7 @@ _formationEditor = ndb.EditableTable(
"formation_code", "formation_code",
"type_parcours", "type_parcours",
"code_specialite", "code_specialite",
"referentiel_competence_id",
), ),
filter_dept=True, filter_dept=True,
sortkey="acronyme", sortkey="acronyme",
@ -104,7 +105,7 @@ def formation_export(
"""Get a formation, with UE, matieres, modules """Get a formation, with UE, matieres, modules
in desired format in desired format
""" """
formation = Formation.query.get_or_404(formation_id) formation: Formation = Formation.query.get_or_404(formation_id)
F = formation.to_dict() F = formation.to_dict()
selector = {"formation_id": formation_id} selector = {"formation_id": formation_id}
if not export_external_ues: if not export_external_ues:
@ -424,17 +425,18 @@ def formation_list_table(formation_id=None, args={}):
def formation_create_new_version(formation_id, redirect=True): def formation_create_new_version(formation_id, redirect=True):
"duplicate formation, with new version number" "duplicate formation, with new version number"
formation = Formation.query.get_or_404(formation_id)
resp = formation_export(formation_id, export_ids=True, format="xml") resp = formation_export(formation_id, export_ids=True, format="xml")
xml_data = resp.get_data(as_text=True) xml_data = resp.get_data(as_text=True)
new_id, modules_old2new, ues_old2new = formation_import_xml(xml_data) new_id, modules_old2new, ues_old2new = formation_import_xml(xml_data)
# news # news
F = formation_list(args={"formation_id": new_id})[0]
ScolarNews.add( ScolarNews.add(
typ=ScolarNews.NEWS_FORM, typ=ScolarNews.NEWS_FORM,
obj=new_id, obj=new_id,
text="Nouvelle version de la formation %(acronyme)s" % F, text=f"Nouvelle version de la formation {formation.acronyme}",
) )
if redirect: if redirect:
flash("Nouvelle version !")
return flask.redirect( return flask.redirect(
url_for( url_for(
"notes.ue_table", "notes.ue_table",