settings: Rename MAX_AVATAR_FILE_SIZE.

Rename MAX_AVATAR_FILE_SIZE to
MAX_AVATAR_FILE_SIZE_MIB reflecting
size in mebibytes.
This commit is contained in:
Gaurav Pandey
2021-05-29 12:21:07 +05:30
committed by Tim Abbott
parent 66f77d3b4b
commit 0f6bb210a6
4 changed files with 5 additions and 5 deletions

View File

@@ -241,7 +241,7 @@ def fetch_initial_state_data(
state["realm_presence_disabled"] = True if user_profile is None else realm.presence_disabled state["realm_presence_disabled"] = True if user_profile is None else realm.presence_disabled
# Important: Encode units in the client-facing API name. # Important: Encode units in the client-facing API name.
state["max_avatar_file_size_mib"] = settings.MAX_AVATAR_FILE_SIZE state["max_avatar_file_size_mib"] = settings.MAX_AVATAR_FILE_SIZE_MIB
state["max_file_upload_size_mib"] = settings.MAX_FILE_UPLOAD_SIZE state["max_file_upload_size_mib"] = settings.MAX_FILE_UPLOAD_SIZE
state["max_icon_file_size_mib"] = settings.MAX_ICON_FILE_SIZE state["max_icon_file_size_mib"] = settings.MAX_ICON_FILE_SIZE
state["realm_upload_quota_mib"] = realm.upload_quota_bytes() state["realm_upload_quota_mib"] = realm.upload_quota_bytes()

View File

@@ -1238,7 +1238,7 @@ class AvatarTest(UploadSerializeMixin, ZulipTestCase):
def test_avatar_upload_file_size_error(self) -> None: def test_avatar_upload_file_size_error(self) -> None:
self.login("hamlet") self.login("hamlet")
with get_test_image_file(self.correct_files[0][0]) as fp: with get_test_image_file(self.correct_files[0][0]) as fp:
with self.settings(MAX_AVATAR_FILE_SIZE=0): with self.settings(MAX_AVATAR_FILE_SIZE_MIB=0):
result = self.client_post("/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 MiB") self.assert_json_error(result, "Uploaded file is larger than the allowed limit of 0 MiB")

View File

@@ -297,10 +297,10 @@ def set_avatar_backend(request: HttpRequest, user_profile: UserProfile) -> HttpR
return json_error(str(AVATAR_CHANGES_DISABLED_ERROR)) return json_error(str(AVATAR_CHANGES_DISABLED_ERROR))
user_file = list(request.FILES.values())[0] user_file = list(request.FILES.values())[0]
if (settings.MAX_AVATAR_FILE_SIZE * 1024 * 1024) < user_file.size: if (settings.MAX_AVATAR_FILE_SIZE_MIB * 1024 * 1024) < user_file.size:
return json_error( return json_error(
_("Uploaded file is larger than the allowed limit of {} MiB").format( _("Uploaded file is larger than the allowed limit of {} MiB").format(
settings.MAX_AVATAR_FILE_SIZE, settings.MAX_AVATAR_FILE_SIZE_MIB,
) )
) )
upload_avatar_image(user_file, user_profile, user_profile) upload_avatar_image(user_file, user_profile, user_profile)

View File

@@ -307,7 +307,7 @@ ZULIP_IOS_APP_ID = "org.zulip.Zulip"
# Limits related to the size of file uploads; last few in MB. # Limits related to the size of file uploads; last few in MB.
DATA_UPLOAD_MAX_MEMORY_SIZE = 25 * 1024 * 1024 DATA_UPLOAD_MAX_MEMORY_SIZE = 25 * 1024 * 1024
MAX_AVATAR_FILE_SIZE = 5 MAX_AVATAR_FILE_SIZE_MIB = 5
MAX_ICON_FILE_SIZE = 5 MAX_ICON_FILE_SIZE = 5
MAX_LOGO_FILE_SIZE = 5 MAX_LOGO_FILE_SIZE = 5
MAX_EMOJI_FILE_SIZE = 5 MAX_EMOJI_FILE_SIZE = 5