don't fail in foodsoft_config without database,
and use proper config defaults so that configuration editing has sensible default values
This commit is contained in:
parent
7b000c39eb
commit
90f60595e6
3 changed files with 13 additions and 6 deletions
|
@ -60,10 +60,14 @@ class FoodsoftConfig
|
||||||
#
|
#
|
||||||
# FoodsoftConfig[:name] # => 'FC Test'
|
# FoodsoftConfig[:name] # => 'FC Test'
|
||||||
#
|
#
|
||||||
|
# To avoid errors when the database is not yet setup (when loading
|
||||||
|
# the initial database schema), cached settings are only being read
|
||||||
|
# when the settings table exists.
|
||||||
|
#
|
||||||
# @param key [String, Symbol]
|
# @param key [String, Symbol]
|
||||||
# @return [Object] Value of the key.
|
# @return [Object] Value of the key.
|
||||||
def [](key)
|
def [](key)
|
||||||
if allowed_key?(key)
|
if RailsSettings::CachedSettings.table_exists? and allowed_key?(key)
|
||||||
value = RailsSettings::CachedSettings["foodcoop.#{self.scope}.#{key}"]
|
value = RailsSettings::CachedSettings["foodcoop.#{self.scope}.#{key}"]
|
||||||
value = config[key] if value.nil?
|
value = config[key] if value.nil?
|
||||||
value
|
value
|
||||||
|
@ -146,10 +150,13 @@ class FoodsoftConfig
|
||||||
end
|
end
|
||||||
|
|
||||||
# When new options are introduced, put backward-compatible defaults here, so that
|
# When new options are introduced, put backward-compatible defaults here, so that
|
||||||
# configuration files that haven't been updated, still work as they did.
|
# configuration files that haven't been updated, still work as they did. This also
|
||||||
|
# makes sure that the configuration editor picks up the defaults.
|
||||||
def set_missing
|
def set_missing
|
||||||
config.replace({
|
config.replace({
|
||||||
use_nick: true,
|
use_nick: true,
|
||||||
|
use_wiki: true,
|
||||||
|
use_messages: true,
|
||||||
use_apple_points: true,
|
use_apple_points: true,
|
||||||
# English is the default language, and this makes it show up as default.
|
# English is the default language, and this makes it show up as default.
|
||||||
default_locale: 'en',
|
default_locale: 'en',
|
||||||
|
|
|
@ -4,8 +4,8 @@ require "deface"
|
||||||
|
|
||||||
module FoodsoftMessages
|
module FoodsoftMessages
|
||||||
# Return whether messages are used or not.
|
# Return whether messages are used or not.
|
||||||
# Enabled by default since it used to be part of the foodsoft core.
|
# Enabled by default in {FoodsoftConfig} since it used to be part of the foodsoft core.
|
||||||
def self.enabled?
|
def self.enabled?
|
||||||
FoodsoftConfig[:use_messages] != false
|
FoodsoftConfig[:use_messages]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,8 +6,8 @@ require 'foodsoft_wiki/engine'
|
||||||
|
|
||||||
module FoodsoftWiki
|
module FoodsoftWiki
|
||||||
# Return whether the wiki is used or not.
|
# Return whether the wiki is used or not.
|
||||||
# Enabled by default since it used to be part of the foodsoft core.
|
# Enabled by default in {FoodsoftConfig} since it used to be part of the foodsoft core.
|
||||||
def self.enabled?
|
def self.enabled?
|
||||||
FoodsoftConfig[:use_wiki] != false
|
FoodsoftConfig[:use_wiki]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue