debian-mirror-gitlab/app/controllers/admin/application_settings_controller.rb

90 lines
2.3 KiB
Ruby
Raw Normal View History

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,
: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,
:metrics_enabled,
:metrics_host,
:metrics_port,
:metrics_pool_size,
:metrics_timeout,
:metrics_method_call_threshold,
:metrics_sample_interval,
:recaptcha_enabled,
:recaptcha_site_key,
:recaptcha_private_key,
2016-01-29 22:53:50 +05:30
:sentry_enabled,
:sentry_dsn,
2016-04-02 18:10:28 +05:30
:akismet_enabled,
:akismet_api_key,
:email_author_in_body,
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