forked from ScoDoc/ScoDoc
adaptation 9.3.1
This commit is contained in:
parent
21460df51a
commit
38e5e12cbf
|
@ -247,7 +247,7 @@ class ScoExcelSheet:
|
|||
if idx < 26: # one letter key
|
||||
return chr(idx + 65)
|
||||
else: # two letters AA..ZZ
|
||||
first = (idx // 26) + 66
|
||||
first = (idx // 26) + 64
|
||||
second = (idx % 26) + 65
|
||||
return "" + chr(first) + chr(second)
|
||||
|
||||
|
@ -265,6 +265,25 @@ class ScoExcelSheet:
|
|||
else:
|
||||
self.ws.column_dimensions[self.i2col(cle)].width = value
|
||||
|
||||
def set_column_dimension_hidden(self, cle=None, value=21):
|
||||
"""Détermine la largeur d'une colonne. cle -- identifie la colonne ("A" "B", ... ou 0, 1, 2, ...) si None,
|
||||
value donne la liste des largeurs de colonnes depuis A, B, C, ... value -- la dimension (unité : 7 pixels
|
||||
comme affiché dans Excel)
|
||||
"""
|
||||
if cle is None:
|
||||
for i, val in enumerate(value):
|
||||
self.ws.column_dimensions[self.i2col(i)].width = val
|
||||
# No keys: value is a list of widths
|
||||
elif isinstance(cle, str): # accepts set_column_with("D", ...)
|
||||
self.ws.column_dimensions[cle].hidden = value
|
||||
else:
|
||||
self.ws.column_dimensions[self.i2col(cle)].hidden = value
|
||||
|
||||
def merge(self, start_row, end_row, start_column, end_column):
|
||||
self.ws.merged_cells.ranges.append(
|
||||
f"{self.i2col(start_column)}{start_row}:{self.i2col(end_column)}{end_row}"
|
||||
)
|
||||
|
||||
def set_row_dimension_height(self, cle=None, value=21):
|
||||
"""Détermine la hauteur d'une ligne. cle -- identifie la ligne (1, 2, ...) si None,
|
||||
value donne la liste des hauteurs de colonnes depuis 1, 2, 3, ... value -- la dimension
|
||||
|
@ -337,14 +356,15 @@ class ScoExcelSheet:
|
|||
|
||||
return cell
|
||||
|
||||
def make_row(self, values: list, style=None, comments=None) -> list:
|
||||
"build a row"
|
||||
# TODO make possible differents styles in a row
|
||||
def make_row(self, values: list, style=None, comments=None):
|
||||
# styles: a list of style(s) instead of a unique style (in a row)
|
||||
if comments is None:
|
||||
comments = [None] * len(values)
|
||||
if not isinstance(style, list):
|
||||
style = [style] * len(values)
|
||||
return [
|
||||
self.make_cell(value, style, comment)
|
||||
for value, comment in zip(values, comments)
|
||||
self.make_cell(value, a_style, comment)
|
||||
for value, a_style, comment in zip(values, style, comments)
|
||||
]
|
||||
|
||||
def append_single_cell_row(self, value: any, style=None):
|
||||
|
|
|
@ -0,0 +1,221 @@
|
|||
# -*- mode: python -*-
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
# Gestion scolarite IUT
|
||||
#
|
||||
# Copyright (c) 1999 - 2019 Emmanuel Viennet. All rights reserved.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
# Emmanuel Viennet emmanuel.viennet@viennet.net
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
|
||||
""" Excel file handling
|
||||
"""
|
||||
|
||||
# from sco_utils import *
|
||||
# from sco_excel import *
|
||||
import time, datetime
|
||||
|
||||
from openpyxl.styles import Font, Alignment, PatternFill, Side, Border
|
||||
|
||||
from app.scodoc.sco_excel import COLORS
|
||||
|
||||
|
||||
def make_font(
|
||||
bold=False,
|
||||
italic=False,
|
||||
font_name=None,
|
||||
font_size=None,
|
||||
color=COLORS.BLACK.value,
|
||||
style=None,
|
||||
uline=False,
|
||||
):
|
||||
font = None
|
||||
if bold or italic or font_name or font_size:
|
||||
font = Font()
|
||||
if bold:
|
||||
font.bold = bold
|
||||
if uline:
|
||||
font.underline = Font.UNDERLINE_SINGLE
|
||||
if italic:
|
||||
font.italic = italic
|
||||
font.name = font_name if font_name else "Arial"
|
||||
if font_size:
|
||||
font.height = 20 * font_size
|
||||
if color:
|
||||
font.color = color
|
||||
if font and style:
|
||||
style["font"] = font
|
||||
return font
|
||||
|
||||
|
||||
def make_alignment(halign=None, valign=None, orientation=None, style=None):
|
||||
alignment = None
|
||||
if halign or valign or orientation:
|
||||
alignment = Alignment()
|
||||
if halign:
|
||||
alignment.horz = halign
|
||||
if valign:
|
||||
alignment.vert = valign
|
||||
if orientation:
|
||||
alignment.rota = orientation
|
||||
if alignment and style:
|
||||
breakpoint()
|
||||
style["alignment"] = alignment
|
||||
return alignment
|
||||
|
||||
|
||||
def make_numfmt(fmt, style=None):
|
||||
if fmt and style:
|
||||
style["num_format_str"] = fmt
|
||||
|
||||
|
||||
def make_pattern(bgcolor, style=None):
|
||||
pattern = PatternFill(fill_type="solid", fgColor=bgcolor)
|
||||
if pattern and style:
|
||||
style["fill"] = pattern
|
||||
return pattern
|
||||
|
||||
|
||||
Sides = {
|
||||
"none": Side(border_style=None),
|
||||
"thin": Side(border_style="thin"),
|
||||
"medium": Side(border_style="medium"),
|
||||
"thick": Side(border_style="thick"),
|
||||
"filet": Side(border_style="hair"),
|
||||
}
|
||||
|
||||
|
||||
def make_borders(left=None, top=None, bottom=None, right=None, style=None):
|
||||
border = None
|
||||
if left or right or top or bottom:
|
||||
border = Border()
|
||||
if left:
|
||||
border.left = Sides[left]
|
||||
if right:
|
||||
border.right = Sides[right]
|
||||
if top:
|
||||
border.top = Sides[top]
|
||||
if bottom:
|
||||
border.bottom = Sides[bottom]
|
||||
if border and style:
|
||||
style["border"] = border
|
||||
return border
|
||||
|
||||
|
||||
#
|
||||
#
|
||||
# def Excel_MakeStyle(
|
||||
# bold=False,
|
||||
# italic=False,
|
||||
# color="black",
|
||||
# bgcolor=None,
|
||||
# halign=None,
|
||||
# valign=None,
|
||||
# orientation=None,
|
||||
# font_name=None,
|
||||
# font_size=None,
|
||||
# ):
|
||||
# style = XFStyle()
|
||||
# make_font(bold, italic, font_name, font_size, color, style=style)
|
||||
# make_alignment(halign, valign, orientation, style=style)
|
||||
# make_pattern(bgcolor, style=style)
|
||||
# return style
|
||||
#
|
||||
#
|
||||
# class ScoExcelSheetExt(ScoExcelSheet):
|
||||
# def __init__(self, sheet_name="feuille", default_style=None):
|
||||
# ScoExcelSheet.__init__(self, sheet_name, default_style)
|
||||
# self.cols_width = {}
|
||||
# self.row_height = {}
|
||||
# self.merged = []
|
||||
# self.panes_frozen = False
|
||||
# self.horz_split_pos = 0
|
||||
# self.vert_split_pos = 0
|
||||
#
|
||||
# def set_panes(self, panes_frozen=True, horz_split_pos=0, vert_split_pos=0):
|
||||
# self.panes_frozen = panes_frozen
|
||||
# self.horz_split_pos = horz_split_pos
|
||||
# self.vert_split_pos = vert_split_pos
|
||||
#
|
||||
# def set_cols_width(self, cols_width):
|
||||
# self.cols_width = cols_width
|
||||
#
|
||||
# def set_row_height(self, row_height):
|
||||
# self.row_height = row_height
|
||||
#
|
||||
# def add_merged(self, first_row, last_row, first_col, last_col, value, style):
|
||||
# self.merged.append((first_row, last_row, first_col, last_col, value, style))
|
||||
#
|
||||
# def gen_workbook(self, wb=None):
|
||||
# """Generates and returns a workbook from stored data.
|
||||
# If wb, add a sheet (tab) to the existing workbook (in this case, returns None).
|
||||
# """
|
||||
# if wb == None:
|
||||
# wb = Workbook() # Création du fichier
|
||||
# sauvegarde = True
|
||||
# else:
|
||||
# sauvegarde = False
|
||||
# ws0 = wb.add_sheet(self.sheet_name.decode(SCO_ENCODING))
|
||||
# li = 0
|
||||
# for l in self.cells:
|
||||
# co = 0
|
||||
# for c in l:
|
||||
# # safety net: allow only str, int and float
|
||||
# if type(c) == LongType:
|
||||
# c = int(c) # assume all ScoDoc longs fits in int !
|
||||
# elif type(c) not in (IntType, FloatType):
|
||||
# c = str(c).decode(SCO_ENCODING)
|
||||
#
|
||||
# ws0.write(li, co, c, self.get_cell_style(li, co))
|
||||
# co += 1
|
||||
# li += 1
|
||||
# for first_row, last_row, first_col, last_col, value, style in self.merged:
|
||||
# ws0.write_merge(
|
||||
# first_row,
|
||||
# last_row,
|
||||
# first_col,
|
||||
# last_col,
|
||||
# str(value).decode(SCO_ENCODING),
|
||||
# style,
|
||||
# )
|
||||
# for col_no in range(len(self.cols_width)):
|
||||
# width = self.cols_width[col_no]
|
||||
# ws0.col(col_no).width = abs(width) * 110 / 3
|
||||
# if width < 0:
|
||||
# ws0.col(col_no).hidden = True
|
||||
# row_styles = {}
|
||||
# for row_no in range(len(self.row_height)):
|
||||
# height = self.row_height[row_no]
|
||||
# if height not in row_styles:
|
||||
# fnt = Font()
|
||||
# fnt.height = height * 12
|
||||
# row_styles[height] = XFStyle()
|
||||
# row_styles[height].font = fnt
|
||||
# ws0.row(row_no).set_style(row_styles[height]) # Excel way
|
||||
# ws0.row(row_no).height = height * 19 / 2 # Libre-Office compatibilité
|
||||
# if self.panes_frozen:
|
||||
# ws0.panes_frozen = self.panes_frozen
|
||||
# ws0.horz_split_pos = self.vert_split_pos
|
||||
# ws0.vert_split_pos = self.horz_split_pos
|
||||
# if sauvegarde:
|
||||
# return wb.savetostr()
|
||||
# else:
|
||||
# return None
|
|
@ -408,6 +408,11 @@ def formsemestre_status_menubar(sem):
|
|||
"endpoint": "notes.feuille_preparation_jury",
|
||||
"args": {"formsemestre_id": formsemestre_id},
|
||||
},
|
||||
{
|
||||
"title": "Générer feuille préparation Jury DUT",
|
||||
"endpoint": "notes.feuille_preparation_jury_dut",
|
||||
"args": {"formsemestre_id": formsemestre_id},
|
||||
},
|
||||
{
|
||||
"title": "Saisie des décisions du jury",
|
||||
"endpoint": "notes.formsemestre_saisie_jury",
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -127,6 +127,7 @@ from app.scodoc import sco_placement
|
|||
from app.scodoc import sco_poursuite_dut
|
||||
from app.scodoc import sco_preferences
|
||||
from app.scodoc import sco_prepajury
|
||||
from app.scodoc import sco_prepajury_iuta
|
||||
from app.scodoc import sco_pvjury
|
||||
from app.scodoc import sco_recapcomplet
|
||||
from app.scodoc import sco_report
|
||||
|
@ -2687,6 +2688,11 @@ sco_publish(
|
|||
sco_prepajury.feuille_preparation_jury,
|
||||
Permission.ScoView,
|
||||
)
|
||||
sco_publish(
|
||||
"/feuille_preparation_jury_dut",
|
||||
sco_prepajury_iuta.feuille_preparation_jury_dut,
|
||||
Permission.ScoView,
|
||||
)
|
||||
sco_publish(
|
||||
"/formsemestre_archive",
|
||||
sco_archives.formsemestre_archive,
|
||||
|
|
Loading…
Reference in New Issue