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",
"coef_rcue",
"color",
"niveau_competence_id",
),
sortkey="numero",
input_formators={

View File

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