Misc. tweaks for "run import job" form

This commit is contained in:
Lance Edgar 2023-05-09 20:25:05 -05:00
parent 8fcef1fb4d
commit dcc7819466

View file

@ -295,15 +295,42 @@ class ImportingView(MasterView):
f.set_widget('models', dfwidget.SelectWidget(values=[(k, k) for k in keys],
multiple=True,
size=len(keys)))
# f.set_default('models', keys)
allow_create = True
allow_update = True
allow_delete = True
if len(keys) == 1:
importers = handler.get_importers().values()
importer = list(importers)[0]
allow_create = importer.allow_create
allow_update = importer.allow_update
allow_delete = importer.allow_delete
if allow_create:
f.set_default('create', True)
else:
f.remove('create')
if allow_update:
f.set_default('update', True)
else:
f.remove('update')
if allow_delete:
f.set_default('delete', False)
else:
f.remove('delete')
# f.set_default('runas', self.rattail_config.get('rattail', 'runas.default') or '')
f.set_default('versioning', True)
f.set_helptext('versioning', "If set, version history will be updated as appropriate")
f.set_default('dry_run', False)
f.set_helptext('dry_run', "If set, data will not actually be written")
f.set_default('warnings', False)
f.set_helptext('warnings', "If set, will send an email if any diffs")
def do_runjob(self, handler_info, form):
handler = handler_info['_handler']