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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Paul Milleville
SCODOC_R6A06
Commits
4d46d981
Commit
4d46d981
authored
3 months ago
by
Emmanuel Viennet
Browse files
Options
Downloads
Patches
Plain Diff
Enhance error checking on photo upload
parent
d8511d04
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/forms/main/config_cas.py
+1
-1
1 addition, 1 deletion
app/forms/main/config_cas.py
app/scodoc/sco_photos.py
+9
-4
9 additions, 4 deletions
app/scodoc/sco_photos.py
with
10 additions
and
5 deletions
app/forms/main/config_cas.py
+
1
−
1
View file @
4d46d981
...
...
@@ -92,7 +92,7 @@ class ConfigCASForm(FlaskForm):
dont le premier groupe doit donner l
'
identifiant CAS.
Si non fournie, le super-admin devra saisir cet identifiant pour chaque compte.
Par exemple, <tt>(.*)@</tt> indique que le mail sans le domaine (donc toute
la partie avant le <tt>@</tt>
)
est l
'
identifiant.
la partie avant le <tt>@</tt> est l
'
identifiant
)
.
Pour prendre le mail complet, utiliser <tt>(.*)</tt>.
"""
,
validators
=
[
Optional
(),
check_cas_uid_from_mail_regexp
],
...
...
This diff is collapsed.
Click to expand it.
app/scodoc/sco_photos.py
+
9
−
4
View file @
4d46d981
...
...
@@ -319,16 +319,21 @@ def save_image(etud: Identite, data: bytes):
data_file
=
io
.
BytesIO
()
data_file
.
write
(
data
)
data_file
.
seek
(
0
)
img
=
PILImage
.
open
(
data_file
)
try
:
img
=
PILImage
.
open
(
data_file
)
except
PIL
.
Image
.
DecompressionBombError
as
exc
:
log
(
"
sco_photos.save_image: DecompressionBombError
"
)
raise
ScoValueError
(
"
Fichier image invalide ou image trop grande
"
)
from
exc
filename
=
get_new_filename
(
etud
)
path
=
os
.
path
.
join
(
PHOTO_DIR
,
filename
)
log
(
"
saving
%dx%d jpeg to %s
"
%
(
img
.
size
[
0
]
,
img
.
size
[
1
],
path
)
)
log
(
f
"
saving
{
img
.
size
[
0
]
}
x
{
img
.
size
[
0
]
}
jpeg to
{
path
}
"
)
img
=
img
.
convert
(
"
RGB
"
)
img
.
save
(
path
+
IMAGE_EXT
,
format
=
"
JPEG
"
,
quality
=
92
)
# resize:
img
=
scale_height
(
img
)
log
(
"
saving %dx%d jpeg to %s.h90
"
%
(
img
.
size
[
0
],
img
.
size
[
1
],
filename
))
img
.
save
(
path
+
H90
+
IMAGE_EXT
,
format
=
"
JPEG
"
,
quality
=
92
)
path
=
path
+
H90
+
IMAGE_EXT
log
(
f
"
saving
{
img
.
size
[
0
]
}
x
{
img
.
size
[
0
]
}
jpeg to
{
path
}
"
)
img
.
save
(
path
,
format
=
"
JPEG
"
,
quality
=
92
)
return
filename
...
...
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