2015-04-26 12:48:37 +05:30
|
|
|
class Admin::ApplicationSettingsController < Admin::ApplicationController
|
2015-09-11 14:41:01 +05:30
|
|
|
before_action :set_application_setting
|
2015-04-26 12:48:37 +05:30
|
|
|
|
|
|
|
def show
|
|
|
|
end
|
|
|
|
|
|
|
|
def update
|
|
|
|
if @application_setting.update_attributes(application_setting_params)
|
|
|
|
redirect_to admin_application_settings_path,
|
|
|
|
notice: 'Application settings saved successfully'
|
|
|
|
else
|
|
|
|
render :show
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-12-23 02:04:40 +05:30
|
|
|
def reset_runners_token
|
|
|
|
@application_setting.reset_runners_registration_token!
|
|
|
|
flash[:notice] = 'New runners registration token has been generated!'
|
|
|
|
redirect_to admin_runners_path
|
|
|
|
end
|
|
|
|
|
2015-04-26 12:48:37 +05:30
|
|
|
private
|
|
|
|
|
|
|
|
def set_application_setting
|
|
|
|
@application_setting = ApplicationSetting.current
|
|
|
|
end
|
|
|
|
|
|
|
|
def application_setting_params
|
|
|
|
restricted_levels = params[:application_setting][:restricted_visibility_levels]
|
|
|
|
if restricted_levels.nil?
|
|
|
|
params[:application_setting][:restricted_visibility_levels] = []
|
|
|
|
else
|
|
|
|
restricted_levels.map! do |level|
|
|
|
|
level.to_i
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-09-25 12:07:36 +05:30
|
|
|
import_sources = params[:application_setting][:import_sources]
|
|
|
|
if import_sources.nil?
|
|
|
|
params[:application_setting][:import_sources] = []
|
|
|
|
else
|
|
|
|
import_sources.map! do |source|
|
|
|
|
source.to_str
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-04-26 12:48:37 +05:30
|
|
|
params.require(:application_setting).permit(
|
|
|
|
:default_projects_limit,
|
|
|
|
:default_branch_protection,
|
|
|
|
:signup_enabled,
|
|
|
|
:signin_enabled,
|
2016-01-14 18:37:52 +05:30
|
|
|
:require_two_factor_authentication,
|
|
|
|
:two_factor_grace_period,
|
2015-04-26 12:48:37 +05:30
|
|
|
:gravatar_enabled,
|
|
|
|
:twitter_sharing_enabled,
|
|
|
|
:sign_in_text,
|
2015-09-25 12:07:36 +05:30
|
|
|
:help_page_text,
|
2015-04-26 12:48:37 +05:30
|
|
|
:home_page_url,
|
2015-09-11 14:41:01 +05:30
|
|
|
:after_sign_out_path,
|
2015-04-26 12:48:37 +05:30
|
|
|
:max_attachment_size,
|
2015-09-11 14:41:01 +05:30
|
|
|
:session_expire_delay,
|
|
|
|
:default_project_visibility,
|
|
|
|
:default_snippet_visibility,
|
|
|
|
:restricted_signup_domains_raw,
|
|
|
|
:version_check_enabled,
|
2015-10-24 18:46:33 +05:30
|
|
|
:admin_notification_email,
|
2015-09-11 14:41:01 +05:30
|
|
|
:user_oauth_applications,
|
2015-11-26 14:37:03 +05:30
|
|
|
:shared_runners_enabled,
|
|
|
|
:max_artifacts_size,
|
2016-01-14 18:37:52 +05:30
|
|
|
:metrics_enabled,
|
|
|
|
:metrics_host,
|
|
|
|
:metrics_port,
|
|
|
|
:metrics_pool_size,
|
|
|
|
:metrics_timeout,
|
|
|
|
:metrics_method_call_threshold,
|
2016-01-19 16:12:03 +05:30
|
|
|
:metrics_sample_interval,
|
2016-01-14 18:37:52 +05:30
|
|
|
:recaptcha_enabled,
|
|
|
|
:recaptcha_site_key,
|
|
|
|
:recaptcha_private_key,
|
2015-09-11 14:41:01 +05:30
|
|
|
restricted_visibility_levels: [],
|
2015-09-25 12:07:36 +05:30
|
|
|
import_sources: []
|
2015-04-26 12:48:37 +05:30
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|