From b9da7e1b12d15529650169ec47b62c9e955873fd Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Tue, 23 Oct 2018 10:25:57 -0500 Subject: [PATCH] Allow individual App Settings to not be required; allow null hopefully this does the right thing also, not saving null to the db when that isn't needed etc. --- tailbone/views/settings.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tailbone/views/settings.py b/tailbone/views/settings.py index c82351fc..65a8066b 100644 --- a/tailbone/views/settings.py +++ b/tailbone/views/settings.py @@ -140,6 +140,10 @@ class AppSettingsView(View): 'name': setting.node_name, 'default': self.get_setting_value(setting), } + if kwargs['default'] is None: + kwargs['default'] = colander.null + if not setting.required: + kwargs['missing'] = colander.null if setting.choices: kwargs['validator'] = colander.OneOf(setting.choices) kwargs['widget'] = forms.widgets.JQuerySelectWidget( @@ -151,11 +155,15 @@ class AppSettingsView(View): def get_node_type(self, setting): if setting.data_type is bool: return colander.Bool() + elif setting.data_type is int: + return colander.Integer() return colander.String() def save_form(self, form): for setting in self.iter_known_settings(): value = form.validated[setting.node_name] + if value is colander.null: + value = None self.save_setting_value(setting, value) def iter_known_settings(self):