Sfoglia il codice sorgente

Set Image.file_hash in the multi image uploader

Karl Hobley 6 anni fa
parent
commit
2c2ef3465f

+ 1 - 0
wagtail/images/tests/test_admin_views.py

@@ -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)

+ 2 - 0
wagtail/images/views/multiple.py

@@ -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