Don't use empty string as default setting value

should just fall back to None as per usual
This commit is contained in:
Lance Edgar 2018-07-18 13:53:24 -05:00
parent c2968fbe52
commit 87ba8026e5

View file

@ -177,16 +177,17 @@ class AppSettingsView(View):
def get_setting_value(self, setting): def get_setting_value(self, setting):
if setting.data_type is bool: if setting.data_type is bool:
return self.rattail_config.getbool(setting.namespace, setting.name) return self.rattail_config.getbool(setting.namespace, setting.name)
return self.rattail_config.get(setting.namespace, setting.name, default='') return self.rattail_config.get(setting.namespace, setting.name)
def save_setting_value(self, setting, value): def save_setting_value(self, setting, value):
existing = self.get_setting_value(setting) existing = self.get_setting_value(setting)
if existing != value: if existing != value:
legacy_name = '{}.{}'.format(setting.namespace, setting.name) legacy_name = '{}.{}'.format(setting.namespace, setting.name)
if setting.data_type is bool: if setting.data_type is bool:
api.save_setting(Session(), legacy_name, 'true' if value else 'false') value = 'true' if value else 'false'
else: else:
api.save_setting(Session(), legacy_name, six.text_type(value)) value = six.text_type(value)
api.save_setting(Session(), legacy_name, value)
@classmethod @classmethod
def defaults(cls, config): def defaults(cls, config):