diff --git a/app/scodoc/gen_tables.py b/app/scodoc/gen_tables.py index 67a52261..c199d0b3 100644 --- a/app/scodoc/gen_tables.py +++ b/app/scodoc/gen_tables.py @@ -482,9 +482,9 @@ class GenTable(object): ses.append_blank_row() # empty line ses.append_single_cell_row(self.origin, style_base) if wb is None: - return ses.generate_standalone() + return ses.generate() else: - ses.generate_embeded() + ses.generate() def text(self): "raw text representation of the table" diff --git a/app/scodoc/sco_excel.py b/app/scodoc/sco_excel.py index b6f0b873..ab40af89 100644 --- a/app/scodoc/sco_excel.py +++ b/app/scodoc/sco_excel.py @@ -65,14 +65,6 @@ class COLORS(Enum): LIGHT_YELLOW = "FFFFFF99" -def send_from_flask(data, filename, mime=scu.XLSX_MIMETYPE): - filename = scu.make_filename(filename) - response = make_response(data) - response.headers["Content-Type"] = mime - response.headers["Content-Disposition"] = 'attachment; filename="%s"' % filename - return response - - def send_excel_file(request, data, filename, mime=scu.XLSX_MIMETYPE): """publication fichier. (on ne doit rien avoir émis avant, car ici sont générés les entetes) @@ -211,7 +203,7 @@ class ScoExcelSheet: * pour finit appel de la méthode de génération """ - def __init__(self, sheet_name="feuille", default_style=None, ws=None): + def __init__(self, sheet_name="feuille", default_style=None, wb=None): """Création de la feuille. sheet_name -- le nom de la feuille default_style -- le style par défaut des cellules ws @@ -224,13 +216,13 @@ class ScoExcelSheet: if default_style is None: default_style = excel_make_style() self.default_style = default_style - if ws is None: + if wb is None: self.wb = Workbook() self.ws = self.wb.active self.ws.title = self.sheet_name else: self.wb = None - self.ws = ws + self.ws = wb # internal data self.rows = [] # list of list of cells self.column_dimensions = {} diff --git a/app/scodoc/sco_placement.py b/app/scodoc/sco_placement.py index dd5e97eb..20f9cdc7 100644 --- a/app/scodoc/sco_placement.py +++ b/app/scodoc/sco_placement.py @@ -46,6 +46,7 @@ from wtforms import ( RadioField, HiddenField, SelectMultipleField, + BooleanField, ) import app.scodoc.sco_utils as scu import app.scodoc.notesdb as ndb @@ -75,9 +76,7 @@ TOUS = "Tous" def _get_group_info(evaluation_id): # groupes - groups = sco_groups.do_evaluation_listegroupes( - evaluation_id, include_default=True - ) + groups = sco_groups.do_evaluation_listegroupes(evaluation_id, include_default=True) has_groups = False groups_tree = {} for group in groups: @@ -92,6 +91,7 @@ def _get_group_info(evaluation_id): nb_groups = len(groups_tree) return groups_tree, has_groups, nb_groups + class PlacementForm(FlaskForm): """Formulaire pour placement des étudiants en Salle""" @@ -137,7 +137,9 @@ class PlacementForm(FlaskForm): eval_data = sco_evaluations.do_evaluation_list({"evaluation_id": evaluation_id}) if not eval_data: raise ScoValueError("invalid evaluation_id") - self.groups_tree, self.has_groups, self.nb_groups = _get_group_info(evaluation_id) + self.groups_tree, self.has_groups, self.nb_groups = _get_group_info( + evaluation_id + ) if self.has_groups: choices = [] for partition in self.groups_tree: @@ -223,7 +225,6 @@ class PlacementRunner: self.eval_data = sco_evaluations.do_evaluation_list( {"evaluation_id": self.evaluation_id} )[0] - self.cnx = ndb.GetDBConnexion() self.groups = sco_groups.listgroups(self.groups_ids) self.gr_title_filename = sco_groups.listgroups_filename(self.groups) # gr_title = sco_groups.listgroups_abbrev(d['groups']) @@ -282,7 +283,9 @@ class PlacementRunner: self.plan = self._affectation_places() def _build_listetud(self): - get_all_students = None in [g["group_name"] for g in self.groups] # tous les etudiants + get_all_students = None in [ + g["group_name"] for g in self.groups + ] # tous les etudiants etudids = sco_groups.do_evaluation_listeetuds_groups( self.evaluation_id, self.groups, @@ -292,7 +295,7 @@ class PlacementRunner: listetud = [] # liste de couples (nom,prenom) for etudid in etudids: # infos identite etudiant (xxx sous-optimal: 1/select par etudiant) - ident = sco_etud.etudident_list(self.cnx, {"etudid": etudid})[0] + ident = sco_etud.etudident_list(ndb.GetDBConnexion(), {"etudid": etudid})[0] # infos inscription inscr = sco_formsemestre_inscriptions.do_formsemestre_inscription_list( { @@ -319,13 +322,9 @@ class PlacementRunner: return plan def _production_xls(self): - filename = "placement_%s_%s%s" % ( - self.evalname, - self.gr_title_filename, - scu.XLSX_SUFFIX, - ) + filename = "placement_%s_%s" % (self.evalname, self.gr_title_filename) xls = self._excel_feuille_placement() - return sco_excel.send_from_flask(xls, filename) + return scu.send_file(xls, filename, scu.XLSX_SUFFIX, scu.XLSX_MIMETYPE) def _production_pdf(self): pdf_title = "
".join(self.desceval)