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