Set Image.file_hash in the multi image uploader

pull/4609/merge
Karl Hobley 2018-06-07 16:23:47 +01:00 zatwierdzone przez Matt Westcott
rodzic 507192f5be
commit 2c2ef3465f
2 zmienionych plików z 3 dodań i 0 usunięć

Wyświetl plik

@ -876,6 +876,7 @@ class TestMultipleImageUploader(TestCase, WagtailTestUtils):
self.assertIn('image', response.context)
self.assertEqual(response.context['image'].title, 'test.png')
self.assertTrue(response.context['image'].file_size)
self.assertTrue(response.context['image'].file_hash)
# Check form
self.assertIn('form', response.context)

Wyświetl plik

@ -67,6 +67,8 @@ def add(request):
image = form.save(commit=False)
image.uploaded_by_user = request.user
image.file_size = image.file.size
image.file.seek(0)
image._set_file_hash(image.file.read())
image.save()
# Success! Send back an edit form for this image to the user