application_settings_controller.rb 1.17 KB
Newer Older
1
class Admin::ApplicationSettingsController < Admin::ApplicationController
2
  before_action :set_application_setting
3 4 5 6 7

  def show
  end

  def update
8 9 10 11 12 13
    if @application_setting.update_attributes(application_setting_params)
      redirect_to admin_application_settings_path,
        notice: 'Application settings saved successfully'
    else
      render :show
    end
14 15 16 17 18
  end

  private

  def set_application_setting
19
    @application_setting = ApplicationSetting.current
20 21 22
  end

  def application_setting_params
23
    restricted_levels = params[:application_setting][:restricted_visibility_levels]
24 25 26
    if restricted_levels.nil?
      params[:application_setting][:restricted_visibility_levels] = []
    else
27 28 29 30 31
      restricted_levels.map! do |level|
        level.to_i
      end
    end

32 33
    params.require(:application_setting).permit(
      :default_projects_limit,
34
      :default_branch_protection,
35 36 37
      :signup_enabled,
      :signin_enabled,
      :gravatar_enabled,
38
      :twitter_sharing_enabled,
39
      :sign_in_text,
40
      :home_page_url,
41
      :max_attachment_size,
Vinnie Okada's avatar
Vinnie Okada committed
42 43
      :default_project_visibility,
      :default_snippet_visibility,
44
      restricted_visibility_levels: []
45 46 47
    )
  end
end