Make vary_key a blank string if there are no vary fields

This addresses an issue which causes all renditions in a project to be regenerated after an upgrade to Wagtail 0.9.
pull/965/head
Karl Hobley 2015-02-04 20:49:45 +00:00
rodzic 3b37a52a25
commit 09f053ce1e
2 zmienionych plików z 6 dodań i 4 usunięć

Wyświetl plik

@ -311,10 +311,12 @@ class Filter(models.Model):
def get_vary_key(self, image):
vary_string = '-'.join(self.get_vary(image))
vary_key = hashlib.sha1(vary_string.encode('utf-8')).hexdigest()
return vary_key[:8]
# Return blank string if there are no vary fields
if not vary_string:
return ''
return hashlib.sha1(vary_string.encode('utf-8')).hexdigest()[:8]
_registered_operations = None

Wyświetl plik

@ -326,14 +326,14 @@ class TestVaryKey(unittest.TestCase):
fil = Filter(spec='max-100x100')
vary_key = fil.get_vary_key(image)
self.assertEqual(vary_key, 'da39a3ee')
self.assertEqual(vary_key, '')
def test_vary_key_fill_filter(self):
image = Image(width=1000, height=1000)
fil = Filter(spec='fill-100x100')
vary_key = fil.get_vary_key(image)
self.assertEqual(vary_key, 'da39a3ee')
self.assertEqual(vary_key, '')
def test_vary_key_fill_filter_with_focal_point(self):
image = Image(