forked from ScoDoc/ScoDoc
correctif formulaire
This commit is contained in:
parent
6a734ce06a
commit
f9cad4fd01
@ -85,21 +85,29 @@ class EntrepriseCreationForm(FlaskForm):
|
||||
"Prénom du contact",
|
||||
validators=[DataRequired(message=CHAMP_REQUIS)],
|
||||
)
|
||||
telephone = StringField(
|
||||
"Téléphone du contact",
|
||||
validators=[DataRequired(message=CHAMP_REQUIS)],
|
||||
)
|
||||
telephone = StringField("Téléphone du contact", validators=[Optional()])
|
||||
mail = EmailField(
|
||||
"Mail du contact",
|
||||
validators=[
|
||||
DataRequired(message=CHAMP_REQUIS),
|
||||
Email(message="Adresse e-mail invalide"),
|
||||
],
|
||||
validators=[Optional(), Email(message="Adresse e-mail invalide")],
|
||||
)
|
||||
poste = StringField("Poste du contact", validators=[])
|
||||
service = StringField("Service du contact", validators=[])
|
||||
poste = StringField("Poste du contact", validators=[Optional()])
|
||||
service = StringField("Service du contact", validators=[Optional()])
|
||||
submit = SubmitField("Envoyer", render_kw={"style": "margin-bottom: 10px;"})
|
||||
|
||||
def validate(self):
|
||||
rv = FlaskForm.validate(self)
|
||||
if not rv:
|
||||
return False
|
||||
|
||||
if not self.telephone.data and not self.mail.data:
|
||||
self.telephone.errors.append(
|
||||
"Saisir un moyen de contact (mail ou téléphone)"
|
||||
)
|
||||
self.mail.errors.append("Saisir un moyen de contact (mail ou téléphone)")
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
def validate_siret(self, siret):
|
||||
siret = siret.data.strip()
|
||||
if re.match("^\d{14}$", siret) == None:
|
||||
@ -198,18 +206,13 @@ class ContactCreationForm(FlaskForm):
|
||||
hidden_entreprise_id = HiddenField()
|
||||
nom = StringField("Nom", validators=[DataRequired(message=CHAMP_REQUIS)])
|
||||
prenom = StringField("Prénom", validators=[DataRequired(message=CHAMP_REQUIS)])
|
||||
telephone = StringField(
|
||||
"Téléphone", validators=[DataRequired(message=CHAMP_REQUIS)]
|
||||
)
|
||||
telephone = StringField("Téléphone", validators=[Optional()])
|
||||
mail = EmailField(
|
||||
"Mail",
|
||||
validators=[
|
||||
DataRequired(message=CHAMP_REQUIS),
|
||||
Email(message="Adresse e-mail invalide"),
|
||||
],
|
||||
validators=[Optional(), Email(message="Adresse e-mail invalide")],
|
||||
)
|
||||
poste = StringField("Poste", validators=[])
|
||||
service = StringField("Service", validators=[])
|
||||
poste = StringField("Poste", validators=[Optional()])
|
||||
service = StringField("Service", validators=[Optional()])
|
||||
submit = SubmitField("Envoyer", render_kw={"style": "margin-bottom: 10px;"})
|
||||
|
||||
def validate(self):
|
||||
@ -226,6 +229,14 @@ class ContactCreationForm(FlaskForm):
|
||||
if contact is not None:
|
||||
self.nom.errors.append("Ce contact existe déjà (même nom et prénom)")
|
||||
self.prenom.errors.append("")
|
||||
|
||||
if not self.telephone.data and not self.mail.data:
|
||||
self.telephone.errors.append(
|
||||
"Saisir un moyen de contact (mail ou téléphone)"
|
||||
)
|
||||
self.mail.errors.append(
|
||||
"Saisir un moyen de contact (mail ou téléphone)"
|
||||
)
|
||||
return False
|
||||
|
||||
return True
|
||||
@ -234,20 +245,29 @@ class ContactCreationForm(FlaskForm):
|
||||
class ContactModificationForm(FlaskForm):
|
||||
nom = StringField("Nom", validators=[DataRequired(message=CHAMP_REQUIS)])
|
||||
prenom = StringField("Prénom", validators=[DataRequired(message=CHAMP_REQUIS)])
|
||||
telephone = StringField(
|
||||
"Téléphone", validators=[DataRequired(message=CHAMP_REQUIS)]
|
||||
)
|
||||
telephone = StringField("Téléphone", validators=[Optional()])
|
||||
mail = EmailField(
|
||||
"Mail",
|
||||
validators=[
|
||||
DataRequired(message=CHAMP_REQUIS),
|
||||
Email(message="Adresse e-mail invalide"),
|
||||
],
|
||||
validators=[Optional(), Email(message="Adresse e-mail invalide")],
|
||||
)
|
||||
poste = StringField("Poste", validators=[])
|
||||
service = StringField("Service", validators=[])
|
||||
poste = StringField("Poste", validators=[Optional()])
|
||||
service = StringField("Service", validators=[Optional()])
|
||||
submit = SubmitField("Modifier", render_kw={"style": "margin-bottom: 10px;"})
|
||||
|
||||
def validate(self):
|
||||
rv = FlaskForm.validate(self)
|
||||
if not rv:
|
||||
return False
|
||||
|
||||
if not self.telephone.data and not self.mail.data:
|
||||
self.telephone.errors.append(
|
||||
"Saisir un moyen de contact (mail ou téléphone)"
|
||||
)
|
||||
self.mail.errors.append("Saisir un moyen de contact (mail ou téléphone)")
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
|
||||
class HistoriqueCreationForm(FlaskForm):
|
||||
etudiant = StringField(
|
||||
|
@ -3,8 +3,12 @@
|
||||
<div>
|
||||
Nom : {{ contact.nom }}<br>
|
||||
Prénom : {{ contact.prenom }}<br>
|
||||
{% if contact.telephone %}
|
||||
Téléphone : {{ contact.telephone }}<br>
|
||||
{% endif %}
|
||||
{% if contact.mail %}
|
||||
Mail : {{ contact.mail }}<br>
|
||||
{% endif %}
|
||||
{% if contact.poste %}
|
||||
Poste : {{ contact.poste }}<br>
|
||||
{% endif %}
|
||||
|
Loading…
Reference in New Issue
Block a user