Gitlab CSE Unil
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
ADIM
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
Model registry
Operate
Environments
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
M. Chardon
ADIM
Merge requests
!6
Django
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Django
django
into
javascript
Overview
0
Commits
2
Pipelines
0
Changes
4
Merged
M. Chardon
requested to merge
django
into
javascript
6 years ago
Overview
0
Commits
2
Pipelines
0
Changes
4
Expand
modif api pour json format
0
0
Merge request reports
Compare
javascript
javascript (base)
and
latest version
latest version
6cffed8e
2 commits,
6 years ago
4 files
+
68
−
16
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
4
Search (e.g. *.vue) (Ctrl+P)
adim_project/adim_app/utils/validators.py
0 → 100644
+
32
−
0
Options
from
django.core.exceptions
import
ValidationError
from
django.utils.translation
import
gettext_lazy
as
_
def
validate_json_file
(
value
):
message
=
_
(
"
File extension
'
%(extension)s
'
is not allowed.
"
"
Allowed extensions are:
'
%(allowed_extensions)s
'
.
"
)
code
=
'
invalid_json_extension
'
if
value
.
content_type
:
options
=
{
# the file types which are going to be allowed for upload
# must be a mimetype
"
acceptedformats
"
:
(
"
image/jpeg
"
,
"
image/jpg
"
,
"
image/png
"
,
)
}
# allowed file type
extension
=
value
.
content_type
if
extension
not
in
options
[
"
acceptedformats
"
]:
raise
ValidationError
(
message
,
code
=
code
,
params
=
{
'
extension
'
:
extension
,
'
allowed_extensions
'
:
'
,
'
.
join
(
options
[
"
acceptedformats
"
])
}
)
\ No newline at end of file
Loading