mirror of https://github.com/zulip/zulip.git
upload: Rename BadImageError exception to not mention avatars.
This is preparation for using that function to decode realm icons as well.
This commit is contained in:
parent
9ce218154e
commit
c5ed119f89
|
@ -90,7 +90,7 @@ def resize_avatar(image_data, size=DEFAULT_AVATAR_SIZE):
|
||||||
im = Image.open(io.BytesIO(image_data))
|
im = Image.open(io.BytesIO(image_data))
|
||||||
im = ImageOps.fit(im, (size, size), Image.ANTIALIAS)
|
im = ImageOps.fit(im, (size, size), Image.ANTIALIAS)
|
||||||
except IOError:
|
except IOError:
|
||||||
raise BadImageError("Could not decode avatar image; did you upload an image file?")
|
raise BadImageError("Could not decode image; did you upload an image file?")
|
||||||
out = io.BytesIO()
|
out = io.BytesIO()
|
||||||
im.save(out, format='png')
|
im.save(out, format='png')
|
||||||
return out.getvalue()
|
return out.getvalue()
|
||||||
|
|
|
@ -444,7 +444,7 @@ class AvatarTest(UploadSerializeMixin, ZulipTestCase):
|
||||||
with get_test_image_file(fname) as fp:
|
with get_test_image_file(fname) as fp:
|
||||||
result = self.client_put_multipart("/json/users/me/avatar", {'file': fp})
|
result = self.client_put_multipart("/json/users/me/avatar", {'file': fp})
|
||||||
|
|
||||||
self.assert_json_error(result, "Could not decode avatar image; did you upload an image file?")
|
self.assert_json_error(result, "Could not decode image; did you upload an image file?")
|
||||||
user_profile = get_user_profile_by_email("hamlet@zulip.com")
|
user_profile = get_user_profile_by_email("hamlet@zulip.com")
|
||||||
self.assertEqual(user_profile.avatar_version, 1)
|
self.assertEqual(user_profile.avatar_version, 1)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue