forked from ScoDoc/ScoDoc
replace send_excel_file by scu.send_file
This commit is contained in:
parent
87ecd09f0e
commit
2a72fb881b
@ -269,9 +269,9 @@ def etudarchive_generate_excel_sample(group_id=None, REQUEST=None):
|
||||
],
|
||||
extra_cols=["fichier_a_charger"],
|
||||
)
|
||||
return sco_excel.send_excel_file(
|
||||
REQUEST, data, "ImportFichiersEtudiants" + scu.XLSX_SUFFIX
|
||||
)
|
||||
breakpoint()
|
||||
return scu.send_file(data, "ImportFichiersEtudiants", scu.XLSX_SUFFIX, scu.XLSX_MIMETYPE, attached=True)
|
||||
# return sco_excel.send_excel_file(REQUEST, data, "ImportFichiersEtudiants" + scu.XLSX_SUFFIX)
|
||||
|
||||
|
||||
def etudarchive_import_files_form(group_id, REQUEST=None):
|
||||
|
@ -35,10 +35,6 @@ from enum import Enum
|
||||
from tempfile import NamedTemporaryFile
|
||||
|
||||
import openpyxl.utils.datetime
|
||||
from flask import make_response
|
||||
from openpyxl import Workbook, load_workbook
|
||||
from openpyxl.cell import WriteOnlyCell
|
||||
from openpyxl.styles import Font, Border, Side, Alignment, PatternFill
|
||||
from openpyxl.styles.numbers import FORMAT_NUMBER_00, FORMAT_GENERAL
|
||||
from openpyxl.comments import Comment
|
||||
from openpyxl import Workbook, load_workbook
|
||||
@ -48,8 +44,6 @@ from openpyxl.styles import Font, Border, Side, Alignment, PatternFill
|
||||
import app.scodoc.sco_utils as scu
|
||||
from app.scodoc import notesdb
|
||||
from app.scodoc import sco_preferences
|
||||
from app.scodoc.sco_exceptions import ScoValueError
|
||||
from app.scodoc import sco_preferences
|
||||
from app import log
|
||||
from app.scodoc.sco_exceptions import ScoValueError
|
||||
|
||||
@ -65,24 +59,25 @@ class COLORS(Enum):
|
||||
LIGHT_YELLOW = "FFFFFF99"
|
||||
|
||||
|
||||
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)
|
||||
"""
|
||||
filename = (
|
||||
scu.unescape_html(scu.suppress_accents(filename))
|
||||
.replace("&", "")
|
||||
.replace(" ", "_")
|
||||
)
|
||||
request.RESPONSE.setHeader("content-type", mime)
|
||||
request.RESPONSE.setHeader(
|
||||
"content-disposition", 'attachment; filename="%s"' % filename
|
||||
)
|
||||
return data
|
||||
# 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)
|
||||
# """
|
||||
# filename = (
|
||||
# scu.unescape_html(scu.suppress_accents(filename))
|
||||
# .replace("&", "")
|
||||
# .replace(" ", "_")
|
||||
# )
|
||||
# request.RESPONSE.setHeader("content-type", mime)
|
||||
# request.RESPONSE.setHeader(
|
||||
# "content-disposition", 'attachment; filename="%s"' % filename
|
||||
# )
|
||||
# return data
|
||||
|
||||
|
||||
# Un style est enregistré comme un dictionnaire qui précise la valeur d'un attributdans la liste suivante:
|
||||
# font, border, number_format, fill, .. (cf https://openpyxl.readthedocs.io/en/stable/styles.html#working-with-styles)
|
||||
# font, border, number_format, fill,...
|
||||
# (cf https://openpyxl.readthedocs.io/en/stable/styles.html#working-with-styles)
|
||||
|
||||
|
||||
def xldate_as_datetime(xldate, datemode=0):
|
||||
@ -129,7 +124,8 @@ class ScoExcelBook:
|
||||
"""
|
||||
for sheet in self.sheets:
|
||||
sheet.prepare()
|
||||
# construction d'un flux (https://openpyxl.readthedocs.io/en/stable/tutorial.html#saving-as-a-stream)
|
||||
# construction d'un flux
|
||||
# (https://openpyxl.readthedocs.io/en/stable/tutorial.html#saving-as-a-stream)
|
||||
with NamedTemporaryFile() as tmp:
|
||||
self.wb.save(tmp.name)
|
||||
tmp.seek(0)
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -322,5 +322,7 @@ def feuille_preparation_jury(formsemestre_id, REQUEST):
|
||||
REQUEST.AUTHENTICATED_USER,
|
||||
)
|
||||
)
|
||||
xls = ws.generate_standalone()
|
||||
return sco_excel.send_excel_file(REQUEST, xls, f"PrepaJury{sn}{scu.XLSX_SUFFIX}")
|
||||
xls = ws.generate()
|
||||
breakpoint()
|
||||
return scu.send_file(xls, f"PrepaJury{sn}{scu.XLSX_SUFFIX}", scu.XLSX_SUFFIX, scu.XLSX_MIMETYPE, attached=True)
|
||||
# return sco_excel.send_excel_file(REQUEST, xls, f"PrepaJury{sn}{scu.XLSX_SUFFIX}")
|
||||
|
@ -829,7 +829,9 @@ def feuille_saisie_notes(evaluation_id, group_ids=[], REQUEST=None):
|
||||
|
||||
filename = "notes_%s_%s.xlsx" % (evalname, gr_title_filename)
|
||||
xls = sco_excel.excel_feuille_saisie(E, sem["titreannee"], description, lines=L)
|
||||
return sco_excel.send_excel_file(REQUEST, xls, filename)
|
||||
breakpoint()
|
||||
return scu.send_file(xls, filename, scu.XLSX_SUFFIX, scu.XLSX_MIMETYPE, attached=True)
|
||||
# return sco_excel.send_excel_file(REQUEST, xls, filename)
|
||||
|
||||
|
||||
def has_existing_decision(M, E, etudid):
|
||||
|
@ -486,7 +486,9 @@ def photos_generate_excel_sample(group_ids=[], REQUEST=None):
|
||||
],
|
||||
extra_cols=["fichier_photo"],
|
||||
)
|
||||
return sco_excel.send_excel_file(REQUEST, data, "ImportPhotos" + scu.XLSX_SUFFIX)
|
||||
breakpoint()
|
||||
return scu.send_file(data, "ImportPhotos", scu.XLSX_SUFFIX, scu.XLSX_MIMETYPE, attached=True)
|
||||
# return sco_excel.send_excel_file(REQUEST, data, "ImportPhotos" + scu.XLSX_SUFFIX)
|
||||
|
||||
|
||||
def photos_import_files_form(group_ids=[], REQUEST=None):
|
||||
|
@ -1937,7 +1937,9 @@ def import_generate_excel_sample(REQUEST, with_codesemestre="1"):
|
||||
data = sco_import_etuds.sco_import_generate_excel_sample(
|
||||
format, with_codesemestre, exclude_cols=["photo_filename"]
|
||||
)
|
||||
return sco_excel.send_excel_file(REQUEST, data, "ImportEtudiants" + scu.XLSX_SUFFIX)
|
||||
breakpoint()
|
||||
return scu.send_file(data, "ImportEtudiants", scu.XLSX_SUFFIX, scu.XLSX_MIMETYPE, attached=True)
|
||||
# return sco_excel.send_excel_file(REQUEST, data, "ImportEtudiants" + scu.XLSX_SUFFIX)
|
||||
|
||||
|
||||
# --- Données admission
|
||||
@ -1955,9 +1957,9 @@ def import_generate_admission_sample(REQUEST, formsemestre_id):
|
||||
exclude_cols=["nationalite", "foto", "photo_filename"],
|
||||
group_ids=[group["group_id"]],
|
||||
)
|
||||
return sco_excel.send_excel_file(
|
||||
REQUEST, data, "AdmissionEtudiants" + scu.XLSX_SUFFIX
|
||||
)
|
||||
breakpoint()
|
||||
return scu.send_file(data, "AdmissionEtudiants", scu.XLSX_SUFFIX, scu.XLSX_MIMETYPE, attached=True)
|
||||
# return sco_excel.send_excel_file(REQUEST, data, "AdmissionEtudiants" + scu.XLSX_SUFFIX)
|
||||
|
||||
|
||||
# --- Données admission depuis fichier excel (version nov 2016)
|
||||
|
@ -65,8 +65,6 @@ from app import log
|
||||
from app.scodoc.sco_exceptions import AccessDenied, ScoValueError
|
||||
from app.scodoc.sco_permissions_check import can_handle_passwd
|
||||
from app.scodoc.TrivialFormulator import TrivialFormulator, tf_error_message
|
||||
from app.scodoc.sco_excel import send_excel_file
|
||||
from app.scodoc.sco_import_users import generate_excel_sample
|
||||
from app.views import users_bp as bp
|
||||
|
||||
|
||||
@ -490,9 +488,9 @@ def create_user_form(REQUEST, user_name=None, edit=0, all_roles=1):
|
||||
def import_users_generate_excel_sample(REQUEST):
|
||||
"une feuille excel pour importation utilisateurs"
|
||||
data = sco_import_users.generate_excel_sample()
|
||||
return sco_excel.send_excel_file(
|
||||
REQUEST, data, "ImportUtilisateurs" + scu.XLSX_SUFFIX
|
||||
)
|
||||
breakpoint()
|
||||
return scu.send_file(data, "ImportUtilisateurs", scu.XLSX_SUFFIX, scu.XLSX_MIMETYPE, attached=True)
|
||||
# return sco_excel.send_excel_file(REQUEST, data, "ImportUtilisateurs" + scu.XLSX_SUFFIX)
|
||||
|
||||
|
||||
@bp.route("/import_users_form", methods=["GET", "POST"])
|
||||
|
Loading…
Reference in New Issue
Block a user