Merge branch 'master' of https://scodoc.org/git/viennet/ScoDoc into refactor_nt
This commit is contained in:
commit
0b87714ac0
@ -58,6 +58,7 @@ from app.scodoc import sco_utils as scu
|
|||||||
from app.scodoc import sco_excel
|
from app.scodoc import sco_excel
|
||||||
from app.scodoc import sco_pdf
|
from app.scodoc import sco_pdf
|
||||||
from app.scodoc import sco_xml
|
from app.scodoc import sco_xml
|
||||||
|
from app.scodoc.sco_exceptions import ScoPDFFormatError
|
||||||
from app.scodoc.sco_pdf import SU
|
from app.scodoc.sco_pdf import SU
|
||||||
from app import log
|
from app import log
|
||||||
|
|
||||||
@ -539,17 +540,18 @@ class GenTable(object):
|
|||||||
#
|
#
|
||||||
# titles = ["<para><b>%s</b></para>" % x for x in self.get_titles_list()]
|
# titles = ["<para><b>%s</b></para>" % x for x in self.get_titles_list()]
|
||||||
pdf_style_list = []
|
pdf_style_list = []
|
||||||
Pt = [
|
data_list = self.get_data_list(
|
||||||
[Paragraph(SU(str(x)), CellStyle) for x in line]
|
|
||||||
for line in (
|
|
||||||
self.get_data_list(
|
|
||||||
pdf_mode=True,
|
pdf_mode=True,
|
||||||
pdf_style_list=pdf_style_list,
|
pdf_style_list=pdf_style_list,
|
||||||
with_titles=True,
|
with_titles=True,
|
||||||
omit_hidden_lines=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
|
pdf_style_list += self.pdf_table_style
|
||||||
T = Table(Pt, repeatRows=1, colWidths=self.pdf_col_widths, style=pdf_style_list)
|
T = Table(Pt, repeatRows=1, colWidths=self.pdf_col_widths, style=pdf_style_list)
|
||||||
|
|
||||||
|
@ -60,6 +60,21 @@ class ScoFormatError(ScoValueError):
|
|||||||
pass
|
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:
|
||||||
|
<p>{msg}</p>
|
||||||
|
<p>Vérifiez les paramètres (polices de caractères, balisage)
|
||||||
|
dans les paramètres ou préférences.
|
||||||
|
</p>
|
||||||
|
""",
|
||||||
|
dest_url=dest_url,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class ScoInvalidDept(ScoValueError):
|
class ScoInvalidDept(ScoValueError):
|
||||||
"""departement invalide"""
|
"""departement invalide"""
|
||||||
|
|
||||||
|
@ -815,7 +815,7 @@ def tab_absences_html(groups_infos, etat=None):
|
|||||||
% (groups_infos.base_url, groups_infos.groups_titles),
|
% (groups_infos.base_url, groups_infos.groups_titles),
|
||||||
"""<li><a class="stdlink" href="trombino?%s&format=pdf">Trombinoscope en PDF</a></li>"""
|
"""<li><a class="stdlink" href="trombino?%s&format=pdf">Trombinoscope en PDF</a></li>"""
|
||||||
% groups_infos.groups_query_args,
|
% groups_infos.groups_query_args,
|
||||||
"""<li><a class="stdlink" href="pdf_trombino_tours?%s&format=pdf">Trombinoscope en PDF (format "IUT de Tours", beta)</a></li>"""
|
"""<li><a class="stdlink" href="pdf_trombino_tours?%s&format=pdf">Trombinoscope en PDF (format "IUT de Tours")</a></li>"""
|
||||||
% groups_infos.groups_query_args,
|
% groups_infos.groups_query_args,
|
||||||
"""<li><a class="stdlink" href="pdf_feuille_releve_absences?%s&format=pdf">Feuille relevé absences hebdomadaire (beta)</a></li>"""
|
"""<li><a class="stdlink" href="pdf_feuille_releve_absences?%s&format=pdf">Feuille relevé absences hebdomadaire (beta)</a></li>"""
|
||||||
% groups_infos.groups_query_args,
|
% groups_infos.groups_query_args,
|
||||||
|
@ -762,7 +762,7 @@ class BasePreferences(object):
|
|||||||
{
|
{
|
||||||
"initvalue": "Helvetica",
|
"initvalue": "Helvetica",
|
||||||
"title": "Police de caractère principale",
|
"title": "Police de caractère principale",
|
||||||
"explanation": "pour les pdf",
|
"explanation": "pour les pdf (Helvetica est recommandée)",
|
||||||
"size": 25,
|
"size": 25,
|
||||||
"category": "pdf",
|
"category": "pdf",
|
||||||
},
|
},
|
||||||
|
@ -44,6 +44,7 @@ from app.scodoc import sco_groups_view
|
|||||||
from app.scodoc import sco_preferences
|
from app.scodoc import sco_preferences
|
||||||
from app.scodoc import sco_trombino
|
from app.scodoc import sco_trombino
|
||||||
from app.scodoc import sco_etud
|
from app.scodoc import sco_etud
|
||||||
|
from app.scodoc.sco_exceptions import ScoPDFFormatError
|
||||||
from app.scodoc.sco_pdf import *
|
from app.scodoc.sco_pdf import *
|
||||||
|
|
||||||
|
|
||||||
@ -268,7 +269,10 @@ def pdf_trombino_tours(
|
|||||||
preferences=sco_preferences.SemPreferences(),
|
preferences=sco_preferences.SemPreferences(),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
try:
|
||||||
document.build(objects)
|
document.build(objects)
|
||||||
|
except (ValueError, KeyError) as exc:
|
||||||
|
raise ScoPDFFormatError(str(exc)) from exc
|
||||||
data = report.getvalue()
|
data = report.getvalue()
|
||||||
|
|
||||||
return scu.sendPDFFile(data, filename)
|
return scu.sendPDFFile(data, filename)
|
||||||
|
@ -151,6 +151,8 @@ def user_info(user_name, format="json"):
|
|||||||
@scodoc7func
|
@scodoc7func
|
||||||
def create_user_form(user_name=None, edit=0, all_roles=1):
|
def create_user_form(user_name=None, edit=0, all_roles=1):
|
||||||
"form. création ou edition utilisateur"
|
"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
|
auth_dept = current_user.dept
|
||||||
from_mail = current_user.email
|
from_mail = current_user.email
|
||||||
initvalues = {}
|
initvalues = {}
|
||||||
@ -745,6 +747,8 @@ def user_info_page(user_name=None):
|
|||||||
"""
|
"""
|
||||||
from app.scodoc.sco_permissions_check import can_handle_passwd
|
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 ?
|
# peut on divulguer ces infos ?
|
||||||
if not can_handle_passwd(current_user, allow_admindepts=True):
|
if not can_handle_passwd(current_user, allow_admindepts=True):
|
||||||
raise AccessDenied("Vous n'avez pas la permission de voir cette page")
|
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:
|
if not user_name:
|
||||||
user = current_user
|
user = current_user
|
||||||
else:
|
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:
|
if not user:
|
||||||
raise ScoValueError("invalid user_name")
|
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.
|
"""Formulaire de changement mot de passe de l'utilisateur user_name.
|
||||||
Un utilisateur peut toujours changer son propre mot de passe.
|
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:
|
if not user_name:
|
||||||
user = current_user
|
user = current_user
|
||||||
else:
|
else:
|
||||||
@ -850,6 +856,8 @@ def form_change_password(user_name=None):
|
|||||||
@scodoc7func
|
@scodoc7func
|
||||||
def change_password(user_name, password, password2):
|
def change_password(user_name, password, password2):
|
||||||
"Change the password for user given by user_name"
|
"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()
|
u = User.query.filter_by(user_name=user_name).first()
|
||||||
# Check access permission
|
# Check access permission
|
||||||
if not can_handle_passwd(u):
|
if not can_handle_passwd(u):
|
||||||
@ -909,6 +917,8 @@ def change_password(user_name, password, password2):
|
|||||||
@permission_required(Permission.ScoUsersAdmin)
|
@permission_required(Permission.ScoUsersAdmin)
|
||||||
def toggle_active_user(user_name: str = None):
|
def toggle_active_user(user_name: str = None):
|
||||||
"""Change active status of a user account"""
|
"""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()
|
u = User.query.filter_by(user_name=user_name).first()
|
||||||
if not u:
|
if not u:
|
||||||
raise ScoValueError("invalid user_name")
|
raise ScoValueError("invalid user_name")
|
||||||
|
@ -389,6 +389,7 @@ def convert_object(
|
|||||||
new_ref = None
|
new_ref = None
|
||||||
elif is_table and table_name in {
|
elif is_table and table_name in {
|
||||||
"notes_semset_formsemestre",
|
"notes_semset_formsemestre",
|
||||||
|
"entreprise_contact",
|
||||||
}:
|
}:
|
||||||
# pour anciennes installs où des relations n'avait pas été déclarées clés étrangères
|
# 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é
|
# eg: notes_semset_formsemestre.semset_id n'était pas une clé
|
||||||
|
Loading…
Reference in New Issue
Block a user