|
|
|
@ -1,11 +1,9 @@
|
|
|
|
|
from flask import redirect, url_for
|
|
|
|
|
from flask_wtf import FlaskForm
|
|
|
|
|
from flask_wtf.file import FileAllowed
|
|
|
|
|
from wtforms import StringField, SubmitField, FileField, TextAreaField, RadioField, SelectMultipleField, widgets, FieldList, FormField, HiddenField
|
|
|
|
|
from wtforms.validators import DataRequired, Regexp, Optional, ValidationError
|
|
|
|
|
from wtforms import StringField, SubmitField, FileField, RadioField, widgets, FieldList, FormField, HiddenField
|
|
|
|
|
from wtforms.validators import DataRequired, Optional
|
|
|
|
|
from wtforms_alchemy import model_form_factory, ClassMap
|
|
|
|
|
from wtforms_alchemy.fields import QuerySelectMultipleField
|
|
|
|
|
from sqlalchemy_utils import ChoiceType
|
|
|
|
|
from app import db
|
|
|
|
|
import app.models as models
|
|
|
|
|
|
|
|
|
@ -49,27 +47,26 @@ class AccueilForm(FlaskForm):
|
|
|
|
|
importerJSON = SubmitField("ImporterJSON")
|
|
|
|
|
importerYAML = SubmitField("ImporterYAML")
|
|
|
|
|
|
|
|
|
|
def exportJSON(self):
|
|
|
|
|
def ListRef(self):
|
|
|
|
|
result = {"semestres": [], "competences": [], "acs": [], "pns": [], "saes": [], "coefsaes": [], "ressources": [], "coefressources": []}
|
|
|
|
|
for key in result.keys():
|
|
|
|
|
model = getattr(models, categorie_to_model[key])
|
|
|
|
|
for ref in model.query.all():
|
|
|
|
|
result[key].append(ref.export())
|
|
|
|
|
return result
|
|
|
|
|
|
|
|
|
|
def exportJSON(self):
|
|
|
|
|
result = self.ListRef()
|
|
|
|
|
fichier = REPERTOIRE_EXPORT + "referentiels" + ".json"
|
|
|
|
|
with open(fichier, "w", encoding="utf8") as fid:
|
|
|
|
|
json.dump(result, fid, cls=CustomEncoder, indent=4)
|
|
|
|
|
|
|
|
|
|
def exportYAML(self):
|
|
|
|
|
result = {"semestres": [], "competences": [], "acs": [], "pns": [], "saes": [], "coefsaes": [], "ressources": [], "coefressources": []}
|
|
|
|
|
for key in result.keys():
|
|
|
|
|
model = getattr(models, categorie_to_model[key])
|
|
|
|
|
for ref in model.query.all():
|
|
|
|
|
result[key].append(ref.export())
|
|
|
|
|
result = self.ListRef()
|
|
|
|
|
fichier = REPERTOIRE_EXPORT + "referentiels" + ".yml"
|
|
|
|
|
with open(fichier, "w", encoding="utf8") as fid:
|
|
|
|
|
yaml.dump(yaml.safe_load(json.dumps(result, cls=CustomEncoder)), fid, indent=4)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class CoefForm(FlaskForm):
|
|
|
|
|
objetformation = HiddenField("Objet de formation")
|
|
|
|
|
coef = StringField("Coef")
|
|
|
|
@ -138,7 +135,6 @@ class Form(ModelForm):
|
|
|
|
|
fichier = REPERTOIRE_EXPORT + self.code.data + ".yml"
|
|
|
|
|
with open(fichier, "w", encoding="utf8") as fid:
|
|
|
|
|
fid.write(yaml.dump(output))
|
|
|
|
|
print(yaml.dump(output))
|
|
|
|
|
|
|
|
|
|
def supprimerRef(self):
|
|
|
|
|
if self.referentiel.data == None:
|
|
|
|
@ -168,7 +164,6 @@ class PNForm(Form):
|
|
|
|
|
|
|
|
|
|
type = RadioField("Type", choices=["1","2","3"])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ACForm(Form):
|
|
|
|
|
regex = "^AC\d{4}$"
|
|
|
|
|
|
|
|
|
|