forked from ScoDoc/DocScoDoc
ajustement formulaires
This commit is contained in:
parent
46eb1185d6
commit
842f73d692
@ -65,20 +65,20 @@ def _build_string_field(label, required=True, render_kw=None):
|
||||
|
||||
class EntrepriseCreationForm(FlaskForm):
|
||||
siret = _build_string_field(
|
||||
"SIRET",
|
||||
"SIRET (*)",
|
||||
render_kw={"placeholder": "Numéro composé de 14 chiffres", "maxlength": "14"},
|
||||
)
|
||||
nom_entreprise = _build_string_field("Nom de l'entreprise")
|
||||
adresse = _build_string_field("Adresse de l'entreprise")
|
||||
codepostal = _build_string_field("Code postal de l'entreprise")
|
||||
ville = _build_string_field("Ville de l'entreprise")
|
||||
pays = _build_string_field("Pays de l'entreprise")
|
||||
nom_entreprise = _build_string_field("Nom de l'entreprise (*)")
|
||||
adresse = _build_string_field("Adresse de l'entreprise (*)")
|
||||
codepostal = _build_string_field("Code postal de l'entreprise (*)")
|
||||
ville = _build_string_field("Ville de l'entreprise (*)")
|
||||
pays = _build_string_field("Pays de l'entreprise", required=False)
|
||||
|
||||
nom_contact = _build_string_field("Nom du contact")
|
||||
prenom_contact = _build_string_field("Prénom du contact")
|
||||
telephone = _build_string_field("Téléphone du contact", required=False)
|
||||
nom_contact = _build_string_field("Nom du contact (*)")
|
||||
prenom_contact = _build_string_field("Prénom du contact (*)")
|
||||
telephone = _build_string_field("Téléphone du contact (*)", required=False)
|
||||
mail = StringField(
|
||||
"Mail du contact",
|
||||
"Mail du contact (*)",
|
||||
validators=[Optional(), Email(message="Adresse e-mail invalide")],
|
||||
)
|
||||
poste = _build_string_field("Poste du contact", required=False)
|
||||
@ -121,14 +121,22 @@ class EntrepriseCreationForm(FlaskForm):
|
||||
|
||||
|
||||
class EntrepriseModificationForm(FlaskForm):
|
||||
siret = StringField("SIRET", render_kw={"disabled": ""})
|
||||
nom = _build_string_field("Nom de l'entreprise")
|
||||
adresse = _build_string_field("Adresse")
|
||||
codepostal = _build_string_field("Code postal")
|
||||
ville = _build_string_field("Ville")
|
||||
pays = _build_string_field("Pays")
|
||||
hidden_entreprise_siret = HiddenField()
|
||||
siret = StringField("SIRET (*)")
|
||||
nom = _build_string_field("Nom de l'entreprise (*)")
|
||||
adresse = _build_string_field("Adresse (*)")
|
||||
codepostal = _build_string_field("Code postal (*)")
|
||||
ville = _build_string_field("Ville (*)")
|
||||
pays = _build_string_field("Pays", required=False)
|
||||
submit = SubmitField("Modifier", render_kw=SUBMIT_MARGE)
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.siret.render_kw = {
|
||||
"disabled": "",
|
||||
"value": self.hidden_entreprise_siret.data,
|
||||
}
|
||||
|
||||
|
||||
class MultiCheckboxField(SelectMultipleField):
|
||||
widget = ListWidget(prefix_label=False)
|
||||
@ -136,22 +144,22 @@ class MultiCheckboxField(SelectMultipleField):
|
||||
|
||||
|
||||
class OffreCreationForm(FlaskForm):
|
||||
intitule = _build_string_field("Intitulé")
|
||||
intitule = _build_string_field("Intitulé (*)")
|
||||
description = TextAreaField(
|
||||
"Description", validators=[DataRequired(message=CHAMP_REQUIS)]
|
||||
"Description (*)", validators=[DataRequired(message=CHAMP_REQUIS)]
|
||||
)
|
||||
type_offre = SelectField(
|
||||
"Type de l'offre",
|
||||
"Type de l'offre (*)",
|
||||
choices=[("Stage"), ("Alternance")],
|
||||
validators=[DataRequired(message=CHAMP_REQUIS)],
|
||||
)
|
||||
missions = TextAreaField(
|
||||
"Missions", validators=[DataRequired(message=CHAMP_REQUIS)]
|
||||
"Missions (*)", validators=[DataRequired(message=CHAMP_REQUIS)]
|
||||
)
|
||||
duree = _build_string_field("Durée")
|
||||
duree = _build_string_field("Durée (*)")
|
||||
depts = MultiCheckboxField("Départements", validators=[Optional()], coerce=int)
|
||||
expiration_date = DateField(
|
||||
"Date expiration", validators=[DataRequired(message=CHAMP_REQUIS)]
|
||||
"Date expiration (*)", validators=[DataRequired(message=CHAMP_REQUIS)]
|
||||
)
|
||||
submit = SubmitField("Envoyer", render_kw=SUBMIT_MARGE)
|
||||
|
||||
@ -164,22 +172,22 @@ class OffreCreationForm(FlaskForm):
|
||||
|
||||
|
||||
class OffreModificationForm(FlaskForm):
|
||||
intitule = _build_string_field("Intitulé")
|
||||
intitule = _build_string_field("Intitulé (*)")
|
||||
description = TextAreaField(
|
||||
"Description", validators=[DataRequired(message=CHAMP_REQUIS)]
|
||||
"Description (*)", validators=[DataRequired(message=CHAMP_REQUIS)]
|
||||
)
|
||||
type_offre = SelectField(
|
||||
"Type de l'offre",
|
||||
"Type de l'offre (*)",
|
||||
choices=[("Stage"), ("Alternance")],
|
||||
validators=[DataRequired(message=CHAMP_REQUIS)],
|
||||
)
|
||||
missions = TextAreaField(
|
||||
"Missions", validators=[DataRequired(message=CHAMP_REQUIS)]
|
||||
"Missions (*)", validators=[DataRequired(message=CHAMP_REQUIS)]
|
||||
)
|
||||
duree = _build_string_field("Durée")
|
||||
duree = _build_string_field("Durée (*)")
|
||||
depts = MultiCheckboxField("Départements", validators=[Optional()], coerce=int)
|
||||
expiration_date = DateField(
|
||||
"Date expiration", validators=[DataRequired(message=CHAMP_REQUIS)]
|
||||
"Date expiration (*)", validators=[DataRequired(message=CHAMP_REQUIS)]
|
||||
)
|
||||
submit = SubmitField("Modifier", render_kw=SUBMIT_MARGE)
|
||||
|
||||
@ -193,11 +201,11 @@ class OffreModificationForm(FlaskForm):
|
||||
|
||||
class ContactCreationForm(FlaskForm):
|
||||
hidden_entreprise_id = HiddenField()
|
||||
nom = _build_string_field("Nom")
|
||||
prenom = _build_string_field("Prénom")
|
||||
telephone = _build_string_field("Téléphone", required=False)
|
||||
nom = _build_string_field("Nom (*)")
|
||||
prenom = _build_string_field("Prénom (*)")
|
||||
telephone = _build_string_field("Téléphone (*)", required=False)
|
||||
mail = StringField(
|
||||
"Mail",
|
||||
"Mail (*)",
|
||||
validators=[Optional(), Email(message="Adresse e-mail invalide")],
|
||||
)
|
||||
poste = _build_string_field("Poste", required=False)
|
||||
@ -232,11 +240,11 @@ class ContactCreationForm(FlaskForm):
|
||||
class ContactModificationForm(FlaskForm):
|
||||
hidden_contact_id = HiddenField()
|
||||
hidden_entreprise_id = HiddenField()
|
||||
nom = _build_string_field("Nom")
|
||||
prenom = _build_string_field("Prénom")
|
||||
telephone = _build_string_field("Téléphone", required=False)
|
||||
nom = _build_string_field("Nom (*)")
|
||||
prenom = _build_string_field("Prénom (*)")
|
||||
telephone = _build_string_field("Téléphone (*)", required=False)
|
||||
mail = StringField(
|
||||
"Mail",
|
||||
"Mail (*)",
|
||||
validators=[Optional(), Email(message="Adresse e-mail invalide")],
|
||||
)
|
||||
poste = _build_string_field("Poste", required=False)
|
||||
@ -271,18 +279,20 @@ class ContactModificationForm(FlaskForm):
|
||||
|
||||
class HistoriqueCreationForm(FlaskForm):
|
||||
etudiant = _build_string_field(
|
||||
"Étudiant",
|
||||
"Étudiant (*)",
|
||||
render_kw={"placeholder": "Tapez le nom de l'étudiant"},
|
||||
)
|
||||
type_offre = SelectField(
|
||||
"Type de l'offre",
|
||||
"Type de l'offre (*)",
|
||||
choices=[("Stage"), ("Alternance")],
|
||||
validators=[DataRequired(message=CHAMP_REQUIS)],
|
||||
)
|
||||
date_debut = DateField(
|
||||
"Date début", validators=[DataRequired(message=CHAMP_REQUIS)]
|
||||
"Date début (*)", validators=[DataRequired(message=CHAMP_REQUIS)]
|
||||
)
|
||||
date_fin = DateField(
|
||||
"Date fin (*)", validators=[DataRequired(message=CHAMP_REQUIS)]
|
||||
)
|
||||
date_fin = DateField("Date fin", validators=[DataRequired(message=CHAMP_REQUIS)])
|
||||
submit = SubmitField("Envoyer", render_kw=SUBMIT_MARGE)
|
||||
|
||||
def validate(self):
|
||||
@ -315,7 +325,7 @@ class HistoriqueCreationForm(FlaskForm):
|
||||
|
||||
class EnvoiOffreForm(FlaskForm):
|
||||
responsable = _build_string_field(
|
||||
"Responsable de formation",
|
||||
"Responsable de formation (*)",
|
||||
render_kw={"placeholder": "Tapez le nom du responsable de formation"},
|
||||
)
|
||||
submit = SubmitField("Envoyer", render_kw=SUBMIT_MARGE)
|
||||
@ -336,7 +346,7 @@ class EnvoiOffreForm(FlaskForm):
|
||||
|
||||
class AjoutFichierForm(FlaskForm):
|
||||
fichier = FileField(
|
||||
"Fichier",
|
||||
"Fichier (*)",
|
||||
validators=[
|
||||
FileRequired(message=CHAMP_REQUIS),
|
||||
FileAllowed(["pdf", "docx"], "Fichier .pdf ou .docx uniquement"),
|
||||
@ -355,7 +365,7 @@ class ValidationConfirmationForm(FlaskForm):
|
||||
|
||||
class ImportForm(FlaskForm):
|
||||
fichier = FileField(
|
||||
"Fichier",
|
||||
"Fichier (*)",
|
||||
validators=[
|
||||
FileRequired(message=CHAMP_REQUIS),
|
||||
FileAllowed(["xlsx"], "Fichier .xlsx uniquement"),
|
||||
|
@ -275,7 +275,7 @@ def add_entreprise():
|
||||
adresse=form.adresse.data.strip(),
|
||||
codepostal=form.codepostal.data.strip(),
|
||||
ville=form.ville.data.strip(),
|
||||
pays=form.pays.data.strip(),
|
||||
pays=form.pays.data.strip() if form.pays.data.strip() else "FRANCE",
|
||||
)
|
||||
db.session.add(entreprise)
|
||||
db.session.commit()
|
||||
@ -326,14 +326,14 @@ def edit_entreprise(id):
|
||||
entreprise = Entreprise.query.filter_by(id=id, visible=True).first_or_404(
|
||||
description=f"entreprise {id} inconnue"
|
||||
)
|
||||
form = EntrepriseModificationForm()
|
||||
form = EntrepriseModificationForm(hidden_entreprise_siret=entreprise.siret)
|
||||
if form.validate_on_submit():
|
||||
nom_entreprise = f"<a href=/ScoDoc/entreprises/fiche_entreprise/{entreprise.id}>{form.nom.data.strip()}</a>"
|
||||
if entreprise.nom != form.nom.data.strip():
|
||||
log = EntrepriseLog(
|
||||
authenticated_user=current_user.user_name,
|
||||
object=entreprise.id,
|
||||
text=f"{nom_entreprise} - Modification du nom (ancien nom : {entreprise.nom})",
|
||||
text=f"{nom_entreprise} - Modification du nom (ancien nom: {entreprise.nom})",
|
||||
)
|
||||
entreprise.nom = form.nom.data.strip()
|
||||
db.session.add(log)
|
||||
@ -341,7 +341,7 @@ def edit_entreprise(id):
|
||||
log = EntrepriseLog(
|
||||
authenticated_user=current_user.user_name,
|
||||
object=entreprise.id,
|
||||
text=f"{nom_entreprise} - Modification de l'adresse (ancienne adresse : {entreprise.adresse})",
|
||||
text=f"{nom_entreprise} - Modification de l'adresse (ancienne adresse: {entreprise.adresse})",
|
||||
)
|
||||
entreprise.adresse = form.adresse.data.strip()
|
||||
db.session.add(log)
|
||||
@ -349,7 +349,7 @@ def edit_entreprise(id):
|
||||
log = EntrepriseLog(
|
||||
authenticated_user=current_user.user_name,
|
||||
object=entreprise.id,
|
||||
text=f"{nom_entreprise} - Modification du code postal (ancien code postal : {entreprise.codepostal})",
|
||||
text=f"{nom_entreprise} - Modification du code postal (ancien code postal: {entreprise.codepostal})",
|
||||
)
|
||||
entreprise.codepostal = form.codepostal.data.strip()
|
||||
db.session.add(log)
|
||||
@ -357,17 +357,19 @@ def edit_entreprise(id):
|
||||
log = EntrepriseLog(
|
||||
authenticated_user=current_user.user_name,
|
||||
object=entreprise.id,
|
||||
text=f"{nom_entreprise} - Modification de la ville (ancienne ville : {entreprise.ville})",
|
||||
text=f"{nom_entreprise} - Modification de la ville (ancienne ville: {entreprise.ville})",
|
||||
)
|
||||
entreprise.ville = form.ville.data.strip()
|
||||
db.session.add(log)
|
||||
if entreprise.pays != form.pays.data.strip():
|
||||
if entreprise.pays != form.pays.data.strip() or not form.pays.data.strip():
|
||||
log = EntrepriseLog(
|
||||
authenticated_user=current_user.user_name,
|
||||
object=entreprise.id,
|
||||
text=f"{nom_entreprise} - Modification du pays (ancien pays : {entreprise.pays})",
|
||||
text=f"{nom_entreprise} - Modification du pays (ancien pays: {entreprise.pays})",
|
||||
)
|
||||
entreprise.pays = (
|
||||
form.pays.data.strip() if form.pays.data.strip() else "FRANCE"
|
||||
)
|
||||
entreprise.pays = form.pays.data.strip()
|
||||
db.session.add(log)
|
||||
db.session.commit()
|
||||
flash("L'entreprise a été modifié.")
|
||||
|
@ -8,7 +8,8 @@
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<p>
|
||||
Les champs s'auto complète selon le SIRET
|
||||
Les champs s'auto complète selon le SIRET<br>
|
||||
(*) champs requis
|
||||
</p>
|
||||
{{ wtf.quick_form(form, novalidate=True) }}
|
||||
</div>
|
||||
|
@ -13,6 +13,9 @@
|
||||
<br>
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<p>
|
||||
(*) champs requis
|
||||
</p>
|
||||
{{ wtf.quick_form(form, novalidate=True) }}
|
||||
</div>
|
||||
</div>
|
||||
|
@ -13,6 +13,9 @@
|
||||
<br>
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<p>
|
||||
(*) champs requis
|
||||
</p>
|
||||
{{ wtf.quick_form(form, novalidate=True) }}
|
||||
</div>
|
||||
</div>
|
||||
|
@ -11,6 +11,9 @@
|
||||
<br>
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<p>
|
||||
(*) champs requis
|
||||
</p>
|
||||
{{ wtf.quick_form(form, novalidate=True) }}
|
||||
</div>
|
||||
</div>
|
||||
|
@ -11,6 +11,9 @@
|
||||
<br>
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<p>
|
||||
(*) champs requis
|
||||
</p>
|
||||
{{ wtf.quick_form(form, novalidate=True) }}
|
||||
</div>
|
||||
|
||||
|
@ -15,6 +15,9 @@
|
||||
<br>
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<p>
|
||||
(*) champs requis
|
||||
</p>
|
||||
{{ wtf.quick_form(form, novalidate=True) }}
|
||||
</div>
|
||||
</div>
|
||||
|
@ -15,6 +15,9 @@
|
||||
<br>
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<p>
|
||||
(*) champs requis
|
||||
</p>
|
||||
{{ wtf.quick_form(form, novalidate=True) }}
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user