From 5277ec1ac07fcddbfb240fb700dcf89b1c0992cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Hanol?= Date: Wed, 16 Sep 2015 15:55:26 +0200 Subject: [PATCH] FIX: ensure we have a bucket before enabling backups to S3 --- .../admin/templates/components/site-settings/bool.hbs | 1 + config/locales/server.en.yml | 1 + lib/site_setting_validations.rb | 4 ++++ 3 files changed, 6 insertions(+) diff --git a/app/assets/javascripts/admin/templates/components/site-settings/bool.hbs b/app/assets/javascripts/admin/templates/components/site-settings/bool.hbs index 1f441c421ce..f1ac669900e 100644 --- a/app/assets/javascripts/admin/templates/components/site-settings/bool.hbs +++ b/app/assets/javascripts/admin/templates/components/site-settings/bool.hbs @@ -1,4 +1,5 @@ diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml index d4859e82900..d2d86cfa1de 100644 --- a/config/locales/server.en.yml +++ b/config/locales/server.en.yml @@ -96,6 +96,7 @@ en: max_username_length_exists: "You cannot set the maximum username length below the longest username." max_username_length_range: "You cannot set the maximum below the minimum." default_categories_already_selected: "You cannot select a category used in another list." + s3_upload_bucket_is_required: "You cannot enable uploads to S3 unless you've provided the 's3_upload_bucket'." activemodel: errors: diff --git a/lib/site_setting_validations.rb b/lib/site_setting_validations.rb index 5c5a0917fc2..e69bfc2f95d 100644 --- a/lib/site_setting_validations.rb +++ b/lib/site_setting_validations.rb @@ -46,4 +46,8 @@ module SiteSettingValidations validate_default_categories(new_val, default_categories_selected) end + def validate_enable_s3_uploads(new_val) + validate_error :s3_upload_bucket_is_required if new_val == "t" && SiteSetting.s3_upload_bucket.blank? + end + end