def upload_logo(request: HttpRequest, user_profile: UserProfile, night: bool=REQ(validator=check_bool)) -> HttpResponse: user_profile.realm.ensure_not_on_limited_plan() if len(request.FILES) != 1: return json_error(_("You must upload exactly one logo.")) logo_file = list(request.FILES.values())[0] if ((settings.MAX_LOGO_FILE_SIZE * 1024 * 1024) < logo_file.size): return json_error(_("Uploaded file is larger than the allowed limit of {} MiB").format( 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, acting_user=user_profile) return json_success()
def upload_logo(request: HttpRequest, user_profile: UserProfile, night: bool=REQ(validator=check_bool)) -> HttpResponse: if user_profile.realm.plan_type == Realm.LIMITED: return json_error(_("Feature unavailable on your current plan.")) if len(request.FILES) != 1: return json_error(_("You must upload exactly one logo.")) logo_file = list(request.FILES.values())[0] if ((settings.MAX_LOGO_FILE_SIZE * 1024 * 1024) < logo_file.size): return json_error(_("Uploaded file is larger than the allowed limit of %s MB") % ( 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) return json_success()
def upload_logo( request: HttpRequest, user_profile: UserProfile, night: bool = REQ(validator=check_bool) ) -> HttpResponse: if user_profile.realm.plan_type == Realm.LIMITED: return json_error(_("Feature unavailable on your current plan.")) if len(request.FILES) != 1: return json_error(_("You must upload exactly one logo.")) logo_file = list(request.FILES.values())[0] if ((settings.MAX_LOGO_FILE_SIZE * 1024 * 1024) < logo_file.size): return json_error( _("Uploaded file is larger than the allowed limit of %s MB") % (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) return json_success()