Misc. tweaks for vendor catalog batch
per rattail changes, in particular for sake of Corporal, to allow for non-native vendor and product associations
This commit is contained in:
parent
ff904d840f
commit
793022b92f
|
@ -2,7 +2,7 @@
|
||||||
################################################################################
|
################################################################################
|
||||||
#
|
#
|
||||||
# Rattail -- Retail Software Framework
|
# Rattail -- Retail Software Framework
|
||||||
# Copyright © 2010-2020 Lance Edgar
|
# Copyright © 2010-2021 Lance Edgar
|
||||||
#
|
#
|
||||||
# This file is part of Rattail.
|
# This file is part of Rattail.
|
||||||
#
|
#
|
||||||
|
@ -38,7 +38,9 @@ from rattail.db.util import maxlen
|
||||||
from webhelpers2.html import *
|
from webhelpers2.html import *
|
||||||
from webhelpers2.html.tags import *
|
from webhelpers2.html.tags import *
|
||||||
|
|
||||||
from tailbone.util import csrf_token, get_csrf_token, pretty_datetime, raw_datetime
|
from tailbone.util import (csrf_token, get_csrf_token,
|
||||||
|
pretty_datetime, raw_datetime,
|
||||||
|
route_exists)
|
||||||
|
|
||||||
|
|
||||||
def pretty_date(date):
|
def pretty_date(date):
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
<%def name="context_menu_items()">
|
<%def name="context_menu_items()">
|
||||||
${parent.context_menu_items()}
|
${parent.context_menu_items()}
|
||||||
% if 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
|
||||||
</%def>
|
</%def>
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
################################################################################
|
################################################################################
|
||||||
#
|
#
|
||||||
# Rattail -- Retail Software Framework
|
# Rattail -- Retail Software Framework
|
||||||
# Copyright © 2010-2020 Lance Edgar
|
# Copyright © 2010-2021 Lance Edgar
|
||||||
#
|
#
|
||||||
# This file is part of Rattail.
|
# This file is part of Rattail.
|
||||||
#
|
#
|
||||||
|
@ -37,6 +37,7 @@ from rattail.files import resource_path
|
||||||
|
|
||||||
import colander
|
import colander
|
||||||
from pyramid.renderers import get_renderer
|
from pyramid.renderers import get_renderer
|
||||||
|
from pyramid.interfaces import IRoutesMapper
|
||||||
from webhelpers2.html import HTML, tags
|
from webhelpers2.html import HTML, tags
|
||||||
|
|
||||||
|
|
||||||
|
@ -239,3 +240,14 @@ def email_address_is_valid(address):
|
||||||
except colander.Invalid:
|
except colander.Invalid:
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
def route_exists(request, route_name):
|
||||||
|
"""
|
||||||
|
Checks for existence of the given route name, within the running app
|
||||||
|
config. Returns boolean indicating whether it exists.
|
||||||
|
"""
|
||||||
|
reg = request.registry
|
||||||
|
mapper = reg.getUtility(IRoutesMapper)
|
||||||
|
route = mapper.get_route(route_name)
|
||||||
|
return bool(route)
|
||||||
|
|
|
@ -58,6 +58,10 @@ class VendorCatalogView(FileBatchMasterView):
|
||||||
editable = False
|
editable = False
|
||||||
rows_bulk_deletable = True
|
rows_bulk_deletable = True
|
||||||
|
|
||||||
|
labels = {
|
||||||
|
'vendor_id': "Vendor ID",
|
||||||
|
}
|
||||||
|
|
||||||
grid_columns = [
|
grid_columns = [
|
||||||
'id',
|
'id',
|
||||||
'vendor',
|
'vendor',
|
||||||
|
@ -107,6 +111,7 @@ class VendorCatalogView(FileBatchMasterView):
|
||||||
'brand_name',
|
'brand_name',
|
||||||
'description',
|
'description',
|
||||||
'size',
|
'size',
|
||||||
|
'is_preferred_vendor',
|
||||||
'old_vendor_code',
|
'old_vendor_code',
|
||||||
'vendor_code',
|
'vendor_code',
|
||||||
'old_case_size',
|
'old_case_size',
|
||||||
|
@ -148,7 +153,7 @@ class VendorCatalogView(FileBatchMasterView):
|
||||||
|
|
||||||
# vendor
|
# vendor
|
||||||
f.set_renderer('vendor', self.render_vendor)
|
f.set_renderer('vendor', self.render_vendor)
|
||||||
if self.creating:
|
if self.creating and 'vendor' in f:
|
||||||
f.replace('vendor', 'vendor_uuid')
|
f.replace('vendor', 'vendor_uuid')
|
||||||
f.set_node('vendor_uuid', colander.String())
|
f.set_node('vendor_uuid', colander.String())
|
||||||
vendor_display = ""
|
vendor_display = ""
|
||||||
|
@ -167,24 +172,19 @@ class VendorCatalogView(FileBatchMasterView):
|
||||||
# filename
|
# filename
|
||||||
f.set_label('filename', "Catalog File")
|
f.set_label('filename', "Catalog File")
|
||||||
|
|
||||||
|
# parser_key
|
||||||
if self.creating:
|
if self.creating:
|
||||||
|
if 'parser_key' not in f:
|
||||||
f.set_fields([
|
f.insert_after('filename', 'parser_key')
|
||||||
'filename',
|
values = [(p.key, p.display) for p in self.get_parsers()]
|
||||||
'parser_key',
|
values.insert(0, ('', "(please choose)"))
|
||||||
'vendor_uuid',
|
f.set_widget('parser_key', dfwidget.SelectWidget(values=values))
|
||||||
'future',
|
|
||||||
'description',
|
|
||||||
'notes',
|
|
||||||
])
|
|
||||||
|
|
||||||
parser_values = [(p.key, p.display) for p in self.get_parsers()]
|
|
||||||
parser_values.insert(0, ('', "(please choose)"))
|
|
||||||
f.set_widget('parser_key', dfwidget.SelectWidget(values=parser_values))
|
|
||||||
f.set_label('parser_key', "File Type")
|
f.set_label('parser_key', "File Type")
|
||||||
|
|
||||||
# effective
|
# effective
|
||||||
if not self.creating:
|
if self.creating:
|
||||||
|
f.remove('effective')
|
||||||
|
else:
|
||||||
f.set_readonly('effective')
|
f.set_readonly('effective')
|
||||||
|
|
||||||
def get_batch_kwargs(self, batch):
|
def get_batch_kwargs(self, batch):
|
||||||
|
@ -194,6 +194,10 @@ class VendorCatalogView(FileBatchMasterView):
|
||||||
kwargs['vendor'] = batch.vendor
|
kwargs['vendor'] = batch.vendor
|
||||||
elif batch.vendor_uuid:
|
elif batch.vendor_uuid:
|
||||||
kwargs['vendor_uuid'] = batch.vendor_uuid
|
kwargs['vendor_uuid'] = batch.vendor_uuid
|
||||||
|
if batch.vendor_id:
|
||||||
|
kwargs['vendor_id'] = batch.vendor_id
|
||||||
|
if batch.vendor_name:
|
||||||
|
kwargs['vendor_name'] = batch.vendor_name
|
||||||
kwargs['future'] = batch.future
|
kwargs['future'] = batch.future
|
||||||
return kwargs
|
return kwargs
|
||||||
|
|
||||||
|
@ -227,7 +231,8 @@ class VendorCatalogView(FileBatchMasterView):
|
||||||
row.STATUS_UPDATE_COST, # TODO: deprecate/remove this one
|
row.STATUS_UPDATE_COST, # TODO: deprecate/remove this one
|
||||||
row.STATUS_CHANGE_VENDOR_ITEM_CODE,
|
row.STATUS_CHANGE_VENDOR_ITEM_CODE,
|
||||||
row.STATUS_CHANGE_CASE_SIZE,
|
row.STATUS_CHANGE_CASE_SIZE,
|
||||||
row.STATUS_CHANGE_COST):
|
row.STATUS_CHANGE_COST,
|
||||||
|
row.STATUS_CHANGE_PRODUCT):
|
||||||
return 'notice'
|
return 'notice'
|
||||||
|
|
||||||
def configure_row_form(self, f):
|
def configure_row_form(self, f):
|
||||||
|
|
Loading…
Reference in a new issue