realm_logo: Update `upload_logo` views to return nothing.

This commit is contained in:
Pragati Agrawal 2019-02-28 17:21:04 +05:30 committed by Tim Abbott
parent 276020445d
commit 095e24c515
2 changed files with 3 additions and 21 deletions

View File

@ -1323,12 +1323,6 @@ class RealmLogoTest(UploadSerializeMixin, ZulipTestCase):
A PUT request to /json/realm/logo with a valid file should return a url
and actually create an realm logo.
"""
if self.night:
field_name = 'night_logo_url'
file_name = 'night_logo.png'
else:
field_name = 'logo_url'
file_name = 'logo.png'
for fname, rfname in self.correct_files:
# TODO: use self.subTest once we're exclusively on python 3 by uncommenting the line below.
# with self.subTest(fname=fname):
@ -1337,13 +1331,10 @@ class RealmLogoTest(UploadSerializeMixin, ZulipTestCase):
result = self.client_post("/json/realm/logo", {'file': fp, 'night': ujson.dumps(self.night)})
realm = get_realm('zulip')
self.assert_json_success(result)
self.assertIn(field_name, result.json())
base = '/user_avatars/%s/realm/%s' % (realm.id, file_name)
url = result.json()[field_name]
self.assertEqual(base, url[:len(base)])
logo_url = realm_logo_url(realm, self.night)
if rfname is not None:
response = self.client_get(url)
response = self.client_get(logo_url)
data = b"".join(response.streaming_content)
# size should be 100 x 100 because thumbnail keeps aspect ratio
# while trying to fit in a 800 x 100 box without losing part of the image

View File

@ -28,16 +28,7 @@ def upload_logo(request: HttpRequest, user_profile: UserProfile,
settings.MAX_LOGO_FILE_SIZE))
upload_logo_image(logo_file, user_profile, night)
do_change_logo_source(user_profile.realm, user_profile.realm.LOGO_UPLOADED, night)
logo_url = realm_logo_url(user_profile.realm, night)
if night:
json_result = dict(
night_logo_url=logo_url
)
else:
json_result = dict(
logo_url=logo_url
)
return json_success(json_result)
return json_success()
@require_realm_admin
@has_request_variables