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,8 +2,14 @@ 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
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'],
......@@ -13,5 +19,4 @@ module Gitlab
)
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