Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Websites UFRPE
Django Private Storage
Commits
48ae1339
Commit
48ae1339
authored
Oct 06, 2016
by
Diederik van der Boor
Browse files
Improve and translate field error messages
parent
faff7384
Changes
3
Hide whitespace changes
Inline
Side-by-side
private_storage/fields.py
View file @
48ae1339
...
...
@@ -19,6 +19,10 @@ class PrivateFileField(models.FileField):
- ``content_types``: list of allowed content types.
- ``max_file_size``: maximum file size.
"""
default_error_messages
=
{
'invalid_file_type'
:
_
(
'File type not supported.'
),
'file_too_large'
:
_
(
'The file may not be larger then {max_size}.'
),
}
def
__init__
(
self
,
*
args
,
**
kwargs
):
self
.
_upload
=
kwargs
.
pop
(
'upload_subfolder'
,
None
)
...
...
@@ -39,12 +43,12 @@ class PrivateFileField(models.FileField):
content_type
=
file
.
content_type
if
self
.
content_types
and
content_type
not
in
self
.
content_types
:
raise
ValidationError
(
_
(
'F
iletype
not supported.'
)
)
raise
ValidationError
(
self
.
error_messages
[
'invalid_f
ile
_
type
'
]
)
if
self
.
max_file_size
and
file
.
size
>
self
.
max_file_size
:
raise
ValidationError
(
_
(
'Please keep the file size under {max_size}, the uploaded file is {cur_size}'
)
.
format
(
raise
ValidationError
(
self
.
error_messages
[
'file_too_large'
]
.
format
(
max_size
=
filesizeformat
(
self
.
max_upload_size
),
cur_
size
=
filesizeformat
(
file
.
size
)
size
=
filesizeformat
(
file
.
size
)
))
return
data
...
...
private_storage/locale/en/LC_MESSAGES/django.po
View file @
48ae1339
...
...
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-10-06 16:
02
+0200\n"
"POT-Creation-Date: 2016-10-06 16:
59
+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
...
...
@@ -17,12 +17,11 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#: fields.py:
4
2
msgid "Filetype not supported."
#: fields.py:2
3
msgid "File
type not supported."
msgstr ""
#: fields.py:4
5
#: fields.py:
2
4
#, python-brace-format
msgid ""
"Please keep the file size under {max_size}, the uploaded file is {cur_size}"
msgid "The file may not be larger then {max_size}."
msgstr ""
private_storage/locale/nl/LC_MESSAGES/django.po
View file @
48ae1339
...
...
@@ -3,27 +3,26 @@
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version:
PACKAGE VERSION
\n"
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-10-06 16:02+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"POT-Creation-Date: 2016-10-06 16:59+0200\n"
"PO-Revision-Date: 2016-10-06 16:59+0100\n"
"Language: nl\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"Last-Translator: Diederik van der Boor <vdboor@edoburu.nl>\n"
"Language-Team: \n"
"X-Generator: Poedit 1.7.4\n"
#: fields.py:
4
2
msgid "Filetype not supported."
msgstr ""
#: fields.py:2
3
msgid "File
type not supported."
msgstr "
Bestandstype is niet ondersteund.
"
#: fields.py:4
5
#: fields.py:
2
4
#, python-brace-format
msgid ""
"Please keep the file size under {max_size}, the uploaded file is {cur_size}"
msgstr ""
msgid "The file may not be larger then {max_size}."
msgstr "Het bestand mag niet groter zijn dan {max_size}."
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment