forked from ScoDoc/DocScoDoc
form edit correspondant (champ site)
This commit is contained in:
parent
8e730c2164
commit
db19322b07
@ -496,6 +496,7 @@ class CorrespondantsCreationForm(FlaskForm):
|
||||
class CorrespondantModificationForm(FlaskForm):
|
||||
hidden_correspondant_id = HiddenField()
|
||||
hidden_site_id = HiddenField()
|
||||
hidden_entreprise_id = HiddenField()
|
||||
civilite = SelectField(
|
||||
"Civilité (*)",
|
||||
choices=[("H", "Monsieur"), ("F", "Madame")],
|
||||
@ -512,9 +513,22 @@ class CorrespondantModificationForm(FlaskForm):
|
||||
service = _build_string_field("Service", required=False)
|
||||
origine = _build_string_field("Origine", required=False)
|
||||
notes = _build_string_field("Notes", required=False)
|
||||
site = SelectField(
|
||||
"Site du correspondant", validators=[DataRequired()], description="Nom du site"
|
||||
)
|
||||
submit = SubmitField("Modifier", render_kw=SUBMIT_MARGE)
|
||||
cancel = SubmitField("Annuler", render_kw=SUBMIT_MARGE)
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
self.site.choices = [
|
||||
(site.id, f"{site.nom}")
|
||||
for site in db.session.query(EntrepriseSite)
|
||||
.filter(EntrepriseSite.entreprise_id == self.hidden_entreprise_id.data)
|
||||
.all()
|
||||
]
|
||||
|
||||
def validate(self):
|
||||
validate = True
|
||||
if not FlaskForm.validate(self):
|
||||
|
@ -1189,6 +1189,8 @@ def edit_correspondant(entreprise_id, site_id, correspondant_id):
|
||||
form = CorrespondantModificationForm(
|
||||
hidden_site_id=correspondant.site.id,
|
||||
hidden_correspondant_id=correspondant.id,
|
||||
hidden_entreprise_id=entreprise_id,
|
||||
site=correspondant.site_id,
|
||||
)
|
||||
if request.method == "POST" and form.cancel.data:
|
||||
return redirect(
|
||||
@ -1204,6 +1206,7 @@ def edit_correspondant(entreprise_id, site_id, correspondant_id):
|
||||
correspondant.service = form.service.data.strip()
|
||||
correspondant.origine = form.origine.data.strip()
|
||||
correspondant.notes = form.notes.data.strip()
|
||||
correspondant.site_id = form.site.data
|
||||
log = EntrepriseHistorique(
|
||||
authenticated_user=current_user.user_name,
|
||||
entreprise_id=correspondant.site.entreprise.id,
|
||||
|
Loading…
Reference in New Issue
Block a user