Add initial Shopfoo pattern feature
data models, import/export, web views etc.
This commit is contained in:
parent
a7656928f5
commit
852f9d4902
19 changed files with 515 additions and 1 deletions
|
@ -126,6 +126,22 @@ def simple_menus(request):
|
|||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
'title': "Shopfoo",
|
||||
'type': 'menu',
|
||||
'items': [
|
||||
{
|
||||
'title': "Products",
|
||||
'url': url('shopfoo.products'),
|
||||
'perm': 'shopfoo.products.list',
|
||||
},
|
||||
{
|
||||
'title': "Product Exports",
|
||||
'url': url('shopfoo.product_exports'),
|
||||
'perm': 'shopfoo.product_exports.list',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
'title': "Batches",
|
||||
'type': 'menu',
|
||||
|
|
|
@ -37,6 +37,9 @@ def includeme(config):
|
|||
# core-pos views
|
||||
config.include('tailbone_corepos.views.corepos')
|
||||
|
||||
# shopfoo views
|
||||
config.include('rattail_demo.web.views.shopfoo')
|
||||
|
||||
# batch views
|
||||
config.include('tailbone.views.handheld')
|
||||
config.include('tailbone.views.batch.inventory')
|
||||
|
|
9
rattail_demo/web/views/shopfoo/__init__.py
Normal file
9
rattail_demo/web/views/shopfoo/__init__.py
Normal file
|
@ -0,0 +1,9 @@
|
|||
# -*- coding: utf-8; -*-
|
||||
"""
|
||||
Shopfoo views
|
||||
"""
|
||||
|
||||
|
||||
def includeme(config):
|
||||
config.include('rattail_demo.web.views.shopfoo.products')
|
||||
config.include('rattail_demo.web.views.shopfoo.exports')
|
42
rattail_demo/web/views/shopfoo/exports.py
Normal file
42
rattail_demo/web/views/shopfoo/exports.py
Normal file
|
@ -0,0 +1,42 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Views for Shopfoo product exports
|
||||
"""
|
||||
|
||||
from rattail_demo.db import model
|
||||
|
||||
from tailbone.views.exports import ExportMasterView
|
||||
|
||||
|
||||
class ShopfooProductExportView(ExportMasterView):
|
||||
"""
|
||||
Master view for Shopfoo product exports.
|
||||
"""
|
||||
model_class = model.ShopfooProductExport
|
||||
route_prefix = 'shopfoo.product_exports'
|
||||
url_prefix = '/shopfoo/exports/product'
|
||||
downloadable = True
|
||||
editable = True
|
||||
delete_export_files = True
|
||||
|
||||
grid_columns = [
|
||||
'id',
|
||||
'created',
|
||||
'created_by',
|
||||
'filename',
|
||||
'record_count',
|
||||
'uploaded',
|
||||
]
|
||||
|
||||
form_fields = [
|
||||
'id',
|
||||
'created',
|
||||
'created_by',
|
||||
'record_count',
|
||||
'filename',
|
||||
'uploaded',
|
||||
]
|
||||
|
||||
|
||||
def includeme(config):
|
||||
ShopfooProductExportView.defaults(config)
|
70
rattail_demo/web/views/shopfoo/products.py
Normal file
70
rattail_demo/web/views/shopfoo/products.py
Normal file
|
@ -0,0 +1,70 @@
|
|||
# -*- coding: utf-8; -*-
|
||||
"""
|
||||
Shopfoo product views
|
||||
"""
|
||||
|
||||
from rattail_demo.db import model
|
||||
|
||||
from tailbone.views import MasterView
|
||||
|
||||
|
||||
class ShopfooProductView(MasterView):
|
||||
"""
|
||||
Shopfoo Product views
|
||||
"""
|
||||
model_class = model.ShopfooProduct
|
||||
url_prefix = '/shopfoo/products'
|
||||
route_prefix = 'shopfoo.products'
|
||||
creatable = False
|
||||
editable = False
|
||||
bulk_deletable = True
|
||||
has_versions = True
|
||||
|
||||
labels = {
|
||||
'upc': "UPC",
|
||||
}
|
||||
|
||||
grid_columns = [
|
||||
'upc',
|
||||
'description',
|
||||
'price',
|
||||
'enabled',
|
||||
]
|
||||
|
||||
form_fields = [
|
||||
'product',
|
||||
'upc',
|
||||
'description',
|
||||
'price',
|
||||
'enabled',
|
||||
]
|
||||
|
||||
def configure_grid(self, g):
|
||||
super(ShopfooProductView, self).configure_grid(g)
|
||||
|
||||
g.filters['upc'].default_active = True
|
||||
g.filters['upc'].default_verb = 'equal'
|
||||
|
||||
g.filters['description'].default_active = True
|
||||
g.filters['description'].default_verb = 'contains'
|
||||
|
||||
g.set_sort_defaults('upc')
|
||||
|
||||
g.set_type('price', 'currency')
|
||||
|
||||
g.set_link('upc')
|
||||
g.set_link('description')
|
||||
|
||||
def grid_extra_class(self, product, i):
|
||||
if not product.enabled:
|
||||
return 'warning'
|
||||
|
||||
def configure_form(self, f):
|
||||
super(ShopfooProductView, self).configure_form(f)
|
||||
|
||||
f.set_renderer('product', self.render_product)
|
||||
f.set_type('price', 'currency')
|
||||
|
||||
|
||||
def includeme(config):
|
||||
ShopfooProductView.defaults(config)
|
Loading…
Add table
Add a link
Reference in a new issue