Don't save any App Settings for which value would not change

that lets us avoid writing "redundant" values to the database, whereas in fact
the underlying value may be coming from config file
This commit is contained in:
Lance Edgar 2018-07-18 13:50:32 -05:00
parent 117e52df23
commit c2968fbe52
2 changed files with 8 additions and 6 deletions

View file

@ -1,7 +1,7 @@
## -*- coding: utf-8; -*-
<%inherit file="/base.mako" />
<%def name="title()">${self.app_title()} App Settings</%def>
<%def name="title()">App Settings</%def>
<%def name="content_title()"></%def>

View file

@ -180,6 +180,8 @@ class AppSettingsView(View):
return self.rattail_config.get(setting.namespace, setting.name, default='')
def save_setting_value(self, setting, value):
existing = self.get_setting_value(setting)
if existing != value:
legacy_name = '{}.{}'.format(setting.namespace, setting.name)
if setting.data_type is bool:
api.save_setting(Session(), legacy_name, 'true' if value else 'false')