diff --git a/tailbone/views/batch.py b/tailbone/views/batch.py index c189687f..b7759953 100644 --- a/tailbone/views/batch.py +++ b/tailbone/views/batch.py @@ -62,7 +62,7 @@ class BatchMasterView(MasterView): """ Base class for all "batch master" views. """ - refreshable = False + refreshable = True rows_viewable = True rows_creatable = False rows_editable = False @@ -205,6 +205,24 @@ class BatchMasterView(MasterView): fs.created_by, ]) + def _postconfigure_fieldset(self, fs): + if self.creating: + if 'created' in fs.render_fields: + del fs.created + if 'created_by' in fs.render_fields: + del fs.created_by + if 'executed' in fs.render_fields: + del fs.executed + if 'executed_by' in fs.render_fields: + del fs.executed_by + else: + batch = fs.model + if not batch.executed: + if 'executed' in fs.render_fields: + del fs.executed + if 'executed_by' in fs.render_fields: + del fs.executed_by + def save_create_form(self, form): """ Save the uploaded data file if necessary, etc. If batch initialization @@ -527,7 +545,7 @@ class BatchMasterView(MasterView): return defaults def row_grid_row_attrs(self, row, i): - pass + return {} def view_row(self): """ @@ -769,7 +787,6 @@ class FileBatchMasterView(BatchMasterView): """ Base class for all file-based "batch master" views. """ - refreshable = True @property def upload_dir(self): diff --git a/tailbone/views/vendors/catalogs.py b/tailbone/views/vendors/catalogs.py index a8eb08dc..b0ae1249 100644 --- a/tailbone/views/vendors/catalogs.py +++ b/tailbone/views/vendors/catalogs.py @@ -85,7 +85,6 @@ class VendorCatalogsView(FileBatchMasterView): parser_options.insert(0, ("(please choose)", '')) fs.parser_key.set(renderer=formalchemy.fields.SelectFieldRenderer, options=parser_options, label="File Type") - fs.configure( include=[ fs.filename, @@ -94,7 +93,6 @@ class VendorCatalogsView(FileBatchMasterView): ]) else: - fs.configure( include=[ fs.vendor.readonly(), @@ -106,11 +104,6 @@ class VendorCatalogsView(FileBatchMasterView): fs.executed_by, ]) - batch = fs.model - if not batch.executed: - del fs.executed - del fs.executed_by - def configure_row_grid(self, g): g.configure( include=[ diff --git a/tailbone/views/vendors/invoices.py b/tailbone/views/vendors/invoices.py index a9c2c717..c056cea2 100644 --- a/tailbone/views/vendors/invoices.py +++ b/tailbone/views/vendors/invoices.py @@ -68,6 +68,19 @@ class VendorInvoicesView(FileBatchMasterView): fs.purchase_order_number.set(validate=self.validate_po_number) fs.filename.set(label="Invoice File") + fs.configure( + include=[ + fs.vendor.readonly(), + fs.filename, + fs.parser_key, + fs.purchase_order_number, + fs.invoice_date.readonly(), + fs.created, + fs.created_by, + fs.executed, + fs.executed_by, + ]) + if self.creating: parsers = sorted(iter_invoice_parsers(), key=lambda p: p.display) parser_options = [(p.display, p.key) for p in parsers] @@ -75,30 +88,11 @@ class VendorInvoicesView(FileBatchMasterView): fs.parser_key.set(label="File Type", renderer=formalchemy.fields.SelectFieldRenderer, options=parser_options) - - fs.configure( - include=[ - fs.filename, - fs.parser_key, - fs.purchase_order_number, - ]) + del fs.vendor + del fs.invoice_date else: - fs.configure( - include=[ - fs.vendor.readonly(), - fs.filename, - fs.purchase_order_number, - fs.invoice_date.readonly(), - fs.created, - fs.created_by, - fs.executed, - fs.executed_by, - ]) - batch = fs.model - if not batch.executed: - del fs.executed - del fs.executed_by + del fs.parser_key def validate_po_number(self, value, field): """