fix a regression ; eliminate send_from_flask
This commit is contained in:
parent
6e7a104fb0
commit
87ecd09f0e
@ -482,9 +482,9 @@ class GenTable(object):
|
|||||||
ses.append_blank_row() # empty line
|
ses.append_blank_row() # empty line
|
||||||
ses.append_single_cell_row(self.origin, style_base)
|
ses.append_single_cell_row(self.origin, style_base)
|
||||||
if wb is None:
|
if wb is None:
|
||||||
return ses.generate_standalone()
|
return ses.generate()
|
||||||
else:
|
else:
|
||||||
ses.generate_embeded()
|
ses.generate()
|
||||||
|
|
||||||
def text(self):
|
def text(self):
|
||||||
"raw text representation of the table"
|
"raw text representation of the table"
|
||||||
|
@ -65,14 +65,6 @@ class COLORS(Enum):
|
|||||||
LIGHT_YELLOW = "FFFFFF99"
|
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):
|
def send_excel_file(request, data, filename, mime=scu.XLSX_MIMETYPE):
|
||||||
"""publication fichier.
|
"""publication fichier.
|
||||||
(on ne doit rien avoir émis avant, car ici sont générés les entetes)
|
(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
|
* 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
|
"""Création de la feuille. sheet_name
|
||||||
-- le nom de la feuille default_style
|
-- le nom de la feuille default_style
|
||||||
-- le style par défaut des cellules ws
|
-- le style par défaut des cellules ws
|
||||||
@ -224,13 +216,13 @@ class ScoExcelSheet:
|
|||||||
if default_style is None:
|
if default_style is None:
|
||||||
default_style = excel_make_style()
|
default_style = excel_make_style()
|
||||||
self.default_style = default_style
|
self.default_style = default_style
|
||||||
if ws is None:
|
if wb is None:
|
||||||
self.wb = Workbook()
|
self.wb = Workbook()
|
||||||
self.ws = self.wb.active
|
self.ws = self.wb.active
|
||||||
self.ws.title = self.sheet_name
|
self.ws.title = self.sheet_name
|
||||||
else:
|
else:
|
||||||
self.wb = None
|
self.wb = None
|
||||||
self.ws = ws
|
self.ws = wb
|
||||||
# internal data
|
# internal data
|
||||||
self.rows = [] # list of list of cells
|
self.rows = [] # list of list of cells
|
||||||
self.column_dimensions = {}
|
self.column_dimensions = {}
|
||||||
|
@ -46,6 +46,7 @@ from wtforms import (
|
|||||||
RadioField,
|
RadioField,
|
||||||
HiddenField,
|
HiddenField,
|
||||||
SelectMultipleField,
|
SelectMultipleField,
|
||||||
|
BooleanField,
|
||||||
)
|
)
|
||||||
import app.scodoc.sco_utils as scu
|
import app.scodoc.sco_utils as scu
|
||||||
import app.scodoc.notesdb as ndb
|
import app.scodoc.notesdb as ndb
|
||||||
@ -75,9 +76,7 @@ TOUS = "Tous"
|
|||||||
|
|
||||||
def _get_group_info(evaluation_id):
|
def _get_group_info(evaluation_id):
|
||||||
# groupes
|
# groupes
|
||||||
groups = sco_groups.do_evaluation_listegroupes(
|
groups = sco_groups.do_evaluation_listegroupes(evaluation_id, include_default=True)
|
||||||
evaluation_id, include_default=True
|
|
||||||
)
|
|
||||||
has_groups = False
|
has_groups = False
|
||||||
groups_tree = {}
|
groups_tree = {}
|
||||||
for group in groups:
|
for group in groups:
|
||||||
@ -92,6 +91,7 @@ def _get_group_info(evaluation_id):
|
|||||||
nb_groups = len(groups_tree)
|
nb_groups = len(groups_tree)
|
||||||
return groups_tree, has_groups, nb_groups
|
return groups_tree, has_groups, nb_groups
|
||||||
|
|
||||||
|
|
||||||
class PlacementForm(FlaskForm):
|
class PlacementForm(FlaskForm):
|
||||||
"""Formulaire pour placement des étudiants en Salle"""
|
"""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})
|
eval_data = sco_evaluations.do_evaluation_list({"evaluation_id": evaluation_id})
|
||||||
if not eval_data:
|
if not eval_data:
|
||||||
raise ScoValueError("invalid evaluation_id")
|
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:
|
if self.has_groups:
|
||||||
choices = []
|
choices = []
|
||||||
for partition in self.groups_tree:
|
for partition in self.groups_tree:
|
||||||
@ -223,7 +225,6 @@ class PlacementRunner:
|
|||||||
self.eval_data = sco_evaluations.do_evaluation_list(
|
self.eval_data = sco_evaluations.do_evaluation_list(
|
||||||
{"evaluation_id": self.evaluation_id}
|
{"evaluation_id": self.evaluation_id}
|
||||||
)[0]
|
)[0]
|
||||||
self.cnx = ndb.GetDBConnexion()
|
|
||||||
self.groups = sco_groups.listgroups(self.groups_ids)
|
self.groups = sco_groups.listgroups(self.groups_ids)
|
||||||
self.gr_title_filename = sco_groups.listgroups_filename(self.groups)
|
self.gr_title_filename = sco_groups.listgroups_filename(self.groups)
|
||||||
# gr_title = sco_groups.listgroups_abbrev(d['groups'])
|
# gr_title = sco_groups.listgroups_abbrev(d['groups'])
|
||||||
@ -282,7 +283,9 @@ class PlacementRunner:
|
|||||||
self.plan = self._affectation_places()
|
self.plan = self._affectation_places()
|
||||||
|
|
||||||
def _build_listetud(self):
|
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(
|
etudids = sco_groups.do_evaluation_listeetuds_groups(
|
||||||
self.evaluation_id,
|
self.evaluation_id,
|
||||||
self.groups,
|
self.groups,
|
||||||
@ -292,7 +295,7 @@ class PlacementRunner:
|
|||||||
listetud = [] # liste de couples (nom,prenom)
|
listetud = [] # liste de couples (nom,prenom)
|
||||||
for etudid in etudids:
|
for etudid in etudids:
|
||||||
# infos identite etudiant (xxx sous-optimal: 1/select par etudiant)
|
# 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
|
# infos inscription
|
||||||
inscr = sco_formsemestre_inscriptions.do_formsemestre_inscription_list(
|
inscr = sco_formsemestre_inscriptions.do_formsemestre_inscription_list(
|
||||||
{
|
{
|
||||||
@ -319,13 +322,9 @@ class PlacementRunner:
|
|||||||
return plan
|
return plan
|
||||||
|
|
||||||
def _production_xls(self):
|
def _production_xls(self):
|
||||||
filename = "placement_%s_%s%s" % (
|
filename = "placement_%s_%s" % (self.evalname, self.gr_title_filename)
|
||||||
self.evalname,
|
|
||||||
self.gr_title_filename,
|
|
||||||
scu.XLSX_SUFFIX,
|
|
||||||
)
|
|
||||||
xls = self._excel_feuille_placement()
|
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):
|
def _production_pdf(self):
|
||||||
pdf_title = "<br/>".join(self.desceval)
|
pdf_title = "<br/>".join(self.desceval)
|
||||||
|
Loading…
Reference in New Issue
Block a user