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