urls: Use POST for zerver.views.user_settings.set_avatar_backend.

The set_avatar_backend is changed from PUT to POST becuase this
is not idempotent.
This commit is contained in:
Vishnu Ks
2017-07-05 22:45:15 +05:30
committed by Tim Abbott
parent df5df76961
commit 9067890120
3 changed files with 7 additions and 7 deletions

View File

@@ -209,7 +209,7 @@ exports.set_up = function () {
var spinner = $("#upload_avatar_spinner").expectOne();
loading.make_indicator(spinner, {text: 'Uploading avatar.'});
channel.put({
channel.post({
url: '/json/users/me/avatar',
data: form_data,
cache: false,

View File

@@ -614,7 +614,7 @@ class AvatarTest(UploadSerializeMixin, ZulipTestCase):
self.login(self.example_email("hamlet"))
with get_test_image_file('img.png') as fp1, \
get_test_image_file('img.png') as fp2:
result = self.client_put_multipart("/json/users/me/avatar", {'f1': fp1, 'f2': fp2})
result = self.client_post("/json/users/me/avatar", {'f1': fp1, 'f2': fp2})
self.assert_json_error(result, "You must upload exactly one avatar.")
def test_no_file_upload_failure(self):
@@ -624,7 +624,7 @@ class AvatarTest(UploadSerializeMixin, ZulipTestCase):
"""
self.login(self.example_email("hamlet"))
result = self.client_put_multipart("/json/users/me/avatar")
result = self.client_post("/json/users/me/avatar")
self.assert_json_error(result, "You must upload exactly one avatar.")
correct_files = [
@@ -705,7 +705,7 @@ class AvatarTest(UploadSerializeMixin, ZulipTestCase):
# with self.subTest(fname=fname):
self.login(self.example_email("hamlet"))
with get_test_image_file(fname) as fp:
result = self.client_put_multipart("/json/users/me/avatar", {'file': fp})
result = self.client_post("/json/users/me/avatar", {'file': fp})
self.assert_json_success(result)
json = ujson.loads(result.content)
@@ -744,7 +744,7 @@ class AvatarTest(UploadSerializeMixin, ZulipTestCase):
# with self.subTest(fname=fname):
self.login(self.example_email("hamlet"))
with get_test_image_file(fname) as fp:
result = self.client_put_multipart("/json/users/me/avatar", {'file': fp})
result = self.client_post("/json/users/me/avatar", {'file': fp})
self.assert_json_error(result, "Could not decode image; did you upload an image file?")
user_profile = self.example_user('hamlet')
@@ -776,7 +776,7 @@ class AvatarTest(UploadSerializeMixin, ZulipTestCase):
self.login(self.example_email("hamlet"))
with get_test_image_file(self.correct_files[0][0]) as fp:
with self.settings(MAX_AVATAR_FILE_SIZE=0):
result = self.client_put_multipart("/json/users/me/avatar", {'file': fp})
result = self.client_post("/json/users/me/avatar", {'file': fp})
self.assert_json_error(result, "Uploaded file is larger than the allowed limit of 0 MB")
def test_get_avatar_url_with_user_profile_lookup(self):

View File

@@ -313,7 +313,7 @@ v1_api_and_json_patterns = [
url(r'^users/me/enter-sends$', rest_dispatch,
{'POST': 'zerver.views.user_settings.change_enter_sends'}),
url(r'^users/me/avatar$', rest_dispatch,
{'PUT': 'zerver.views.user_settings.set_avatar_backend',
{'POST': 'zerver.views.user_settings.set_avatar_backend',
'DELETE': 'zerver.views.user_settings.delete_avatar_backend'}),
# users/me/hotspots -> zerver.views.hotspots