New upgrades should be enabled by default

This commit is contained in:
Lance Edgar 2022-02-13 16:27:24 -06:00
parent 4e3aa1af83
commit 09227fa30a

View file

@ -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)