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