ScoDoc/app/scodoc/sco_bulletins_signature.py

106 lines
3.7 KiB
Python
Raw Permalink Normal View History

2020-09-26 16:19:37 +02:00
# -*- mode: python -*-
# -*- coding: utf-8 -*-
##############################################################################
#
# Gestion scolarite IUT
#
2023-12-31 23:04:06 +01:00
# Copyright (c) 1999 - 2024 Emmanuel Viennet. All rights reserved.
2020-09-26 16:19:37 +02:00
#
# 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
#
##############################################################################
"""Signature des bulletin pdf
XXX en projet, non finalisé: on peut utiliser en attendant les paramétrages des bulletins (malcommodes).
2021-06-17 00:08:37 +02:00
Il ne s'agit pas d'une "signature" électronique, mais simplement d'une image
2020-09-26 16:19:37 +02:00
que l'on intègre dans les documents pdf générés (bulletins, classeur des bulletins,
envois par mail).
La signature est controlée par:
- la présence d'un fichier .../ScoDoc/static/signatures/<DeptId>/<formsemestre_id>/bul_sig_{left|right}
ou, à défaut, .../ScoDoc/signatures/<DeptId>/bul_sig_{left|right}
2023-12-31 23:04:06 +01:00
- les préférences booléennes bul_sig_left et bul_sig_right
2020-09-26 16:19:37 +02:00
(ne pas confondre avec bul_show_sig_left...)
2023-12-31 23:04:06 +01:00
- les préférences bul_sig_left_image_height et bul_sig_right_image_height
2020-09-26 16:19:37 +02:00
(hauteur de l'image, float, en mm)
API:
- form_change_bul_sig( side = "left" | "right", [formsemestre_id])
affiche signature courante, soit globale soit pour le semestre
upload nouvelle
- set_bul_sig( side = "left", [formsemestre_id], image )
Lien sur Scolarite/edit_preferences (sans formsemestre_id)
et sur page "réglages bulletin" (avec formsemestre_id)
"""
2021-02-01 16:23:11 +01:00
# import os
# def form_change_bul_sig(side, formsemestre_id=None):
2021-02-01 16:23:11 +01:00
# """Change pdf signature"""
# filename = _get_sig_existing_filename(
# side, formsemestre_id=formsemestre_id
2021-02-01 16:23:11 +01:00
# )
# if side == "left":
# sidetxt = "gauche"
# elif side == "right":
# sidetxt = "droite"
# else:
# raise ValueError("invalid value for 'side' parameter")
# signatureloc = get_bul_sig_img()
# H = [
# self.sco_header(page_title="Changement de signature"),
2021-02-01 16:23:11 +01:00
# """<h2>Changement de la signature bulletin de %(sidetxt)s</h2>
# """
# % (sidetxt,),
# ]
# "<p>Photo actuelle (%(signatureloc)s): "
# def get_bul_sig_img(side, formsemestre_id=None):
2021-02-01 16:23:11 +01:00
# "send back signature image data"
# # slow, not cached, used for unfrequent access (do not bypass python)
# def _sig_filename(side, formsemestre_id=None):
2021-02-01 16:23:11 +01:00
# if not side in ("left", "right"):
# raise ValueError("side must be left or right")
2021-08-21 15:17:14 +02:00
# dirs = [SCODOC_LOGOS_DIR, g.scodoc_dept]
2021-02-01 16:23:11 +01:00
# if formsemestre_id:
# dirs.append(formsemestre_id)
# dirs.append("bul_sig_{}".format(side))
# return os.path.join(*dirs)
# def _get_sig_existing_filename(side, formsemestre_id=None):
2021-02-01 16:23:11 +01:00
# "full path to signature to use, or None if no signature available"
# if formsemestre_id:
# filename = _sig_filename(side, formsemestre_id=formsemestre_id)
2021-02-01 16:23:11 +01:00
# if os.path.exists(filename):
# return filename
# filename = _sig_filename(side)
2021-02-01 16:23:11 +01:00
# if os.path.exists(filename):
# return filename
# else:
# return None