Refactor importer batch views to use master3

This commit is contained in:
Lance Edgar 2018-01-27 13:04:07 -06:00
parent 2cbe1b0049
commit 8d62960548

View file

@ -28,11 +28,10 @@ from __future__ import unicode_literals, absolute_import
import sqlalchemy as sa
from rattail.core import Object
from rattail.db import model
from tailbone import forms, forms2
from tailbone.views.batch import BatchMasterView2 as BatchMasterView
from tailbone import forms2 as forms
from tailbone.views.batch import BatchMasterView3 as BatchMasterView
class ImporterBatchView(BatchMasterView):
@ -64,6 +63,22 @@ class ImporterBatchView(BatchMasterView):
'executed_by',
]
form_fields = [
'id',
'description',
'import_handler_spec',
'host_title',
'local_title',
'importer_key',
'notes',
'created',
'created_by',
'row_table',
'rowcount',
'executed',
'executed_by',
]
labels = {
'host_title': "Source",
'local_title': "Target",
@ -77,24 +92,23 @@ class ImporterBatchView(BatchMasterView):
'status_code',
]
def configure_fieldset(self, fs):
fs.configure(
include=[
fs.id,
fs.description,
# fs.batch_handler_spec.readonly(),
fs.import_handler_spec.readonly(),
fs.host_title.readonly().label("Source"),
fs.local_title.readonly().label("Target"),
fs.importer_key.readonly().label("Model"),
fs.notes,
fs.created,
fs.created_by,
fs.row_table.readonly(),
fs.rowcount,
fs.executed,
fs.executed_by,
])
def configure_form(self, f):
super(ImporterBatchView, self).configure_form(f)
# import_handler_spec
f.set_readonly('import_handler_spec')
# host_title
f.set_readonly('host_title')
# local_title
f.set_readonly('local_title')
# importer_key
f.set_readonly('importer_key')
# row_table
f.set_readonly('row_table')
def delete_instance(self, batch):
self.make_row_table(batch.row_table)
@ -207,7 +221,7 @@ class ImporterBatchView(BatchMasterView):
Creates a new form for the given model class/instance
"""
if factory is None:
factory = forms2.Form
factory = forms.Form
if fields is None:
fields = ['sequence', 'object_key', 'object_str', 'status_code']
for col in self.current_row_table.c: