############################################################################## # # Gestion scolarite IUT # # 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 # ############################################################################## """ScoDoc : gestion des fichiers archivés associés au formsemestre (PV de jury, ...) """ import json import flask from flask import flash, g, render_template, request, url_for from app import ScoDocJSONEncoder from app.but import jury_but_pv from app.comp import res_sem from app.comp.res_compat import NotesTableCompat from app.models import FormSemestre from app.scodoc.TrivialFormulator import TrivialFormulator from app.scodoc.sco_exceptions import ScoPermissionDenied from app.scodoc import html_sco_header from app.scodoc import sco_bulletins_pdf from app.scodoc import sco_groups from app.scodoc import sco_groups_view from app.scodoc import sco_pv_forms from app.scodoc import sco_pv_lettres_inviduelles from app.scodoc import sco_pv_pdf from app.scodoc.sco_archives import BaseArchiver from app.scodoc.sco_exceptions import ScoValueError from app.scodoc.sco_recapcomplet import ( gen_formsemestre_recapcomplet_excel, gen_formsemestre_recapcomplet_html_table, gen_formsemestre_recapcomplet_json, ) import app.scodoc.sco_utils as scu class SemsArchiver(BaseArchiver): "Archiveur pour les PV de semestre" def __init__(self): BaseArchiver.__init__(self, archive_type="") PV_ARCHIVER = SemsArchiver() # ---------------------------------------------------------------------------- def do_formsemestre_archive( formsemestre: FormSemestre, group_ids: list[int] = None, # si indiqué, ne prend que ces groupes description="", date_jury="", signature=None, # pour lettres indiv date_commission=None, numero_arrete=None, code_vdi=None, show_title=False, pv_title=None, pv_title_session=None, with_paragraph_nom=False, anonymous=False, bul_version="long", ): """Make and store new archive for this formsemestre. Store: - tableau recap (xls), pv jury (xls et pdf), bulletins (xml et pdf), lettres individuelles (pdf) """ if bul_version not in scu.BULLETINS_VERSIONS: raise ScoValueError( "do_formsemestre_archive: version de bulletin demandée invalide" ) res: NotesTableCompat = res_sem.load_formsemestre_results(formsemestre) sem_archive_id = formsemestre.id archive_id = PV_ARCHIVER.create_obj_archive( sem_archive_id, description, formsemestre.dept_id ) date = PV_ARCHIVER.get_archive_date(archive_id).strftime(scu.DATEATIME_FMT) if not group_ids: # tous les inscrits du semestre group_ids = [sco_groups.get_default_group(formsemestre.id)] groups_infos = sco_groups_view.DisplayedGroupsInfos( group_ids, formsemestre_id=formsemestre.id ) groups_filename = "-" + groups_infos.groups_filename etudids = [m["etudid"] for m in groups_infos.members] # Tableau recap notes en XLS (pour tous les etudiants, n'utilise pas les groupes) data, _ = gen_formsemestre_recapcomplet_excel(res, include_evaluations=True) if data: PV_ARCHIVER.store( archive_id, "Tableau_moyennes" + scu.XLSX_SUFFIX, data, dept_id=formsemestre.dept_id, ) # Tableau recap notes en HTML (pour tous les etudiants, n'utilise pas les groupes) table_html, _, _ = gen_formsemestre_recapcomplet_html_table( formsemestre, res, include_evaluations=True ) if table_html: flash(f"Moyennes archivées le {date}", category="info") data = "\n".join( [ html_sco_header.sco_header( page_title=f"Moyennes archivées le {date}", no_sidebar=True, ), f'
Cette page permet de générer et d'archiver tous les documents résultant de ce semestre: PV de jury, lettres individuelles, tableaux récapitulatifs.
Les documents archivés sont enregistrés et non modifiables, on peut les retrouver ultérieurement.
On peut archiver plusieurs versions des documents (avant et après le jury par exemple).
""", ] F = [ f"""Note: les documents sont aussi affectés par les réglages sur la page "Paramétrage" (accessible à l'administrateur du département).
""", html_sco_header.sco_footer(), ] descr = [ ( "description", {"input_type": "textarea", "rows": 4, "cols": 77, "title": "Description"}, ), ("sep", {"input_type": "separator", "title": "Informations sur PV de jury"}), ] descr += sco_pv_forms.descrform_pvjury(formsemestre) descr += [ ( "signature", { "input_type": "file", "size": 30, "explanation": "optionnel: image scannée de la signature pour les lettres individuelles", }, ), ( "bul_version", { "input_type": "menu", "title": "Version des bulletins archivés", "labels": [ "Version courte", "Version intermédiaire", "Version complète", ], "allowed_values": scu.BULLETINS_VERSIONS.keys(), "default": "long", }, ), ] menu_choix_groupe = ( """ """ ) tf = TrivialFormulator( request.base_url, scu.get_request_args(), descr, cancelbutton="Annuler", submitlabel="Générer et archiver les documents", name="tf", formid="group_selector", html_foot_markup=menu_choix_groupe, ) if tf[0] == 0: return render_template( "sco_page.j2", title="Archiver les PV et résultats", javascripts=sco_groups_view.JAVASCRIPTS, cssstyles=sco_groups_view.CSSSTYLES, content="aucune archive enregistrée
") else: H.append("La suppression sera définitive.
""", dest_url="", cancel_url=dest_url, parameters={ "formsemestre_id": formsemestre_id, "archive_name": archive_name, }, ) PV_ARCHIVER.delete_archive(archive_id, dept_id=formsemestre.dept_id) flash("Archive supprimée") return flask.redirect(dest_url)