Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SCODOC_R6A06
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Paul Milleville
SCODOC_R6A06
Commits
36a5c15e
Commit
36a5c15e
authored
1 year ago
by
Emmanuel Viennet
Browse files
Options
Downloads
Patches
Plain Diff
améliore légèrement le traitement des exceptions pdf
parent
1cf9d87f
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/scodoc/sco_bulletins_standard.py
+45
-25
45 additions, 25 deletions
app/scodoc/sco_bulletins_standard.py
app/scodoc/sco_pdf.py
+6
-3
6 additions, 3 deletions
app/scodoc/sco_pdf.py
with
51 additions
and
28 deletions
app/scodoc/sco_bulletins_standard.py
+
45
−
25
View file @
36a5c15e
...
...
@@ -46,16 +46,20 @@ de la forme %(XXX)s sont remplacées par la valeur de XXX, pour XXX dans:
Balises img: actuellement interdites.
"""
from
flask
import
url_for
,
g
from
reportlab.platypus
import
KeepTogether
,
Paragraph
,
Spacer
,
Table
from
reportlab.lib.units
import
cm
,
mm
from
flask
import
g
,
url_for
from
reportlab.lib.colors
import
Color
,
blue
from
reportlab.lib.units
import
cm
,
mm
from
reportlab.platypus
import
KeepTogether
,
Paragraph
,
Spacer
,
Table
import
app.scodoc.sco_utils
as
scu
from
app.scodoc.sco_pdf
import
SU
,
make_paras
from
app.scodoc
import
sco_preferences
from
app.scodoc.sco_permissions
import
Permission
from
app.scodoc
import
(
gen_tables
,
sco_bulletins_generator
,
sco_bulletins_pdf
,
sco_evaluations
,
sco_groups
,
sco_preferences
,
)
from
app.scodoc.codes_cursus
import
(
UE_COLORS
,
UE_DEFAULT_COLOR
,
...
...
@@ -63,17 +67,17 @@ from app.scodoc.codes_cursus import (
UE_SPORT
,
UE_STANDARD
,
)
from
app.scodoc
import
sco_bulletins_generator
from
app.scodoc
import
sco_bulletins_pdf
from
app.scodoc
import
sco_groups
from
app.scodoc
import
sco_evaluations
from
app.scodoc
import
gen_tables
from
app.scodoc.sco_exceptions
import
ScoPDFFormatError
from
app.scodoc.sco_pdf
import
SU
,
make_paras
from
app.scodoc.sco_permissions
import
Permission
# Important: Le nom de la classe ne doit pas changer (bien le choisir),
# car il sera stocké en base de données (dans les préférences)
class
BulletinGeneratorStandard
(
sco_bulletins_generator
.
BulletinGenerator
):
description
=
"
standard ScoDoc (version 2011)
"
# la description doit être courte: elle apparait dans le menu de paramètrage ScoDoc
"
Les bulletins standards
"
# la description doit être courte: elle apparait dans le menu de paramètrage ScoDoc
description
=
"
standard ScoDoc (version 2011)
"
supported_formats
=
[
"
html
"
,
"
pdf
"
]
def
bul_title_pdf
(
self
)
->
list
:
...
...
@@ -158,31 +162,47 @@ class BulletinGeneratorStandard(sco_bulletins_generator.BulletinGenerator):
H
.
append
(
'
<div class=
"
bull_appreciations
"
>
'
)
for
app
in
self
.
infos
[
"
appreciations_list
"
]:
if
can_edit_app
:
mlink
=
(
'
<a class=
"
stdlink
"
href=
"
appreciation_add_form?id=%s
"
>modifier</a> <a class=
"
stdlink
"
href=
"
appreciation_add_form?id=%s&suppress=1
"
>supprimer</a>
'
%
(
app
[
"
id
"
],
app
[
"
id
"
])
)
mlink
=
f
"""
<a class=
"
stdlink
"
href=
"
{
url_for
(
'
notes.appreciation_add_form
'
,
scodoc_dept
=
g
.
scodoc_dept
,
id
=
app
[
'
id
'
])
}
"
>modifier</a>
<a class=
"
stdlink
"
href=
"
{
url_for
(
'
notes.appreciation_add_form
'
,
scodoc_dept
=
g
.
scodoc_dept
,
id
=
app
[
'
id
'
],
suppress
=
1
)
}
"
>supprimer</a>
"""
else
:
mlink
=
""
H
.
append
(
'
<p><span class=
"
bull_appreciations_date
"
>%s</span>%s<span class=
"
bull_appreciations_link
"
>%s</span></p>
'
%
(
app
[
"
date
"
],
app
[
"
comment
"
],
mlink
)
f
"""
<p><span class=
"
bull_appreciations_date
"
>
{
app
[
"
date
"
]
}
</span>
{
app
[
"
comment
"
]
}
<span class=
"
bull_appreciations_link
"
>
{
mlink
}
</span>
</p>
"""
)
if
can_edit_app
:
H
.
append
(
'
<p><a class=
"
stdlink
"
href=
"
appreciation_add_form?etudid=%(etudid)s&formsemestre_id=%(formsemestre_id)s
"
>Ajouter une appréciation</a></p>
'
f
"""
<p><a class=
"
stdlink
"
href=
"
{
url_for
(
'
notes.appreciation_add_form
'
,
scodoc_dept
=
g
.
scodoc_dept
,
etudid
=
self
.
infos
[
'
etudid
'
],
formsemestre_id
=
self
.
infos
[
'
formsemestre_id
'
]
)
}
"
>Ajouter une appréciation</a></p>
"""
%
self
.
infos
)
H
.
append
(
"
</div>
"
)
# Appréciations sur PDF:
if
self
.
infos
.
get
(
"
appreciations_list
"
,
False
):
story
.
append
(
Spacer
(
1
,
3
*
mm
))
try
:
story
.
append
(
Paragraph
(
SU
(
"
Appréciation :
"
+
"
\n
"
.
join
(
self
.
infos
[
"
appreciations_txt
"
])),
SU
(
"
Appréciation :
"
+
"
\n
"
.
join
(
self
.
infos
[
"
appreciations_txt
"
])
),
self
.
CellStyle
,
)
)
except
AttributeError
as
exc
:
raise
ScoPDFFormatError
(
"
Appréciation invalide bloquant la génération du pdf
"
)
from
exc
# ----- DECISION JURY
if
self
.
preferences
[
"
bul_show_decision
"
]:
...
...
This diff is collapsed.
Click to expand it.
app/scodoc/sco_pdf.py
+
6
−
3
View file @
36a5c15e
...
...
@@ -55,10 +55,10 @@ from reportlab.lib import styles
from
flask
import
g
from
app
import
log
from
app.scodoc.sco_exceptions
import
ScoGenError
,
ScoPDFFormatError
,
ScoValueError
from
app.scodoc
import
sco_utils
as
scu
from
app.scodoc.sco_utils
import
CONFIG
from
app
import
log
from
app.scodoc.sco_exceptions
import
ScoGenError
,
ScoValueError
import
sco_version
PAGE_HEIGHT
=
defaultPageSize
[
1
]
...
...
@@ -136,7 +136,10 @@ def make_paras(txt: str, style, suppress_empty=False) -> list[Paragraph]:
if
m
.
group
(
1
):
# non empty paragraph
r
.
append
(
para
)
paras
=
r
try
:
result
=
[
Paragraph
(
SU
(
s
),
style
)
for
s
in
paras
]
except
AttributeError
as
exc
:
raise
ScoPDFFormatError
(
"
PDF: paragraphe avec balisage invalide
"
)
from
exc
except
OSError
as
e
:
msg
=
str
(
e
)
# If a file is missing, try to display the invalid name
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment