2015-01-08 03:22:50 -05:00
|
|
|
class Admin::ApplicationSettingsController < Admin::ApplicationController
|
2015-04-16 08:03:37 -04:00
|
|
|
before_action :set_application_setting
|
2015-01-08 03:22:50 -05:00
|
|
|
|
|
|
|
def show
|
|
|
|
end
|
|
|
|
|
|
|
|
def update
|
2015-01-08 12:53:35 -05:00
|
|
|
if @application_setting.update_attributes(application_setting_params)
|
|
|
|
redirect_to admin_application_settings_path,
|
|
|
|
notice: 'Application settings saved successfully'
|
|
|
|
else
|
|
|
|
render :show
|
|
|
|
end
|
2015-01-08 03:22:50 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def set_application_setting
|
2015-01-08 14:26:16 -05:00
|
|
|
@application_setting = ApplicationSetting.current
|
2015-01-08 03:22:50 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def application_setting_params
|
2015-03-01 10:06:46 -05:00
|
|
|
restricted_levels = params[:application_setting][:restricted_visibility_levels]
|
2015-03-16 15:59:50 -04:00
|
|
|
if restricted_levels.nil?
|
|
|
|
params[:application_setting][:restricted_visibility_levels] = []
|
|
|
|
else
|
2015-03-01 10:06:46 -05:00
|
|
|
restricted_levels.map! do |level|
|
|
|
|
level.to_i
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-01-08 03:22:50 -05:00
|
|
|
params.require(:application_setting).permit(
|
|
|
|
:default_projects_limit,
|
2015-01-25 10:33:54 -05:00
|
|
|
:default_branch_protection,
|
2015-01-08 03:22:50 -05:00
|
|
|
:signup_enabled,
|
|
|
|
:signin_enabled,
|
|
|
|
:gravatar_enabled,
|
2015-02-13 06:02:17 -05:00
|
|
|
:twitter_sharing_enabled,
|
2015-01-08 03:22:50 -05:00
|
|
|
:sign_in_text,
|
2015-03-01 10:06:46 -05:00
|
|
|
:home_page_url,
|
2015-03-20 08:11:12 -04:00
|
|
|
:max_attachment_size,
|
2015-04-26 01:01:52 -04:00
|
|
|
:default_project_visibility,
|
|
|
|
:default_snippet_visibility,
|
2015-05-02 09:53:32 -04:00
|
|
|
:restricted_signup_domains_raw,
|
|
|
|
restricted_visibility_levels: [],
|
2015-01-08 03:22:50 -05:00
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|