Add configurable template file for vendor catalog batch
This commit is contained in:
parent
ad110c2ce2
commit
f89dc88c0e
BIN
tailbone/static/files/vendor_catalog_template.xlsx
Normal file
BIN
tailbone/static/files/vendor_catalog_template.xlsx
Normal file
Binary file not shown.
9
tailbone/templates/batch/vendorcatalog/configure.mako
Normal file
9
tailbone/templates/batch/vendorcatalog/configure.mako
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
## -*- coding: utf-8; -*-
|
||||||
|
<%inherit file="/configure.mako" />
|
||||||
|
|
||||||
|
<%def name="form_content()">
|
||||||
|
${self.input_file_templates_section()}
|
||||||
|
</%def>
|
||||||
|
|
||||||
|
|
||||||
|
${parent.body()}
|
|
@ -3,9 +3,6 @@
|
||||||
|
|
||||||
<%def name="context_menu_items()">
|
<%def name="context_menu_items()">
|
||||||
${parent.context_menu_items()}
|
${parent.context_menu_items()}
|
||||||
% if generic_template_url and master.has_perm('create'):
|
|
||||||
<li>${h.link_to("Download Generic Template", generic_template_url)}</li>
|
|
||||||
% endif
|
|
||||||
% if h.route_exists(request, 'vendors') and request.has_perm('vendors.list'):
|
% if h.route_exists(request, 'vendors') and request.has_perm('vendors.list'):
|
||||||
<li>${h.link_to("View Vendors", url('vendors'))}</li>
|
<li>${h.link_to("View Vendors", url('vendors'))}</li>
|
||||||
% endif
|
% endif
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
################################################################################
|
################################################################################
|
||||||
#
|
#
|
||||||
# Rattail -- Retail Software Framework
|
# Rattail -- Retail Software Framework
|
||||||
# Copyright © 2010-2021 Lance Edgar
|
# Copyright © 2010-2022 Lance Edgar
|
||||||
#
|
#
|
||||||
# This file is part of Rattail.
|
# This file is part of Rattail.
|
||||||
#
|
#
|
||||||
|
@ -57,6 +57,8 @@ class VendorCatalogView(FileBatchMasterView):
|
||||||
template_prefix = '/batch/vendorcatalog'
|
template_prefix = '/batch/vendorcatalog'
|
||||||
editable = False
|
editable = False
|
||||||
rows_bulk_deletable = True
|
rows_bulk_deletable = True
|
||||||
|
has_input_file_templates = True
|
||||||
|
configurable = True
|
||||||
|
|
||||||
labels = {
|
labels = {
|
||||||
'vendor_id': "Vendor ID",
|
'vendor_id': "Vendor ID",
|
||||||
|
@ -133,6 +135,14 @@ class VendorCatalogView(FileBatchMasterView):
|
||||||
'status_text',
|
'status_text',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
def get_input_file_templates(self):
|
||||||
|
return [
|
||||||
|
{'key': 'default',
|
||||||
|
'label': "Default",
|
||||||
|
'default_url': self.request.static_url(
|
||||||
|
'tailbone:static/files/vendor_catalog_template.xlsx')},
|
||||||
|
]
|
||||||
|
|
||||||
def get_parsers(self):
|
def get_parsers(self):
|
||||||
if not hasattr(self, 'parsers'):
|
if not hasattr(self, 'parsers'):
|
||||||
parsers = sorted(iter_catalog_parsers(), key=lambda p: p.display)
|
parsers = sorted(iter_catalog_parsers(), key=lambda p: p.display)
|
||||||
|
@ -252,11 +262,6 @@ class VendorCatalogView(FileBatchMasterView):
|
||||||
f.set_type('upc', 'gpc')
|
f.set_type('upc', 'gpc')
|
||||||
f.set_type('discount_percent', 'percent')
|
f.set_type('discount_percent', 'percent')
|
||||||
|
|
||||||
def template_kwargs_index(self, **kwargs):
|
|
||||||
url = self.rattail_config.get('tailbone', 'batch.vendorcatalog.generic_template_url')
|
|
||||||
kwargs['generic_template_url'] = url
|
|
||||||
return kwargs
|
|
||||||
|
|
||||||
def template_kwargs_create(self, **kwargs):
|
def template_kwargs_create(self, **kwargs):
|
||||||
parsers = self.get_parsers()
|
parsers = self.get_parsers()
|
||||||
for parser in parsers:
|
for parser in parsers:
|
||||||
|
|
Loading…
Reference in a new issue