Add "quick lookup" for mobile Products page
only if enabled, otherwise just shows the normal grid
This commit is contained in:
parent
21740ea2fd
commit
950af8b5e0
7 changed files with 68 additions and 18 deletions
|
@ -725,6 +725,35 @@ class ProductsView(MasterView):
|
|||
'instance_title': self.get_instance_title(instance),
|
||||
'form': form})
|
||||
|
||||
def mobile_index(self):
|
||||
"""
|
||||
Mobile "home" page for products
|
||||
"""
|
||||
self.mobile = True
|
||||
context = {
|
||||
'quick_lookup': False,
|
||||
'placeholder': "Enter {}".format(self.rattail_config.product_key_title()),
|
||||
'quick_lookup_keyboard_wedge': True,
|
||||
}
|
||||
if self.rattail_config.getbool('rattail', 'products.mobile.quick_lookup', default=False):
|
||||
context['quick_lookup'] = True
|
||||
else:
|
||||
self.listing = True
|
||||
grid = self.make_mobile_grid()
|
||||
context['grid'] = grid
|
||||
return self.render_to_response('index', context, mobile=True)
|
||||
|
||||
def mobile_quick_lookup(self):
|
||||
entry = self.request.POST['quick_entry']
|
||||
provided = GPC(entry, calc_check_digit=False)
|
||||
product = api.get_product_by_upc(self.Session(), provided)
|
||||
if not product:
|
||||
checked = GPC(entry, calc_check_digit='upc')
|
||||
product = api.get_product_by_upc(self.Session(), checked)
|
||||
if not product:
|
||||
raise self.notfound()
|
||||
return self.redirect(self.get_action_url('view', product, mobile=True))
|
||||
|
||||
def get_version_child_classes(self):
|
||||
return [
|
||||
(model.ProductCode, 'product_uuid'),
|
||||
|
@ -938,6 +967,10 @@ class ProductsView(MasterView):
|
|||
config.add_route('products.image', '/products/{uuid}/image')
|
||||
config.add_view(cls, attr='image', route_name='products.image')
|
||||
|
||||
# mobile quick lookup
|
||||
config.add_route('mobile.products.quick_lookup', '/mobile/products/quick-lookup')
|
||||
config.add_view(cls, attr='mobile_quick_lookup', route_name='mobile.products.quick_lookup')
|
||||
|
||||
|
||||
class ProductsAutocomplete(AutocompleteView):
|
||||
"""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue