forked from ScoDoc/ScoDoc
formulaire saisie multiple, des ajustements
This commit is contained in:
parent
a3cbea5dcd
commit
efe48582bf
@ -406,24 +406,46 @@ class StageApprentissageModificationForm(FlaskForm):
|
|||||||
|
|
||||||
|
|
||||||
class EnvoiOffreForm(FlaskForm):
|
class EnvoiOffreForm(FlaskForm):
|
||||||
responsable = _build_string_field(
|
responsable_1 = _build_string_field(
|
||||||
"Responsable de formation (*)",
|
"Responsable de formation (*)",
|
||||||
render_kw={"placeholder": "Tapez le nom du responsable de formation"},
|
render_kw={"placeholder": "Tapez le nom du responsable de formation"},
|
||||||
)
|
)
|
||||||
|
responsable_2 = _build_string_field(
|
||||||
|
"Responsable de formation",
|
||||||
|
required=False,
|
||||||
|
render_kw={"placeholder": "Tapez le nom du responsable de formation"},
|
||||||
|
)
|
||||||
|
responsable_3 = _build_string_field(
|
||||||
|
"Responsable de formation",
|
||||||
|
required=False,
|
||||||
|
render_kw={"placeholder": "Tapez le nom du responsable de formation"},
|
||||||
|
)
|
||||||
submit = SubmitField("Envoyer", render_kw=SUBMIT_MARGE)
|
submit = SubmitField("Envoyer", render_kw=SUBMIT_MARGE)
|
||||||
|
|
||||||
def validate_responsable(self, responsable):
|
def validate(self):
|
||||||
responsable_data = responsable.data.upper().strip()
|
validate = True
|
||||||
stm = text(
|
if not FlaskForm.validate(self):
|
||||||
"SELECT id, UPPER(CONCAT(nom, ' ', prenom, ' ', '(', user_name, ')')) FROM \"user\" WHERE UPPER(CONCAT(nom, ' ', prenom, ' ', '(', user_name, ')'))=:responsable_data"
|
validate = False
|
||||||
)
|
|
||||||
responsable = (
|
for field in self:
|
||||||
User.query.from_statement(stm)
|
if (
|
||||||
.params(responsable_data=responsable_data)
|
field.name in ["responsable_1", "responsable_2", "responsable_3"]
|
||||||
.first()
|
and field.data.strip()
|
||||||
)
|
):
|
||||||
if responsable is None:
|
responsable_data = field.data.upper().strip()
|
||||||
raise ValidationError("Champ incorrect (selectionnez dans la liste)")
|
stm = text(
|
||||||
|
"SELECT id, UPPER(CONCAT(nom, ' ', prenom, ' ', '(', user_name, ')')) FROM \"user\" WHERE UPPER(CONCAT(nom, ' ', prenom, ' ', '(', user_name, ')'))=:responsable_data"
|
||||||
|
)
|
||||||
|
responsable = (
|
||||||
|
User.query.from_statement(stm)
|
||||||
|
.params(responsable_data=responsable_data)
|
||||||
|
.first()
|
||||||
|
)
|
||||||
|
if responsable is None:
|
||||||
|
field.errors.append("Champ incorrect (selectionnez dans la liste)")
|
||||||
|
validate = False
|
||||||
|
|
||||||
|
return validate
|
||||||
|
|
||||||
|
|
||||||
class AjoutFichierForm(FlaskForm):
|
class AjoutFichierForm(FlaskForm):
|
||||||
|
@ -833,6 +833,9 @@ def add_stage_apprentissage(id):
|
|||||||
@bp.route("/edit_stage_apprentissage/<int:id>", methods=["GET", "POST"])
|
@bp.route("/edit_stage_apprentissage/<int:id>", methods=["GET", "POST"])
|
||||||
@permission_required(Permission.RelationsEntreprisesChange)
|
@permission_required(Permission.RelationsEntreprisesChange)
|
||||||
def edit_stage_apprentissage(id):
|
def edit_stage_apprentissage(id):
|
||||||
|
"""
|
||||||
|
Permet de modifier un étudiant ayant réalisé un stage ou une alternance sur la fiche entreprise de l'entreprise
|
||||||
|
"""
|
||||||
stage_apprentissage = EntrepriseStageApprentissage.query.filter_by(
|
stage_apprentissage = EntrepriseStageApprentissage.query.filter_by(
|
||||||
id=id
|
id=id
|
||||||
).first_or_404(description=f"stage_apprentissage {id} inconnue")
|
).first_or_404(description=f"stage_apprentissage {id} inconnue")
|
||||||
@ -885,6 +888,9 @@ def edit_stage_apprentissage(id):
|
|||||||
|
|
||||||
@bp.route("/delete_stage_apprentissage/<int:id>", methods=["GET", "POST"])
|
@bp.route("/delete_stage_apprentissage/<int:id>", methods=["GET", "POST"])
|
||||||
def delete_stage_apprentissage(id):
|
def delete_stage_apprentissage(id):
|
||||||
|
"""
|
||||||
|
Permet de supprimer un étudiant ayant réalisé un stage ou une alternance sur la fiche entreprise de l'entreprise
|
||||||
|
"""
|
||||||
stage_apprentissage = EntrepriseStageApprentissage.query.filter_by(
|
stage_apprentissage = EntrepriseStageApprentissage.query.filter_by(
|
||||||
id=id
|
id=id
|
||||||
).first_or_404(description=f"stage_apprentissage {id} inconnu")
|
).first_or_404(description=f"stage_apprentissage {id} inconnu")
|
||||||
@ -915,23 +921,28 @@ def envoyer_offre(id):
|
|||||||
)
|
)
|
||||||
form = EnvoiOffreForm()
|
form = EnvoiOffreForm()
|
||||||
if form.validate_on_submit():
|
if form.validate_on_submit():
|
||||||
responsable_data = form.responsable.data.upper().strip()
|
for field in form:
|
||||||
stm = text(
|
if (
|
||||||
"SELECT id, UPPER(CONCAT(nom, ' ', prenom, ' ', '(', user_name, ')')) FROM \"user\" WHERE UPPER(CONCAT(nom, ' ', prenom, ' ', '(', user_name, ')'))=:responsable_data"
|
field.name in ["responsable_1", "responsable_2", "responsable_3"]
|
||||||
)
|
and field.data
|
||||||
responsable = (
|
):
|
||||||
User.query.from_statement(stm)
|
responsable_data = field.data.upper().strip()
|
||||||
.params(responsable_data=responsable_data)
|
stm = text(
|
||||||
.first()
|
"SELECT id, UPPER(CONCAT(nom, ' ', prenom, ' ', '(', user_name, ')')) FROM \"user\" WHERE UPPER(CONCAT(nom, ' ', prenom, ' ', '(', user_name, ')'))=:responsable_data"
|
||||||
)
|
)
|
||||||
envoi_offre = EntrepriseEnvoiOffre(
|
responsable = (
|
||||||
sender_id=current_user.id,
|
User.query.from_statement(stm)
|
||||||
receiver_id=responsable.id,
|
.params(responsable_data=responsable_data)
|
||||||
offre_id=offre.id,
|
.first()
|
||||||
)
|
)
|
||||||
db.session.add(envoi_offre)
|
envoi_offre = EntrepriseEnvoiOffre(
|
||||||
|
sender_id=current_user.id,
|
||||||
|
receiver_id=responsable.id,
|
||||||
|
offre_id=offre.id,
|
||||||
|
)
|
||||||
|
db.session.add(envoi_offre)
|
||||||
|
flash(f"L'offre a été envoyé à {responsable.get_nomplogin()}.")
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
flash(f"L'offre a été envoyé à {responsable.get_nomplogin()}.")
|
|
||||||
return redirect(url_for("entreprises.fiche_entreprise", id=offre.entreprise_id))
|
return redirect(url_for("entreprises.fiche_entreprise", id=offre.entreprise_id))
|
||||||
return render_template(
|
return render_template(
|
||||||
"entreprises/envoi_offre_form.html",
|
"entreprises/envoi_offre_form.html",
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
{# -*- mode: jinja-html -*- #}
|
{# -*- mode: jinja-html -*- #}
|
||||||
<div class="offre">
|
<div class="offre">
|
||||||
<div>
|
<div>
|
||||||
|
Ajouté le {{ offre[0].date_ajout.strftime('%d/%m/%y') }} à {{ offre[0].date_ajout.strftime('%Hh%M') }}<br>
|
||||||
Intitulé : {{ offre[0].intitule }}<br>
|
Intitulé : {{ offre[0].intitule }}<br>
|
||||||
Description : {{ offre[0].description }}<br>
|
Description : {{ offre[0].description }}<br>
|
||||||
Type de l'offre : {{ offre[0].type_offre }}<br>
|
Type de l'offre : {{ offre[0].type_offre }}<br>
|
||||||
|
@ -38,7 +38,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td data-priority="1">Nom</td>
|
<td data-priority="1">Nom</td>
|
||||||
<td data-priority="3">Prenom</td>
|
<td data-priority="3">Prenom</td>
|
||||||
<td data-priority="4">Telephone</td>
|
<td data-priority="4">Téléphone</td>
|
||||||
<td data-priority="5">Mail</td>
|
<td data-priority="5">Mail</td>
|
||||||
<td data-priority="6">Poste</td>
|
<td data-priority="6">Poste</td>
|
||||||
<td data-priority="7">Service</td>
|
<td data-priority="7">Service</td>
|
||||||
@ -62,7 +62,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td>Nom</td>
|
<td>Nom</td>
|
||||||
<td>Prenom</td>
|
<td>Prenom</td>
|
||||||
<td>Telephone</td>
|
<td>Téléphone</td>
|
||||||
<td>Mail</td>
|
<td>Mail</td>
|
||||||
<td>Poste</td>
|
<td>Poste</td>
|
||||||
<td>Service</td>
|
<td>Service</td>
|
||||||
|
@ -30,7 +30,9 @@
|
|||||||
minchars: 2,
|
minchars: 2,
|
||||||
timeout: 60000
|
timeout: 60000
|
||||||
};
|
};
|
||||||
var as_responsables = new bsn.AutoSuggest('responsable', responsables_options);
|
var as_responsables_1 = new bsn.AutoSuggest('responsable_1', responsables_options);
|
||||||
|
var as_responsables_2 = new bsn.AutoSuggest('responsable_2', responsables_options);
|
||||||
|
var as_responsables_3 = new bsn.AutoSuggest('responsable_3', responsables_options);
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
@ -10,7 +10,7 @@
|
|||||||
{% for offre in offres_recues %}
|
{% for offre in offres_recues %}
|
||||||
<div class="offre offre-recue">
|
<div class="offre offre-recue">
|
||||||
<div>
|
<div>
|
||||||
Envoyé le {{ offre[0].date_envoi.strftime('%d %B %Y à %H:%M') }} par {{ offre[0].sender_id|get_nomcomplet_by_id }}<br>
|
Envoyé le {{ offre[0].date_envoi.strftime('%d/%m/%Y') }} à {{ offre[0].date_envoi.strftime('%Hh%M') }} par {{ offre[0].sender_id|get_nomcomplet_by_id }}<br>
|
||||||
Intitulé : {{ offre[1].intitule }}<br>
|
Intitulé : {{ offre[1].intitule }}<br>
|
||||||
Description : {{ offre[1].description }}<br>
|
Description : {{ offre[1].description }}<br>
|
||||||
Type de l'offre : {{ offre[1].type_offre }}<br>
|
Type de l'offre : {{ offre[1].type_offre }}<br>
|
||||||
|
Loading…
Reference in New Issue
Block a user