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

118 lines
3.2 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
2016-06-02 11:05:42 +05:30
def reset_health_check_token
@application_setting.reset_health_check_access_token!
flash[:notice] = 'New health check access token has been generated!'
redirect_to :back
end
def clear_repository_check_states
RepositoryCheck::ClearWorker.perform_async
redirect_to(
admin_application_settings_path,
notice: 'Started asynchronous removal of all repository check states.'
)
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
2016-06-02 11:05:42 +05:30
enabled_oauth_sign_in_sources = params[:application_setting].delete(:enabled_oauth_sign_in_sources)
params[:application_setting][:disabled_oauth_sign_in_sources] =
AuthHelper.button_based_providers.map(&:to_s) -
Array(enabled_oauth_sign_in_sources)
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,
:sign_in_text,
:after_sign_up_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,
2016-06-02 11:05:42 +05:30
:default_group_visibility,
2015-09-11 14:41:01 +05:30
: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,
2016-06-02 11:05:42 +05:30
:shared_runners_text,
2015-11-26 14:37:03 +05:30
: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,
2016-06-02 11:05:42 +05:30
:repository_checks_enabled,
:metrics_packet_size,
:send_user_confirmation_email,
:container_registry_token_expire_delay,
2015-09-11 14:41:01 +05:30
restricted_visibility_levels: [],
2016-06-02 11:05:42 +05:30
import_sources: [],
disabled_oauth_sign_in_sources: []
2015-04-26 12:48:37 +05:30
)
end
end