diff --git a/app/scodoc/gen_tables.py b/app/scodoc/gen_tables.py
index a9ed10aaf..855545556 100644
--- a/app/scodoc/gen_tables.py
+++ b/app/scodoc/gen_tables.py
@@ -58,6 +58,7 @@ from app.scodoc import sco_utils as scu
from app.scodoc import sco_excel
from app.scodoc import sco_pdf
from app.scodoc import sco_xml
+from app.scodoc.sco_exceptions import ScoPDFFormatError
from app.scodoc.sco_pdf import SU
from app import log
@@ -539,17 +540,18 @@ class GenTable(object):
#
# titles = ["%s" % x for x in self.get_titles_list()]
pdf_style_list = []
- Pt = [
- [Paragraph(SU(str(x)), CellStyle) for x in line]
- for line in (
- self.get_data_list(
- pdf_mode=True,
- pdf_style_list=pdf_style_list,
- with_titles=True,
- omit_hidden_lines=True,
- )
- )
- ]
+ data_list = self.get_data_list(
+ pdf_mode=True,
+ pdf_style_list=pdf_style_list,
+ with_titles=True,
+ omit_hidden_lines=True,
+ )
+ try:
+ Pt = [
+ [Paragraph(SU(str(x)), CellStyle) for x in line] for line in data_list
+ ]
+ except ValueError as exc:
+ raise ScoPDFFormatError(str(exc)) from exc
pdf_style_list += self.pdf_table_style
T = Table(Pt, repeatRows=1, colWidths=self.pdf_col_widths, style=pdf_style_list)
diff --git a/app/scodoc/sco_exceptions.py b/app/scodoc/sco_exceptions.py
index c563c93e6..d975766ef 100644
--- a/app/scodoc/sco_exceptions.py
+++ b/app/scodoc/sco_exceptions.py
@@ -60,6 +60,21 @@ class ScoFormatError(ScoValueError):
pass
+class ScoPDFFormatError(ScoValueError):
+ "erreur génération PDF (templates platypus, ...)"
+
+ def __init__(self, msg, dest_url=None):
+ super().__init__(
+ f"""Erreur dans un format pdf:
+
{msg}
+ Vérifiez les paramètres (polices de caractères, balisage)
+ dans les paramètres ou préférences.
+
+ """,
+ dest_url=dest_url,
+ )
+
+
class ScoInvalidDept(ScoValueError):
"""departement invalide"""
diff --git a/app/scodoc/sco_groups_view.py b/app/scodoc/sco_groups_view.py
index 603627d14..df4c55e98 100644
--- a/app/scodoc/sco_groups_view.py
+++ b/app/scodoc/sco_groups_view.py
@@ -815,7 +815,7 @@ def tab_absences_html(groups_infos, etat=None):
% (groups_infos.base_url, groups_infos.groups_titles),
"""Trombinoscope en PDF"""
% groups_infos.groups_query_args,
- """Trombinoscope en PDF (format "IUT de Tours", beta)"""
+ """Trombinoscope en PDF (format "IUT de Tours")"""
% groups_infos.groups_query_args,
"""Feuille relevé absences hebdomadaire (beta)"""
% groups_infos.groups_query_args,
diff --git a/app/scodoc/sco_preferences.py b/app/scodoc/sco_preferences.py
index 3dd413f50..a0d9b010b 100644
--- a/app/scodoc/sco_preferences.py
+++ b/app/scodoc/sco_preferences.py
@@ -762,7 +762,7 @@ class BasePreferences(object):
{
"initvalue": "Helvetica",
"title": "Police de caractère principale",
- "explanation": "pour les pdf",
+ "explanation": "pour les pdf (Helvetica est recommandée)",
"size": 25,
"category": "pdf",
},
diff --git a/app/scodoc/sco_trombino_tours.py b/app/scodoc/sco_trombino_tours.py
index e7f2266fb..3861bb74f 100644
--- a/app/scodoc/sco_trombino_tours.py
+++ b/app/scodoc/sco_trombino_tours.py
@@ -44,6 +44,7 @@ from app.scodoc import sco_groups_view
from app.scodoc import sco_preferences
from app.scodoc import sco_trombino
from app.scodoc import sco_etud
+from app.scodoc.sco_exceptions import ScoPDFFormatError
from app.scodoc.sco_pdf import *
@@ -268,7 +269,10 @@ def pdf_trombino_tours(
preferences=sco_preferences.SemPreferences(),
)
)
- document.build(objects)
+ try:
+ document.build(objects)
+ except (ValueError, KeyError) as exc:
+ raise ScoPDFFormatError(str(exc)) from exc
data = report.getvalue()
return scu.sendPDFFile(data, filename)
diff --git a/app/views/users.py b/app/views/users.py
index af4a721ed..cc9b9db01 100644
--- a/app/views/users.py
+++ b/app/views/users.py
@@ -151,6 +151,8 @@ def user_info(user_name, format="json"):
@scodoc7func
def create_user_form(user_name=None, edit=0, all_roles=1):
"form. création ou edition utilisateur"
+ if user_name is not None: # scodoc7func converti en int !
+ user_name = str(user_name)
auth_dept = current_user.dept
from_mail = current_user.email
initvalues = {}
@@ -745,6 +747,8 @@ def user_info_page(user_name=None):
"""
from app.scodoc.sco_permissions_check import can_handle_passwd
+ if user_name is not None: # scodoc7func converti en int !
+ user_name = str(user_name)
# peut on divulguer ces infos ?
if not can_handle_passwd(current_user, allow_admindepts=True):
raise AccessDenied("Vous n'avez pas la permission de voir cette page")
@@ -753,7 +757,7 @@ def user_info_page(user_name=None):
if not user_name:
user = current_user
else:
- user = User.query.filter_by(user_name=str(user_name)).first()
+ user = User.query.filter_by(user_name=user_name).first()
if not user:
raise ScoValueError("invalid user_name")
@@ -802,6 +806,8 @@ def form_change_password(user_name=None):
"""Formulaire de changement mot de passe de l'utilisateur user_name.
Un utilisateur peut toujours changer son propre mot de passe.
"""
+ if user_name is not None: # scodoc7func converti en int !
+ user_name = str(user_name)
if not user_name:
user = current_user
else:
@@ -850,6 +856,8 @@ def form_change_password(user_name=None):
@scodoc7func
def change_password(user_name, password, password2):
"Change the password for user given by user_name"
+ if user_name is not None: # scodoc7func converti en int !
+ user_name = str(user_name)
u = User.query.filter_by(user_name=user_name).first()
# Check access permission
if not can_handle_passwd(u):
@@ -909,6 +917,8 @@ def change_password(user_name, password, password2):
@permission_required(Permission.ScoUsersAdmin)
def toggle_active_user(user_name: str = None):
"""Change active status of a user account"""
+ if user_name is not None: # scodoc7func converti en int !
+ user_name = str(user_name)
u = User.query.filter_by(user_name=user_name).first()
if not u:
raise ScoValueError("invalid user_name")
diff --git a/tools/import_scodoc7_dept.py b/tools/import_scodoc7_dept.py
index cedf0a936..597b9baf6 100644
--- a/tools/import_scodoc7_dept.py
+++ b/tools/import_scodoc7_dept.py
@@ -389,6 +389,7 @@ def convert_object(
new_ref = None
elif is_table and table_name in {
"notes_semset_formsemestre",
+ "entreprise_contact",
}:
# pour anciennes installs où des relations n'avait pas été déclarées clés étrangères
# eg: notes_semset_formsemestre.semset_id n'était pas une clé