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"],
|
extra_cols=["fichier_a_charger"],
|
||||||
)
|
)
|
||||||
return sco_excel.send_excel_file(
|
breakpoint()
|
||||||
REQUEST, data, "ImportFichiersEtudiants" + scu.XLSX_SUFFIX
|
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):
|
def etudarchive_import_files_form(group_id, REQUEST=None):
|
||||||
|
@ -35,10 +35,6 @@ from enum import Enum
|
|||||||
from tempfile import NamedTemporaryFile
|
from tempfile import NamedTemporaryFile
|
||||||
|
|
||||||
import openpyxl.utils.datetime
|
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.styles.numbers import FORMAT_NUMBER_00, FORMAT_GENERAL
|
||||||
from openpyxl.comments import Comment
|
from openpyxl.comments import Comment
|
||||||
from openpyxl import Workbook, load_workbook
|
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
|
import app.scodoc.sco_utils as scu
|
||||||
from app.scodoc import notesdb
|
from app.scodoc import notesdb
|
||||||
from app.scodoc import sco_preferences
|
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 import log
|
||||||
from app.scodoc.sco_exceptions import ScoValueError
|
from app.scodoc.sco_exceptions import ScoValueError
|
||||||
|
|
||||||
@ -65,24 +59,25 @@ class COLORS(Enum):
|
|||||||
LIGHT_YELLOW = "FFFFFF99"
|
LIGHT_YELLOW = "FFFFFF99"
|
||||||
|
|
||||||
|
|
||||||
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)
|
||||||
"""
|
# """
|
||||||
filename = (
|
# filename = (
|
||||||
scu.unescape_html(scu.suppress_accents(filename))
|
# scu.unescape_html(scu.suppress_accents(filename))
|
||||||
.replace("&", "")
|
# .replace("&", "")
|
||||||
.replace(" ", "_")
|
# .replace(" ", "_")
|
||||||
)
|
# )
|
||||||
request.RESPONSE.setHeader("content-type", mime)
|
# request.RESPONSE.setHeader("content-type", mime)
|
||||||
request.RESPONSE.setHeader(
|
# request.RESPONSE.setHeader(
|
||||||
"content-disposition", 'attachment; filename="%s"' % filename
|
# "content-disposition", 'attachment; filename="%s"' % filename
|
||||||
)
|
# )
|
||||||
return data
|
# return data
|
||||||
|
|
||||||
|
|
||||||
# Un style est enregistré comme un dictionnaire qui précise la valeur d'un attributdans la liste suivante:
|
# 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):
|
def xldate_as_datetime(xldate, datemode=0):
|
||||||
@ -129,7 +124,8 @@ class ScoExcelBook:
|
|||||||
"""
|
"""
|
||||||
for sheet in self.sheets:
|
for sheet in self.sheets:
|
||||||
sheet.prepare()
|
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:
|
with NamedTemporaryFile() as tmp:
|
||||||
self.wb.save(tmp.name)
|
self.wb.save(tmp.name)
|
||||||
tmp.seek(0)
|
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,
|
REQUEST.AUTHENTICATED_USER,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
xls = ws.generate_standalone()
|
xls = ws.generate()
|
||||||
return sco_excel.send_excel_file(REQUEST, xls, f"PrepaJury{sn}{scu.XLSX_SUFFIX}")
|
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)
|
filename = "notes_%s_%s.xlsx" % (evalname, gr_title_filename)
|
||||||
xls = sco_excel.excel_feuille_saisie(E, sem["titreannee"], description, lines=L)
|
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):
|
def has_existing_decision(M, E, etudid):
|
||||||
|
@ -486,7 +486,9 @@ def photos_generate_excel_sample(group_ids=[], REQUEST=None):
|
|||||||
],
|
],
|
||||||
extra_cols=["fichier_photo"],
|
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):
|
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(
|
data = sco_import_etuds.sco_import_generate_excel_sample(
|
||||||
format, with_codesemestre, exclude_cols=["photo_filename"]
|
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
|
# --- Données admission
|
||||||
@ -1955,9 +1957,9 @@ def import_generate_admission_sample(REQUEST, formsemestre_id):
|
|||||||
exclude_cols=["nationalite", "foto", "photo_filename"],
|
exclude_cols=["nationalite", "foto", "photo_filename"],
|
||||||
group_ids=[group["group_id"]],
|
group_ids=[group["group_id"]],
|
||||||
)
|
)
|
||||||
return sco_excel.send_excel_file(
|
breakpoint()
|
||||||
REQUEST, data, "AdmissionEtudiants" + scu.XLSX_SUFFIX
|
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)
|
# --- 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_exceptions import AccessDenied, ScoValueError
|
||||||
from app.scodoc.sco_permissions_check import can_handle_passwd
|
from app.scodoc.sco_permissions_check import can_handle_passwd
|
||||||
from app.scodoc.TrivialFormulator import TrivialFormulator, tf_error_message
|
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
|
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):
|
def import_users_generate_excel_sample(REQUEST):
|
||||||
"une feuille excel pour importation utilisateurs"
|
"une feuille excel pour importation utilisateurs"
|
||||||
data = sco_import_users.generate_excel_sample()
|
data = sco_import_users.generate_excel_sample()
|
||||||
return sco_excel.send_excel_file(
|
breakpoint()
|
||||||
REQUEST, data, "ImportUtilisateurs" + scu.XLSX_SUFFIX
|
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"])
|
@bp.route("/import_users_form", methods=["GET", "POST"])
|
||||||
|
Loading…
Reference in New Issue
Block a user