forked from ScoDoc/DocScoDoc
formulaire saisie multiple, des ajustements
This commit is contained in:
parent
a3cbea5dcd
commit
efe48582bf
@ -406,24 +406,46 @@ class StageApprentissageModificationForm(FlaskForm):
|
||||
|
||||
|
||||
class EnvoiOffreForm(FlaskForm):
|
||||
responsable = _build_string_field(
|
||||
responsable_1 = _build_string_field(
|
||||
"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)
|
||||
|
||||
def validate_responsable(self, responsable):
|
||||
responsable_data = responsable.data.upper().strip()
|
||||
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:
|
||||
raise ValidationError("Champ incorrect (selectionnez dans la liste)")
|
||||
def validate(self):
|
||||
validate = True
|
||||
if not FlaskForm.validate(self):
|
||||
validate = False
|
||||
|
||||
for field in self:
|
||||
if (
|
||||
field.name in ["responsable_1", "responsable_2", "responsable_3"]
|
||||
and field.data.strip()
|
||||
):
|
||||
responsable_data = field.data.upper().strip()
|
||||
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):
|
||||
|
@ -833,6 +833,9 @@ def add_stage_apprentissage(id):
|
||||
@bp.route("/edit_stage_apprentissage/<int:id>", methods=["GET", "POST"])
|
||||
@permission_required(Permission.RelationsEntreprisesChange)
|
||||
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(
|
||||
id=id
|
||||
).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"])
|
||||
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(
|
||||
id=id
|
||||
).first_or_404(description=f"stage_apprentissage {id} inconnu")
|
||||
@ -915,23 +921,28 @@ def envoyer_offre(id):
|
||||
)
|
||||
form = EnvoiOffreForm()
|
||||
if form.validate_on_submit():
|
||||
responsable_data = form.responsable.data.upper().strip()
|
||||
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()
|
||||
)
|
||||
envoi_offre = EntrepriseEnvoiOffre(
|
||||
sender_id=current_user.id,
|
||||
receiver_id=responsable.id,
|
||||
offre_id=offre.id,
|
||||
)
|
||||
db.session.add(envoi_offre)
|
||||
for field in form:
|
||||
if (
|
||||
field.name in ["responsable_1", "responsable_2", "responsable_3"]
|
||||
and field.data
|
||||
):
|
||||
responsable_data = field.data.upper().strip()
|
||||
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()
|
||||
)
|
||||
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()
|
||||
flash(f"L'offre a été envoyé à {responsable.get_nomplogin()}.")
|
||||
return redirect(url_for("entreprises.fiche_entreprise", id=offre.entreprise_id))
|
||||
return render_template(
|
||||
"entreprises/envoi_offre_form.html",
|
||||
|
@ -1,6 +1,7 @@
|
||||
{# -*- mode: jinja-html -*- #}
|
||||
<div class="offre">
|
||||
<div>
|
||||
Ajouté le {{ offre[0].date_ajout.strftime('%d/%m/%y') }} à {{ offre[0].date_ajout.strftime('%Hh%M') }}<br>
|
||||
Intitulé : {{ offre[0].intitule }}<br>
|
||||
Description : {{ offre[0].description }}<br>
|
||||
Type de l'offre : {{ offre[0].type_offre }}<br>
|
||||
|
@ -38,7 +38,7 @@
|
||||
<tr>
|
||||
<td data-priority="1">Nom</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="6">Poste</td>
|
||||
<td data-priority="7">Service</td>
|
||||
@ -62,7 +62,7 @@
|
||||
<tr>
|
||||
<td>Nom</td>
|
||||
<td>Prenom</td>
|
||||
<td>Telephone</td>
|
||||
<td>Téléphone</td>
|
||||
<td>Mail</td>
|
||||
<td>Poste</td>
|
||||
<td>Service</td>
|
||||
|
@ -30,7 +30,9 @@
|
||||
minchars: 2,
|
||||
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>
|
||||
{% endblock %}
|
@ -10,7 +10,7 @@
|
||||
{% for offre in offres_recues %}
|
||||
<div class="offre offre-recue">
|
||||
<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>
|
||||
Description : {{ offre[1].description }}<br>
|
||||
Type de l'offre : {{ offre[1].type_offre }}<br>
|
||||
|
Loading…
Reference in New Issue
Block a user