Commit d0a50985 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Create ApplicationSettings if does not exist in runtime

parent 8133e449
......@@ -16,7 +16,7 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController
private
def set_application_setting
@application_setting = ApplicationSetting.last
@application_setting = ApplicationSetting.current
end
def application_setting_params
......
......@@ -2,4 +2,14 @@ class ApplicationSetting < ActiveRecord::Base
def self.current
ApplicationSetting.last
end
def self.create_from_defaults
create(
default_projects_limit: Settings.gitlab['default_projects_limit'],
signup_enabled: Settings.gitlab['signup_enabled'],
signin_enabled: Settings.gitlab['signin_enabled'],
gravatar_enabled: Settings.gravatar['enabled'],
sign_in_text: Settings.extra['sign_in_text'],
)
end
end
if ActiveRecord::Base.connection.table_exists?('application_settings')
unless ApplicationSetting.any?
ApplicationSetting.create(
default_projects_limit: Settings.gitlab['default_projects_limit'],
signup_enabled: Settings.gitlab['signup_enabled'],
signin_enabled: Settings.gitlab['signin_enabled'],
gravatar_enabled: Settings.gravatar['enabled'],
sign_in_text: Settings.extra['sign_in_text'],
)
end
end
......@@ -2,16 +2,21 @@ module Gitlab
module CurrentSettings
def current_application_settings
if ActiveRecord::Base.connection.table_exists?('application_settings')
ApplicationSetting.current
ApplicationSetting.current ||
ApplicationSetting.create_from_defaults
else
OpenStruct.new(
default_projects_limit: Settings.gitlab['default_projects_limit'],
signup_enabled: Settings.gitlab['signup_enabled'],
signin_enabled: Settings.gitlab['signin_enabled'],
gravatar_enabled: Settings.gravatar['enabled'],
sign_in_text: Settings.extra['sign_in_text'],
)
fake_application_settings
end
end
def fake_application_settings
OpenStruct.new(
default_projects_limit: Settings.gitlab['default_projects_limit'],
signup_enabled: Settings.gitlab['signup_enabled'],
signin_enabled: Settings.gitlab['signin_enabled'],
gravatar_enabled: Settings.gravatar['enabled'],
sign_in_text: Settings.extra['sign_in_text'],
)
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment