2021-12-03 11:03:33 +01:00
|
|
|
##############################################################################
|
|
|
|
# ScoDoc
|
2023-12-31 23:04:06 +01:00
|
|
|
# Copyright (c) 1999 - 2024 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
|
2022-12-02 17:41:19 +01:00
|
|
|
from flask_wtf.file import FileField, FileAllowed
|
2021-12-03 11:03:33 +01:00
|
|
|
from wtforms import SelectField, SubmitField
|
2024-04-05 23:41:34 +02:00
|
|
|
from wtforms.validators import DataRequired
|
2021-12-03 11:03:33 +01:00
|
|
|
|
|
|
|
|
|
|
|
class FormationRefCompForm(FlaskForm):
|
2024-04-05 23:41:34 +02:00
|
|
|
"Choix d'un référentiel"
|
2022-05-22 03:26:39 +02:00
|
|
|
referentiel_competence = SelectField(
|
|
|
|
"Choisir parmi les référentiels déjà chargés :"
|
|
|
|
)
|
2021-12-03 11:03:33 +01:00
|
|
|
submit = SubmitField("Valider")
|
|
|
|
cancel = SubmitField("Annuler")
|
|
|
|
|
|
|
|
|
|
|
|
class RefCompLoadForm(FlaskForm):
|
2024-04-05 23:41:34 +02:00
|
|
|
"Upload d'un référentiel"
|
2022-02-12 20:25:22 +01:00
|
|
|
referentiel_standard = SelectField(
|
|
|
|
"Choisir un référentiel de compétences officiel BUT"
|
|
|
|
)
|
2024-10-21 19:12:01 +02:00
|
|
|
submit = SubmitField("Valider")
|
|
|
|
cancel = SubmitField("Annuler")
|
|
|
|
|
|
|
|
def validate(self, extra_validators=None) -> bool:
|
|
|
|
if not super().validate(extra_validators):
|
|
|
|
return False
|
|
|
|
if self.referentiel_standard.data == "0":
|
|
|
|
self.referentiel_standard.errors.append("Choisir soit un référentiel")
|
|
|
|
return False
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
|
class RefCompUploadForm(FlaskForm):
|
|
|
|
"Upload d'un référentiel"
|
2021-12-03 11:03:33 +01:00
|
|
|
upload = FileField(
|
2024-10-21 19:12:01 +02:00
|
|
|
label="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
|
|
|
|
2024-10-21 19:12:01 +02:00
|
|
|
def validate(self, extra_validators=None) -> bool:
|
2023-04-04 13:00:39 +02:00
|
|
|
if not super().validate(extra_validators):
|
2022-02-12 20:25:22 +01:00
|
|
|
return False
|
2024-10-21 19:12:01 +02:00
|
|
|
if not self.upload.data:
|
|
|
|
self.upload.errors.append("Choisir un fichier XML")
|
2022-02-12 20:25:22 +01:00
|
|
|
return False
|
|
|
|
return True
|
2024-04-05 23:41:34 +02:00
|
|
|
|
|
|
|
|
|
|
|
class FormationChangeRefCompForm(FlaskForm):
|
|
|
|
"choix d'un nouveau ref. comp. pour une formation"
|
|
|
|
object_select = SelectField(
|
|
|
|
"Choisir le nouveau référentiel", validators=[DataRequired()]
|
|
|
|
)
|
|
|
|
submit = SubmitField("Changer le référentiel de la formation")
|
|
|
|
cancel = SubmitField("Annuler")
|