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 ...@@ -16,7 +16,7 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController
private private
def set_application_setting def set_application_setting
@application_setting = ApplicationSetting.last @application_setting = ApplicationSetting.current
end end
def application_setting_params def application_setting_params
......
...@@ -2,4 +2,14 @@ class ApplicationSetting < ActiveRecord::Base ...@@ -2,4 +2,14 @@ class ApplicationSetting < ActiveRecord::Base
def self.current def self.current
ApplicationSetting.last ApplicationSetting.last
end 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 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 ...@@ -2,16 +2,21 @@ module Gitlab
module CurrentSettings module CurrentSettings
def current_application_settings def current_application_settings
if ActiveRecord::Base.connection.table_exists?('application_settings') if ActiveRecord::Base.connection.table_exists?('application_settings')
ApplicationSetting.current ApplicationSetting.current ||
ApplicationSetting.create_from_defaults
else else
OpenStruct.new( fake_application_settings
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 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
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