From 09227fa30aec42bf5af8c3f2cbc2d9785f01f55c Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Sun, 13 Feb 2022 16:27:24 -0600 Subject: [PATCH] New upgrades should be enabled by default --- tailbone/views/upgrades.py | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/tailbone/views/upgrades.py b/tailbone/views/upgrades.py index 0484dabc..11c2930c 100644 --- a/tailbone/views/upgrades.py +++ b/tailbone/views/upgrades.py @@ -2,7 +2,7 @@ ################################################################################ # # Rattail -- Retail Software Framework -# Copyright © 2010-2020 Lance Edgar +# Copyright © 2010-2022 Lance Edgar # # This file is part of Rattail. # @@ -155,6 +155,7 @@ class UpgradeView(MasterView): def configure_form(self, f): super(UpgradeView, self).configure_form(f) + upgrade = f.model_instance # status_code if self.creating: @@ -168,7 +169,6 @@ class UpgradeView(MasterView): f.remove('executing') f.set_type('created', 'datetime') - f.set_type('enabled', 'boolean') f.set_type('executed', 'datetime') # f.set_widget('not_until', dfwidget.DateInputWidget()) f.set_widget('notes', dfwidget.TextAreaWidget(cols=80, rows=8)) @@ -179,7 +179,6 @@ class UpgradeView(MasterView): # f.set_readonly('created_by') f.set_readonly('executed') f.set_readonly('executed_by') - upgrade = f.model_instance if self.creating or self.editing: f.remove_field('created') f.remove_field('created_by') @@ -188,11 +187,6 @@ class UpgradeView(MasterView): if self.creating or not upgrade.executed: f.remove_field('executed') f.remove_field('executed_by') - if self.editing and upgrade.executed: - f.remove_field('enabled') - - elif f.model_instance.executed: - f.remove_field('enabled') else: f.remove_field('executed') @@ -200,6 +194,13 @@ class UpgradeView(MasterView): f.remove_field('stdout_file') f.remove_field('stderr_file') + # enabled + if not self.creating and upgrade.executed: + f.remove('enabled') + else: + f.set_type('enabled', 'boolean') + f.set_default('enabled', True) + if not self.viewing or not upgrade.executed: f.remove_field('package_diff') f.remove_field('exit_code') @@ -462,5 +463,12 @@ class UpgradeView(MasterView): cls._defaults(config) -def includeme(config): +def defaults(config, **kwargs): + base = globals() + + UpgradeView = kwargs.get('UpgradeView', base['UpgradeView']) UpgradeView.defaults(config) + + +def includeme(config): + defaults(config)