mirror of
https://github.com/wagtail/wagtail.git
synced 2024-12-01 11:41:20 +01:00
Fixed max upload size error message in multi image uploader
This commit is contained in:
parent
e2a9ed3924
commit
0def3c1768
@ -49,6 +49,10 @@ class WagtailImageField(ImageField):
|
|||||||
"This file is too big (%%s). Maximum filesize %s."
|
"This file is too big (%%s). Maximum filesize %s."
|
||||||
) % max_upload_size_text
|
) % max_upload_size_text
|
||||||
|
|
||||||
|
self.error_messages['file_too_large_unknown_size'] = _(
|
||||||
|
"This file is too big. Maximum filesize %s."
|
||||||
|
) % max_upload_size_text
|
||||||
|
|
||||||
def check_image_file_format(self, f):
|
def check_image_file_format(self, f):
|
||||||
# Check file extension
|
# Check file extension
|
||||||
extension = os.path.splitext(f.name)[1].lower()[1:]
|
extension = os.path.splitext(f.name)[1].lower()[1:]
|
||||||
|
@ -302,6 +302,13 @@ class TestMultipleImageUploader(TestCase, WagtailTestUtils):
|
|||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
self.assertTemplateUsed(response, 'wagtailimages/multiple/add.html')
|
self.assertTemplateUsed(response, 'wagtailimages/multiple/add.html')
|
||||||
|
|
||||||
|
@override_settings(WAGTAILIMAGES_MAX_UPLOAD_SIZE=1000)
|
||||||
|
def test_add_max_file_size_context_variables(self):
|
||||||
|
response = self.client.get(reverse('wagtailimages_add_multiple'))
|
||||||
|
|
||||||
|
self.assertEqual(response.context['max_filesize'], 1000)
|
||||||
|
self.assertEqual(response.context['error_max_file_size'], "This file is too big. Maximum filesize 1000\xa0bytes.")
|
||||||
|
|
||||||
def test_add_post(self):
|
def test_add_post(self):
|
||||||
"""
|
"""
|
||||||
This tests that a POST request to the add view saves the image and returns an edit form
|
This tests that a POST request to the add view saves the image and returns an edit form
|
||||||
|
@ -88,7 +88,7 @@ def add(request):
|
|||||||
'max_filesize': form.fields['file'].max_upload_size,
|
'max_filesize': form.fields['file'].max_upload_size,
|
||||||
'help_text': form.fields['file'].help_text,
|
'help_text': form.fields['file'].help_text,
|
||||||
'allowed_extensions': ALLOWED_EXTENSIONS,
|
'allowed_extensions': ALLOWED_EXTENSIONS,
|
||||||
'error_max_file_size': form.fields['file'].error_messages['file_too_large'],
|
'error_max_file_size': form.fields['file'].error_messages['file_too_large_unknown_size'],
|
||||||
'error_accepted_file_types': form.fields['file'].error_messages['invalid_image'],
|
'error_accepted_file_types': form.fields['file'].error_messages['invalid_image'],
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user