Add some smarts when making batch execution form schema
in some cases `has_execution_options()` may return True but the base view class may not need to provide any options itself (i.e. subclass is responsible for declaring the view has options).
This commit is contained in:
parent
ca57bd3572
commit
f49fdebd98
|
@ -786,28 +786,30 @@ class BatchMasterView(MasterView):
|
|||
route_prefix = self.get_route_prefix()
|
||||
use_buefy = self.get_use_buefy()
|
||||
|
||||
schema = None
|
||||
if self.has_execution_options(batch):
|
||||
if batch is None:
|
||||
batch = self.model_class
|
||||
schema = self.make_execute_schema(batch)
|
||||
for field in schema:
|
||||
if schema:
|
||||
for field in schema:
|
||||
|
||||
# if field does not yet have a default, maybe provide one from session storage
|
||||
if field.default is colander.null:
|
||||
key = 'batch.{}.execute_option.{}'.format(batch.batch_key, field.name)
|
||||
if key in self.request.session:
|
||||
defaults[field.name] = self.request.session[key]
|
||||
# if field does not yet have a default, maybe provide one from session storage
|
||||
if field.default is colander.null:
|
||||
key = 'batch.{}.execute_option.{}'.format(batch.batch_key, field.name)
|
||||
if key in self.request.session:
|
||||
defaults[field.name] = self.request.session[key]
|
||||
|
||||
# make sure field label is preserved
|
||||
if field.title:
|
||||
labels = kwargs.setdefault('labels', {})
|
||||
labels[field.name] = field.title
|
||||
# make sure field label is preserved
|
||||
if field.title:
|
||||
labels = kwargs.setdefault('labels', {})
|
||||
labels[field.name] = field.title
|
||||
|
||||
# auto-convert select widgets for buefy theme
|
||||
if use_buefy and isinstance(field.widget, forms.widgets.PlainSelectWidget):
|
||||
field.widget = dfwidget.SelectWidget(values=field.widget.values)
|
||||
# auto-convert select widgets for buefy theme
|
||||
if use_buefy and isinstance(field.widget, forms.widgets.PlainSelectWidget):
|
||||
field.widget = dfwidget.SelectWidget(values=field.widget.values)
|
||||
|
||||
else:
|
||||
if not schema:
|
||||
schema = colander.Schema()
|
||||
|
||||
kwargs['use_buefy'] = use_buefy
|
||||
|
|
Loading…
Reference in a new issue