forked from eric.li/EditionPN
Implementation des fonctionnalité SQLAlchemy
This commit is contained in:
parent
92bb40d585
commit
e70b3e70f5
@ -14,6 +14,8 @@ if not os.path.exists(REPERTOIRE_YAML):
|
|||||||
|
|
||||||
class Form(FlaskForm):
|
class Form(FlaskForm):
|
||||||
|
|
||||||
|
sauvegarder = SubmitField("Sauvegarder")
|
||||||
|
charger = SubmitField("Charger")
|
||||||
exporter = SubmitField("Exporter")
|
exporter = SubmitField("Exporter")
|
||||||
fichier = FileField("Choisir fichier", validators=[FileAllowed(["yml"], "Fichier Yaml seulement!")])
|
fichier = FileField("Choisir fichier", validators=[FileAllowed(["yml"], "Fichier Yaml seulement!")])
|
||||||
importer = SubmitField("Importer")
|
importer = SubmitField("Importer")
|
||||||
@ -99,7 +101,7 @@ def form_export(form):
|
|||||||
""" Si le formulaire est valide => exporte dans un fichier yaml avec les informations du formulaire """
|
""" Si le formulaire est valide => exporte dans un fichier yaml avec les informations du formulaire """
|
||||||
output = {}
|
output = {}
|
||||||
|
|
||||||
for categorie, valeur in list(form.data.items())[3:-1]:
|
for categorie, valeur in list(form.data.items())[5:-1]:
|
||||||
output[categorie] = valeur
|
output[categorie] = valeur
|
||||||
|
|
||||||
fichier = REPERTOIRE_YAML + form.code.data + ".yml"
|
fichier = REPERTOIRE_YAML + form.code.data + ".yml"
|
||||||
|
@ -5,7 +5,61 @@ class PN(db.Model):
|
|||||||
nom = db.Column(db.String(255))
|
nom = db.Column(db.String(255))
|
||||||
diminutif = db.Column(db.String(30))
|
diminutif = db.Column(db.String(30))
|
||||||
description = db.Column(db.Text())
|
description = db.Column(db.Text())
|
||||||
type = db.Column(db.Integer())
|
type = db.Column(db.String(1))
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "<PN {}>".format(self.code)
|
return "<PN {}>".format(self.code)
|
||||||
|
|
||||||
|
class AC(db.Model):
|
||||||
|
code = db.Column(db.String(6), primary_key = True)
|
||||||
|
titre = db.Column(db.String(255))
|
||||||
|
saes = db.Column(db.String(255))
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
return "<AC {}>".format(self.code)
|
||||||
|
|
||||||
|
class SAE(db.Model):
|
||||||
|
code = db.Column(db.String(5), primary_key = True)
|
||||||
|
titre = db.Column(db.String(255))
|
||||||
|
semestre = db.Column(db.String(255))
|
||||||
|
heures_encadrees = db.Column(db.String(3))
|
||||||
|
heures_tp = db.Column(db.String(3))
|
||||||
|
projet = db.Column(db.String(3))
|
||||||
|
description = db.Column(db.Text())
|
||||||
|
coef = db.Column(db.String(255))
|
||||||
|
acs = db.Column(db.String(255))
|
||||||
|
ressources = db.Column(db.String(255))
|
||||||
|
livrables = db.Column(db.Text())
|
||||||
|
motscles = db.Column(db.String(255))
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
return "<SAE {}>".format(self.code)
|
||||||
|
|
||||||
|
class Ressource(db.Model):
|
||||||
|
code = db.Column(db.String(4), primary_key = True)
|
||||||
|
nom = db.Column(db.String(255))
|
||||||
|
semestre = db.Column(db.String(255))
|
||||||
|
heures_formation = db.Column(db.String(3))
|
||||||
|
heures_tp = db.Column(db.String(3))
|
||||||
|
coef = db.Column(db.String(255))
|
||||||
|
acs = db.Column(db.String(255))
|
||||||
|
saes = db.Column(db.String(255))
|
||||||
|
prerequis = db.Column(db.String(255))
|
||||||
|
contexte = db.Column(db.Text())
|
||||||
|
contenu = db.Column(db.Text())
|
||||||
|
motscles = db.Column(db.String(255))
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
return "<Ressource {}>".format(self.code)
|
||||||
|
|
||||||
|
class Competence(db.Model):
|
||||||
|
code = db.Column(db.String(3), primary_key = True)
|
||||||
|
nom = db.Column(db.String(255))
|
||||||
|
diminutif = db.Column(db.String(30))
|
||||||
|
description = db.Column(db.Text())
|
||||||
|
composantes = db.Column(db.Text())
|
||||||
|
situations = db.Column(db.Text())
|
||||||
|
niveaux = db.Column(db.Text())
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
return "<Compétence {}>".format(self.code)
|
@ -1,7 +1,7 @@
|
|||||||
from flask import render_template, flash, redirect, url_for, request
|
from flask import render_template, flash, redirect, url_for, request
|
||||||
from app import app
|
from app import app, db
|
||||||
from app.forms import *
|
from app.forms import *
|
||||||
from app.models import PN
|
import app.models as models
|
||||||
|
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
@ -15,9 +15,16 @@ def PN():
|
|||||||
form = PNForm()
|
form = PNForm()
|
||||||
form_validation = form.validate_on_submit()
|
form_validation = form.validate_on_submit()
|
||||||
form = form_import(form)
|
form = form_import(form)
|
||||||
if form_validation and form.exporter.data:
|
if form_validation:
|
||||||
|
if form.exporter.data:
|
||||||
flash("Ajout du référentiel PN: {} ".format(form.code.data))
|
flash("Ajout du référentiel PN: {} ".format(form.code.data))
|
||||||
form_export(form)
|
form_export(form)
|
||||||
|
if form.sauvegarder.data:
|
||||||
|
if not "pn" in locals():
|
||||||
|
pn = models.PN()
|
||||||
|
form.populate_obj(pn)
|
||||||
|
db.session.add(pn)
|
||||||
|
db.session.commit()
|
||||||
return redirect(url_for("PN"))
|
return redirect(url_for("PN"))
|
||||||
return render_template("PN.html", form = form)
|
return render_template("PN.html", form = form)
|
||||||
|
|
||||||
@ -26,9 +33,15 @@ def AC():
|
|||||||
form = ACForm()
|
form = ACForm()
|
||||||
form_validation = form.validate_on_submit()
|
form_validation = form.validate_on_submit()
|
||||||
form = form_import(form)
|
form = form_import(form)
|
||||||
if form_validation and form.exporter.data:
|
if form_validation:
|
||||||
|
if form.exporter.data:
|
||||||
flash("Ajout du référentiel AC: {} ".format(form.code.data))
|
flash("Ajout du référentiel AC: {} ".format(form.code.data))
|
||||||
form_export(form)
|
form_export(form)
|
||||||
|
if not "ac" in locals():
|
||||||
|
ac = models.AC()
|
||||||
|
form.populate_obj(ac)
|
||||||
|
db.session.add(ac)
|
||||||
|
db.session.commit()
|
||||||
return redirect(url_for("AC"))
|
return redirect(url_for("AC"))
|
||||||
return render_template("AC.html", form = form)
|
return render_template("AC.html", form = form)
|
||||||
|
|
||||||
@ -37,9 +50,15 @@ def SAE():
|
|||||||
form = SAEForm()
|
form = SAEForm()
|
||||||
form_validation = form.validate_on_submit()
|
form_validation = form.validate_on_submit()
|
||||||
form = form_import(form)
|
form = form_import(form)
|
||||||
if form_validation and form.exporter.data:
|
if form_validation:
|
||||||
|
if form.exporter.data:
|
||||||
flash("Ajout du référentiel SAE: {} ".format(form.code.data))
|
flash("Ajout du référentiel SAE: {} ".format(form.code.data))
|
||||||
form_export(form)
|
form_export(form)
|
||||||
|
if not "sae" in locals():
|
||||||
|
sae = models.SAE()
|
||||||
|
form.populate_obj(sae)
|
||||||
|
db.session.add(sae)
|
||||||
|
db.session.commit()
|
||||||
return redirect(url_for("SAE"))
|
return redirect(url_for("SAE"))
|
||||||
return render_template("SAE.html", form = form)
|
return render_template("SAE.html", form = form)
|
||||||
|
|
||||||
@ -48,9 +67,15 @@ def Ressource():
|
|||||||
form = RessourceForm()
|
form = RessourceForm()
|
||||||
form_validation = form.validate_on_submit()
|
form_validation = form.validate_on_submit()
|
||||||
form = form_import(form)
|
form = form_import(form)
|
||||||
if form_validation and form.exporter.data:
|
if form_validation:
|
||||||
|
if form.exporter.data:
|
||||||
flash("Ajout du référentiel Ressource: {} ".format(form.code.data))
|
flash("Ajout du référentiel Ressource: {} ".format(form.code.data))
|
||||||
form_export(form)
|
form_export(form)
|
||||||
|
if not "ressource" in locals():
|
||||||
|
ressource = models.Ressource()
|
||||||
|
form.populate_obj(ressource)
|
||||||
|
db.session.add(ressource)
|
||||||
|
db.session.commit()
|
||||||
return redirect(url_for("Ressource"))
|
return redirect(url_for("Ressource"))
|
||||||
return render_template("Ressource.html", form = form)
|
return render_template("Ressource.html", form = form)
|
||||||
|
|
||||||
@ -59,8 +84,14 @@ def Competence():
|
|||||||
form = CompetenceForm()
|
form = CompetenceForm()
|
||||||
form_validation = form.validate_on_submit()
|
form_validation = form.validate_on_submit()
|
||||||
form = form_import(form)
|
form = form_import(form)
|
||||||
if form_validation and form.exporter.data:
|
if form_validation:
|
||||||
|
if form.exporter.data:
|
||||||
flash("Ajout du référentielCompetence: {} ".format(form.code.data))
|
flash("Ajout du référentielCompetence: {} ".format(form.code.data))
|
||||||
form_export(form)
|
form_export(form)
|
||||||
|
if not "competence" in locals():
|
||||||
|
competence = models.Competence()
|
||||||
|
form.populate_obj(competence)
|
||||||
|
db.session.add(competence)
|
||||||
|
db.session.commit()
|
||||||
return redirect(url_for("Competence"))
|
return redirect(url_for("Competence"))
|
||||||
return render_template("Competence.html", form = form)
|
return render_template("Competence.html", form = form)
|
@ -20,6 +20,12 @@
|
|||||||
{% block formulaire %}{% endblock %}
|
{% block formulaire %}{% endblock %}
|
||||||
|
|
||||||
<div class="field is-grouped">
|
<div class="field is-grouped">
|
||||||
|
<div class="control">
|
||||||
|
{{ form.sauvegarder(class="button")}}
|
||||||
|
</div>
|
||||||
|
<div class="control">
|
||||||
|
{{ form.charger(class="button is-static")}}
|
||||||
|
</div>
|
||||||
<div class="control">
|
<div class="control">
|
||||||
{{ form.exporter(class="button")}}
|
{{ form.exporter(class="button")}}
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user