forked from ScoDoc/DocScoDoc
export/import notes ; gentables
This commit is contained in:
parent
b2b325dda9
commit
48ad4f3877
@ -279,7 +279,7 @@ class GenTable(object):
|
||||
"""
|
||||
if format == "html":
|
||||
return self.html()
|
||||
elif format == "xls":
|
||||
elif format == "xls" or format == "xlsx":
|
||||
return self.excel()
|
||||
elif format == "text" or format == "csv":
|
||||
return self.text()
|
||||
@ -465,22 +465,24 @@ class GenTable(object):
|
||||
return "\n".join(H)
|
||||
|
||||
def excel(self, wb=None):
|
||||
"Simple Excel representation of the table"
|
||||
L = sco_excel.ScoExcelSheet(sheet_name=self.xls_sheet_name)
|
||||
style_bold = sco_excel.Excel_MakeStyle(bold=True)
|
||||
|
||||
L.cells += self.xls_before_table
|
||||
L.set_style(style_bold, li=len(L.cells))
|
||||
L.append(self.get_titles_list())
|
||||
L.cells += [[x for x in line] for line in self.get_data_list()]
|
||||
"""Simple Excel representation of the table"""
|
||||
ses = sco_excel.ScoExcelSheet(sheet_name=self.xls_sheet_name, wb=wb)
|
||||
ses.rows += self.xls_before_table
|
||||
style_bold = sco_excel.excel_make_style(bold=True)
|
||||
style_base = sco_excel.excel_make_style()
|
||||
ses.append_row(ses.make_row(self.get_titles_list(), style_bold))
|
||||
for line in self.get_data_list():
|
||||
ses.append_row(ses.make_row(line, style_base))
|
||||
if self.caption:
|
||||
L.append([]) # empty line
|
||||
L.append([self.caption])
|
||||
ses.append_blank_row() # empty line
|
||||
ses.append_single_cell_row(self.caption, style_base)
|
||||
if self.origin:
|
||||
L.append([]) # empty line
|
||||
L.append([self.origin])
|
||||
|
||||
return L.gen_workbook(wb=wb)
|
||||
ses.append_blank_row() # empty line
|
||||
ses.append_single_cell_row(self.origin, style_base)
|
||||
if wb is None:
|
||||
return ses.generate_standalone()
|
||||
else:
|
||||
ses.generate_embeded()
|
||||
|
||||
def text(self):
|
||||
"raw text representation of the table"
|
||||
@ -648,10 +650,10 @@ class GenTable(object):
|
||||
return scu.sendPDFFile(REQUEST, doc, filename + ".pdf")
|
||||
else:
|
||||
return doc
|
||||
elif format == "xls":
|
||||
elif format == "xls" or format == "xlsx":
|
||||
xls = self.excel()
|
||||
if publish:
|
||||
return sco_excel.sendExcelFile(REQUEST, xls, filename + ".xls")
|
||||
return sco_excel.send_excel_file(REQUEST, xls, filename + ".xls")
|
||||
else:
|
||||
return xls
|
||||
elif format == "text":
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -29,6 +29,7 @@
|
||||
|
||||
Formulaire revu en juillet 2016
|
||||
"""
|
||||
import sys
|
||||
import time
|
||||
import datetime
|
||||
import psycopg2
|
||||
@ -178,8 +179,7 @@ def do_evaluation_upload_xls(context, REQUEST):
|
||||
# XXX imaginer un redirect + msg erreur
|
||||
raise AccessDenied("Modification des notes impossible pour %s" % authuser)
|
||||
#
|
||||
data = REQUEST.form["notefile"].read()
|
||||
diag, lines = sco_excel.Excel_to_list(data)
|
||||
diag, lines = sco_excel.excel_file_to_list(REQUEST.form["notefile"])
|
||||
try:
|
||||
if not lines:
|
||||
raise InvalidNoteValue()
|
||||
@ -224,7 +224,7 @@ def do_evaluation_upload_xls(context, REQUEST):
|
||||
ni += 1
|
||||
except:
|
||||
diag.append(
|
||||
'Erreur: feuille invalide ! (erreur ligne %d)<br/>"%s"'
|
||||
'Erreur: Ligne invalide ! (erreur ligne %d)<br/>"%s"'
|
||||
% (ni, str(lines[ni]))
|
||||
)
|
||||
raise InvalidNoteValue()
|
||||
@ -629,7 +629,7 @@ def saisie_notes_tableur(context, evaluation_id, group_ids=[], REQUEST=None):
|
||||
|
||||
H.append(
|
||||
"""<div class="saisienote_etape2">
|
||||
<span class="titredivsaisienote">Etape 2 : chargement d'un fichier de notes</span>""" #'
|
||||
<span class="titredivsaisienote">Etape 2 : chargement d'un fichier de notes</span>""" # '
|
||||
)
|
||||
|
||||
nf = TrivialFormulator(
|
||||
@ -702,7 +702,7 @@ def saisie_notes_tableur(context, evaluation_id, group_ids=[], REQUEST=None):
|
||||
<li><a class="stdlink" href="evaluation_suppress_alln?evaluation_id=%s">Effacer toutes les notes de cette évaluation</a> (ceci permet ensuite de supprimer l'évaluation si besoin)
|
||||
</li>"""
|
||||
% (evaluation_id, evaluation_id)
|
||||
) #'
|
||||
) # '
|
||||
H.append(
|
||||
"""<li><a class="stdlink" href="moduleimpl_status?moduleimpl_id=%(moduleimpl_id)s">Revenir au module</a></li>
|
||||
<li><a class="stdlink" href="saisie_notes?evaluation_id=%(evaluation_id)s">Revenir au formulaire de saisie</a></li>
|
||||
@ -805,8 +805,8 @@ def feuille_saisie_notes(context, evaluation_id, group_ids=[], REQUEST=None):
|
||||
)
|
||||
|
||||
filename = "notes_%s_%s.xls" % (evalname, gr_title_filename)
|
||||
xls = sco_excel.Excel_feuille_saisie(E, sem["titreannee"], description, lines=L)
|
||||
return sco_excel.sendExcelFile(REQUEST, xls, filename)
|
||||
xls = sco_excel.excel_feuille_saisie(E, sem["titreannee"], description, lines=L)
|
||||
return sco_excel.send_excel_file(REQUEST, xls, filename)
|
||||
|
||||
|
||||
def has_existing_decision(context, M, E, etudid):
|
||||
|
@ -1551,6 +1551,7 @@ sco_publish(
|
||||
"/saisie_notes_tableur",
|
||||
sco_saisie_notes.saisie_notes_tableur,
|
||||
Permission.ScoEnsView,
|
||||
methods=["GET", "POST"],
|
||||
)
|
||||
sco_publish(
|
||||
"/feuille_saisie_notes",
|
||||
|
Loading…
Reference in New Issue
Block a user