mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 05:53:43 +00:00 
			
		
		
		
	settings: Rename MAX_ICON_FILE_SIZE.
Rename MAX_ICON_FILE_SIZE to MAX_ICON_FILE_SIZE_MIB reflecting size in mebibytes.
This commit is contained in:
		
				
					committed by
					
						
						Tim Abbott
					
				
			
			
				
	
			
			
			
						parent
						
							0f6bb210a6
						
					
				
				
					commit
					2ddc62e9b3
				
			@@ -243,7 +243,7 @@ def fetch_initial_state_data(
 | 
			
		||||
        # Important: Encode units in the client-facing API name.
 | 
			
		||||
        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_icon_file_size_mib"] = settings.MAX_ICON_FILE_SIZE
 | 
			
		||||
        state["max_icon_file_size_mib"] = settings.MAX_ICON_FILE_SIZE_MIB
 | 
			
		||||
        state["realm_upload_quota_mib"] = realm.upload_quota_bytes()
 | 
			
		||||
 | 
			
		||||
        state["realm_icon_url"] = realm_icon_url(realm)
 | 
			
		||||
 
 | 
			
		||||
@@ -1416,7 +1416,7 @@ class RealmIconTest(UploadSerializeMixin, ZulipTestCase):
 | 
			
		||||
    def test_realm_icon_upload_file_size_error(self) -> None:
 | 
			
		||||
        self.login("iago")
 | 
			
		||||
        with get_test_image_file(self.correct_files[0][0]) as fp:
 | 
			
		||||
            with self.settings(MAX_ICON_FILE_SIZE=0):
 | 
			
		||||
            with self.settings(MAX_ICON_FILE_SIZE_MIB=0):
 | 
			
		||||
                result = self.client_post("/json/realm/icon", {"file": fp})
 | 
			
		||||
        self.assert_json_error(result, "Uploaded file is larger than the allowed limit of 0 MiB")
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -19,10 +19,10 @@ def upload_icon(request: HttpRequest, user_profile: UserProfile) -> HttpResponse
 | 
			
		||||
        return json_error(_("You must upload exactly one icon."))
 | 
			
		||||
 | 
			
		||||
    icon_file = list(request.FILES.values())[0]
 | 
			
		||||
    if (settings.MAX_ICON_FILE_SIZE * 1024 * 1024) < icon_file.size:
 | 
			
		||||
    if (settings.MAX_ICON_FILE_SIZE_MIB * 1024 * 1024) < icon_file.size:
 | 
			
		||||
        return json_error(
 | 
			
		||||
            _("Uploaded file is larger than the allowed limit of {} MiB").format(
 | 
			
		||||
                settings.MAX_ICON_FILE_SIZE,
 | 
			
		||||
                settings.MAX_ICON_FILE_SIZE_MIB,
 | 
			
		||||
            )
 | 
			
		||||
        )
 | 
			
		||||
    upload_icon_image(icon_file, user_profile)
 | 
			
		||||
 
 | 
			
		||||
@@ -308,7 +308,7 @@ ZULIP_IOS_APP_ID = "org.zulip.Zulip"
 | 
			
		||||
# Limits related to the size of file uploads; last few in MB.
 | 
			
		||||
DATA_UPLOAD_MAX_MEMORY_SIZE = 25 * 1024 * 1024
 | 
			
		||||
MAX_AVATAR_FILE_SIZE_MIB = 5
 | 
			
		||||
MAX_ICON_FILE_SIZE = 5
 | 
			
		||||
MAX_ICON_FILE_SIZE_MIB = 5
 | 
			
		||||
MAX_LOGO_FILE_SIZE = 5
 | 
			
		||||
MAX_EMOJI_FILE_SIZE = 5
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user