From bcb801662ac28f45982cc702dd75411bb74707b3 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Fri, 9 Feb 2024 21:52:33 +0100 Subject: [PATCH] =?UTF-8?q?WIP:=20PE=20:=20form=20param=C3=A9trage=20pe=5F?= =?UTF-8?q?view=5Fsem=5Frecap?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/forms/pe/pe_sem_recap.py | 49 +++++++++++++++++++++++++ app/pe/pe_view.py | 51 +++++++++++++++------------ app/templates/pe/pe_view_sem_recap.j2 | 23 +++--------- 3 files changed, 81 insertions(+), 42 deletions(-) create mode 100644 app/forms/pe/pe_sem_recap.py diff --git a/app/forms/pe/pe_sem_recap.py b/app/forms/pe/pe_sem_recap.py new file mode 100644 index 000000000..37fd155c3 --- /dev/null +++ b/app/forms/pe/pe_sem_recap.py @@ -0,0 +1,49 @@ +############################################################################## +# +# ScoDoc +# +# Copyright (c) 1999 - 2024 Emmanuel Viennet. All rights reserved. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# Emmanuel Viennet emmanuel.viennet@viennet.net +# +############################################################################## + +""" +Formulaire options génération table poursuite études (PE) +""" + +from flask_wtf import FlaskForm +from wtforms import BooleanField, HiddenField, SubmitField + + +class ParametrageClasseurPE(FlaskForm): + "Formulaire paramétrage génération classeur PE" + cohorte_restreinte = BooleanField( + "Restreindre aux étudiants inscrits dans le semestre" + ) + moyennes_tags = BooleanField("Générer les moyennes sur les tags de modules") + moyennes_ue_res_sae = BooleanField( + "Générer les moyennes des ressources et des SAEs par UE" + ) + moyennes_ues_rcues = BooleanField("Générer moyennes des UEs et RCUEs (compétences)") + min_max_moy = BooleanField("Colonnes min/max/moy") + synthese_individuelle_etud = BooleanField( + "Générer la feuille synthèse avec un onglet par étudiant" + ) + + submit = SubmitField("Générer les classeurs poursuites d'études") + cancel = SubmitField("Annuler", render_kw={"formnovalidate": True}) diff --git a/app/pe/pe_view.py b/app/pe/pe_view.py index 986627fa9..03ad54322 100644 --- a/app/pe/pe_view.py +++ b/app/pe/pe_view.py @@ -38,6 +38,7 @@ from flask import flash, g, redirect, render_template, request, send_file, url_for from app.decorators import permission_required, scodoc +from app.forms.pe.pe_sem_recap import ParametrageClasseurPE from app.models import FormSemestre from app.pe import pe_comp from app.pe import pe_jury @@ -73,40 +74,44 @@ def pe_view_sem_recap(formsemestre_id: int): # Cosemestres diplomants cosemestres = pe_comp.get_cosemestres_diplomants(annee_diplome) + form = ParametrageClasseurPE() + if request.method == "GET": return render_template( "pe/pe_view_sem_recap.j2", annee_diplome=annee_diplome, + form=form, formsemestre=formsemestre, sco=ScoData(formsemestre=formsemestre), cosemestres=cosemestres, ) # request.method == "POST" - jury = pe_jury.JuryPE(annee_diplome) - if not jury.diplomes_ids: - flash("aucun étudiant à considérer !") - return redirect( - url_for( - "notes.pe_view_sem_recap", - scodoc_dept=g.scodoc_dept, - formsemestre_id=formsemestre_id, + if form.validate_on_submit(): + jury = pe_jury.JuryPE(annee_diplome, options=form.data) + if not jury.diplomes_ids: + flash("aucun étudiant à considérer !") + return redirect( + url_for( + "notes.pe_view_sem_recap", + scodoc_dept=g.scodoc_dept, + formsemestre_id=formsemestre_id, + ) ) + + data = jury.get_zipped_data() + + return send_file( + data, + mimetype="application/zip", + download_name=scu.sanitize_filename(jury.nom_export_zip + ".zip"), + as_attachment=True, ) - data = jury.get_zipped_data() - - return send_file( - data, - mimetype="application/zip", - download_name=scu.sanitize_filename(jury.nom_export_zip + ".zip"), - as_attachment=True, - ) - - return render_template( - "pe/pe_view_sem_recap.j2", - annee_diplome=annee_diplome, - formsemestre=formsemestre, - sco=ScoData(formsemestre=formsemestre), - cosemestres=cosemestres, + return redirect( + url_for( + "notes.formsemestre_status", + scodoc_dept=g.scodoc_dept, + formsemestre_id=formsemestre_id, + ) ) diff --git a/app/templates/pe/pe_view_sem_recap.j2 b/app/templates/pe/pe_view_sem_recap.j2 index 756b7f870..8d0a0fb11 100644 --- a/app/templates/pe/pe_view_sem_recap.j2 +++ b/app/templates/pe/pe_view_sem_recap.j2 @@ -1,4 +1,5 @@ {% extends "sco_page.j2" %} +{% import 'wtf.j2' as wtf %} {% block styles %} {{super()}} @@ -42,7 +43,9 @@

Avis de poursuites d'études de la promo {{ annee_diplome }}

-
+ {{ wtf.quick_form(form) }} + +
Seront (a minima) pris en compte les étudiants ayant été inscrits aux semestres suivants :
    @@ -54,22 +57,4 @@
-
- -
- -
- - - - {% endblock app_content %} \ No newline at end of file