Refactor batch views / templates per rattail framework overhaul
This commit is contained in:
parent
a5184e416a
commit
203f0242fb
12 changed files with 225 additions and 182 deletions
22
tailbone/views/vendors/catalogs.py
vendored
22
tailbone/views/vendors/catalogs.py
vendored
|
@ -29,7 +29,6 @@ from __future__ import unicode_literals, absolute_import
|
|||
import logging
|
||||
|
||||
from rattail.db import model, api
|
||||
from rattail.db.batch.vendorcatalog.handler import VendorCatalogHandler
|
||||
from rattail.vendors.catalogs import iter_catalog_parsers
|
||||
|
||||
import formalchemy
|
||||
|
@ -48,7 +47,7 @@ class VendorCatalogsView(FileBatchMasterView):
|
|||
"""
|
||||
model_class = model.VendorCatalog
|
||||
model_row_class = model.VendorCatalogRow
|
||||
batch_handler_class = VendorCatalogHandler
|
||||
default_handler_spec = 'rattail.batch.vendorcatalog:VendorCatalogHandler'
|
||||
url_prefix = '/vendors/catalogs'
|
||||
editable = False
|
||||
|
||||
|
@ -105,6 +104,15 @@ class VendorCatalogsView(FileBatchMasterView):
|
|||
fs.executed_by,
|
||||
])
|
||||
|
||||
def get_batch_kwargs(self, batch):
|
||||
kwargs = super(VendorCatalogsView, self).get_batch_kwargs(batch)
|
||||
kwargs['parser_key'] = batch.parser_key
|
||||
if batch.vendor:
|
||||
kwargs['vendor'] = batch.vendor
|
||||
elif batch.vendor_uuid:
|
||||
kwargs['vendor_uuid'] = batch.vendor_uuid
|
||||
return kwargs
|
||||
|
||||
def configure_row_grid(self, g):
|
||||
g.configure(
|
||||
include=[
|
||||
|
@ -146,16 +154,6 @@ class VendorCatalogsView(FileBatchMasterView):
|
|||
kwargs['parsers'] = parsers
|
||||
return kwargs
|
||||
|
||||
@classmethod
|
||||
def defaults(cls, config):
|
||||
|
||||
# fix permission group title
|
||||
config.add_tailbone_permission_group('vendorcatalogs', "Vendor Catalogs")
|
||||
|
||||
cls._filebatch_defaults(config)
|
||||
cls._batch_defaults(config)
|
||||
cls._defaults(config)
|
||||
|
||||
|
||||
def includeme(config):
|
||||
VendorCatalogsView.defaults(config)
|
||||
|
|
18
tailbone/views/vendors/invoices.py
vendored
18
tailbone/views/vendors/invoices.py
vendored
|
@ -27,7 +27,6 @@ Views for maintaining vendor invoices
|
|||
from __future__ import unicode_literals, absolute_import
|
||||
|
||||
from rattail.db import model, api
|
||||
from rattail.db.batch.vendorinvoice.handler import VendorInvoiceHandler
|
||||
from rattail.vendors.invoices import iter_invoice_parsers, require_invoice_parser
|
||||
|
||||
import formalchemy
|
||||
|
@ -42,7 +41,7 @@ class VendorInvoicesView(FileBatchMasterView):
|
|||
"""
|
||||
model_class = model.VendorInvoice
|
||||
model_row_class = model.VendorInvoiceRow
|
||||
batch_handler_class = VendorInvoiceHandler
|
||||
default_handler_spec = 'rattail.batch.vendorinvoice:VendorInvoiceHandler'
|
||||
url_prefix = '/vendors/invoices'
|
||||
|
||||
def get_instance_title(self, batch):
|
||||
|
@ -109,6 +108,11 @@ class VendorInvoicesView(FileBatchMasterView):
|
|||
except ValueError as error:
|
||||
raise formalchemy.ValidationError(unicode(error))
|
||||
|
||||
def get_batch_kwargs(self, batch):
|
||||
kwargs = super(VendorInvoicesView, self).get_batch_kwargs(batch)
|
||||
kwargs['parser_key'] = batch.parser_key
|
||||
return kwargs
|
||||
|
||||
def init_batch(self, batch):
|
||||
parser = require_invoice_parser(batch.parser_key)
|
||||
vendor = api.get_vendor(Session(), parser.vendor_key)
|
||||
|
@ -148,16 +152,6 @@ class VendorInvoicesView(FileBatchMasterView):
|
|||
attrs['class_'] = 'warning'
|
||||
return attrs
|
||||
|
||||
@classmethod
|
||||
def defaults(cls, config):
|
||||
|
||||
# fix permission group title
|
||||
config.add_tailbone_permission_group('vendorinvoices', "Vendor Invoices")
|
||||
|
||||
cls._filebatch_defaults(config)
|
||||
cls._batch_defaults(config)
|
||||
cls._defaults(config)
|
||||
|
||||
|
||||
def includeme(config):
|
||||
VendorInvoicesView.defaults(config)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue