2021-12-03 11:03:33 +01:00
|
|
|
##############################################################################
|
|
|
|
# ScoDoc
|
2022-01-01 14:49:42 +01:00
|
|
|
# Copyright (c) 1999 - 2022 Emmanuel Viennet. All rights reserved.
|
2021-12-03 11:03:33 +01:00
|
|
|
# See LICENSE
|
|
|
|
##############################################################################
|
|
|
|
|
|
|
|
"""ScoDoc 9 : Formulaires / référentiel de compétence
|
|
|
|
"""
|
|
|
|
|
|
|
|
from flask_wtf import FlaskForm
|
|
|
|
from flask_wtf.file import FileField, FileAllowed, FileRequired
|
|
|
|
from wtforms import SelectField, SubmitField
|
|
|
|
|
|
|
|
|
|
|
|
class FormationRefCompForm(FlaskForm):
|
|
|
|
referentiel_competence = SelectField("Référentiels déjà chargés")
|
|
|
|
submit = SubmitField("Valider")
|
|
|
|
cancel = SubmitField("Annuler")
|
|
|
|
|
|
|
|
|
|
|
|
class RefCompLoadForm(FlaskForm):
|
2022-02-12 20:25:22 +01:00
|
|
|
referentiel_standard = SelectField(
|
|
|
|
"Choisir un référentiel de compétences officiel BUT"
|
|
|
|
)
|
2021-12-03 11:03:33 +01:00
|
|
|
upload = FileField(
|
2022-02-12 20:25:22 +01:00
|
|
|
label="Ou bien sélectionner un fichier XML au format Orébut",
|
2021-12-03 11:03:33 +01:00
|
|
|
validators=[
|
|
|
|
FileAllowed(
|
|
|
|
[
|
|
|
|
"xml",
|
|
|
|
],
|
|
|
|
"Fichier XML Orébut seulement",
|
|
|
|
),
|
|
|
|
],
|
|
|
|
)
|
|
|
|
submit = SubmitField("Valider")
|
|
|
|
cancel = SubmitField("Annuler")
|
2022-02-12 20:25:22 +01:00
|
|
|
|
|
|
|
def validate(self):
|
|
|
|
if not super().validate():
|
|
|
|
return False
|
|
|
|
if (self.referentiel_standard.data == "0") == (not self.upload.data):
|
|
|
|
self.referentiel_standard.errors.append(
|
|
|
|
"Choisir soit un référentiel, soit un fichier xml"
|
|
|
|
)
|
|
|
|
return False
|
|
|
|
return True
|