Add product report codes to the UI.
This commit is contained in:
parent
bdf835a4dd
commit
6943298ee0
2
setup.py
2
setup.py
|
@ -84,7 +84,7 @@ requires = [
|
||||||
'pyramid_exclog', # 0.6
|
'pyramid_exclog', # 0.6
|
||||||
'pyramid_simpleform', # 0.6.1
|
'pyramid_simpleform', # 0.6.1
|
||||||
'pyramid_tm', # 0.3
|
'pyramid_tm', # 0.3
|
||||||
'rattail[db]>=0.3.18', # 0.3.18
|
u'rattail[db]>=0.3.32', # 0.3.32
|
||||||
'transaction', # 1.2.0
|
'transaction', # 1.2.0
|
||||||
'waitress', # 0.8.1
|
'waitress', # 0.8.1
|
||||||
'WebHelpers', # 1.3
|
'WebHelpers', # 1.3
|
||||||
|
|
13
tailbone/templates/reportcodes/crud.mako
Normal file
13
tailbone/templates/reportcodes/crud.mako
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
## -*- coding: utf-8 -*-
|
||||||
|
<%inherit file="/crud.mako" />
|
||||||
|
|
||||||
|
<%def name="context_menu_items()">
|
||||||
|
<li>${h.link_to(u"Back to Report Codes", url(u'reportcodes'))}</li>
|
||||||
|
% if form.readonly:
|
||||||
|
<li>${h.link_to(u"Edit this Report Code", url(u'reportcode.update', uuid=form.fieldset.model.uuid))}</li>
|
||||||
|
% elif form.updating:
|
||||||
|
<li>${h.link_to(u"View this Report Code", url(u'reportcode.read', uuid=form.fieldset.model.uuid))}</li>
|
||||||
|
% endif
|
||||||
|
</%def>
|
||||||
|
|
||||||
|
${parent.body()}
|
12
tailbone/templates/reportcodes/index.mako
Normal file
12
tailbone/templates/reportcodes/index.mako
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
## -*- coding: utf-8 -*-
|
||||||
|
<%inherit file="/grid.mako" />
|
||||||
|
|
||||||
|
<%def name="title()">Report Codes</%def>
|
||||||
|
|
||||||
|
<%def name="context_menu_items()">
|
||||||
|
% if request.has_perm(u'reportcodes.create'):
|
||||||
|
<li>${h.link_to(u"Create a new Report Code", url(u'reportcode.create'))}</li>
|
||||||
|
% endif
|
||||||
|
</%def>
|
||||||
|
|
||||||
|
${parent.body()}
|
|
@ -1,9 +1,8 @@
|
||||||
#!/usr/bin/env python
|
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
################################################################################
|
################################################################################
|
||||||
#
|
#
|
||||||
# Rattail -- Retail Software Framework
|
# Rattail -- Retail Software Framework
|
||||||
# Copyright © 2010-2012 Lance Edgar
|
# Copyright © 2010-2014 Lance Edgar
|
||||||
#
|
#
|
||||||
# This file is part of Rattail.
|
# This file is part of Rattail.
|
||||||
#
|
#
|
||||||
|
@ -63,6 +62,7 @@ def includeme(config):
|
||||||
config.include('tailbone.views.people')
|
config.include('tailbone.views.people')
|
||||||
config.include('tailbone.views.products')
|
config.include('tailbone.views.products')
|
||||||
config.include('tailbone.views.progress')
|
config.include('tailbone.views.progress')
|
||||||
|
config.include(u'tailbone.views.reportcodes')
|
||||||
config.include('tailbone.views.roles')
|
config.include('tailbone.views.roles')
|
||||||
config.include('tailbone.views.stores')
|
config.include('tailbone.views.stores')
|
||||||
config.include('tailbone.views.subdepartments')
|
config.include('tailbone.views.subdepartments')
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
#!/usr/bin/env python
|
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
################################################################################
|
################################################################################
|
||||||
#
|
#
|
||||||
# Rattail -- Retail Software Framework
|
# Rattail -- Retail Software Framework
|
||||||
# Copyright © 2010-2012 Lance Edgar
|
# Copyright © 2010-2014 Lance Edgar
|
||||||
#
|
#
|
||||||
# This file is part of Rattail.
|
# This file is part of Rattail.
|
||||||
#
|
#
|
||||||
|
@ -102,6 +101,8 @@ class ProductsGrid(SearchableAlchemyGridView):
|
||||||
'subdepartment':
|
'subdepartment':
|
||||||
lambda q: q.outerjoin(Subdepartment,
|
lambda q: q.outerjoin(Subdepartment,
|
||||||
Subdepartment.uuid == Product.subdepartment_uuid),
|
Subdepartment.uuid == Product.subdepartment_uuid),
|
||||||
|
u'report_code':
|
||||||
|
lambda q: q.outerjoin(model.ReportCode),
|
||||||
'regular_price':
|
'regular_price':
|
||||||
lambda q: q.outerjoin(ProductPrice,
|
lambda q: q.outerjoin(ProductPrice,
|
||||||
ProductPrice.uuid == Product.regular_price_uuid),
|
ProductPrice.uuid == Product.regular_price_uuid),
|
||||||
|
@ -146,6 +147,7 @@ class ProductsGrid(SearchableAlchemyGridView):
|
||||||
brand=self.filter_ilike(Brand.name),
|
brand=self.filter_ilike(Brand.name),
|
||||||
family=self.filter_ilike(model.Family.name),
|
family=self.filter_ilike(model.Family.name),
|
||||||
department=self.filter_ilike(Department.name),
|
department=self.filter_ilike(Department.name),
|
||||||
|
report_code=self.filter_ilike(model.ReportCode.name),
|
||||||
subdepartment=self.filter_ilike(Subdepartment.name),
|
subdepartment=self.filter_ilike(Subdepartment.name),
|
||||||
vendor=self.filter_ilike(Vendor.name),
|
vendor=self.filter_ilike(Vendor.name),
|
||||||
vendor_any=self.filter_ilike(self.VendorAny.name),
|
vendor_any=self.filter_ilike(self.VendorAny.name),
|
||||||
|
@ -257,8 +259,9 @@ class ProductCrud(CrudView):
|
||||||
fs.description,
|
fs.description,
|
||||||
fs.size,
|
fs.size,
|
||||||
fs.department,
|
fs.department,
|
||||||
fs.family,
|
|
||||||
fs.subdepartment,
|
fs.subdepartment,
|
||||||
|
fs.family,
|
||||||
|
fs.report_code,
|
||||||
fs.regular_price,
|
fs.regular_price,
|
||||||
fs.current_price,
|
fs.current_price,
|
||||||
])
|
])
|
||||||
|
|
112
tailbone/views/reportcodes.py
Normal file
112
tailbone/views/reportcodes.py
Normal file
|
@ -0,0 +1,112 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
################################################################################
|
||||||
|
#
|
||||||
|
# Rattail -- Retail Software Framework
|
||||||
|
# Copyright © 2010-2014 Lance Edgar
|
||||||
|
#
|
||||||
|
# This file is part of Rattail.
|
||||||
|
#
|
||||||
|
# Rattail is free software: you can redistribute it and/or modify it under the
|
||||||
|
# terms of the GNU Affero General Public License as published by the Free
|
||||||
|
# Software Foundation, either version 3 of the License, or (at your option)
|
||||||
|
# any later version.
|
||||||
|
#
|
||||||
|
# Rattail is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||||
|
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||||
|
# FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
|
||||||
|
# more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
|
# along with Rattail. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
"""
|
||||||
|
Report Code Views
|
||||||
|
"""
|
||||||
|
|
||||||
|
from tailbone.views import SearchableAlchemyGridView, CrudView
|
||||||
|
|
||||||
|
from rattail.db import model
|
||||||
|
|
||||||
|
|
||||||
|
class ReportCodesGrid(SearchableAlchemyGridView):
|
||||||
|
|
||||||
|
mapped_class = model.ReportCode
|
||||||
|
config_prefix = u'reportcodes'
|
||||||
|
sort = u'name'
|
||||||
|
|
||||||
|
def filter_map(self):
|
||||||
|
return self.make_filter_map(
|
||||||
|
exact=[u'code'],
|
||||||
|
ilike=[u'name'])
|
||||||
|
|
||||||
|
def filter_config(self):
|
||||||
|
return self.make_filter_config(
|
||||||
|
include_filter_name=True,
|
||||||
|
filter_type_name=u'lk')
|
||||||
|
|
||||||
|
def sort_map(self):
|
||||||
|
return self.make_sort_map(u'code', u'name')
|
||||||
|
|
||||||
|
def grid(self):
|
||||||
|
g = self.make_grid()
|
||||||
|
g.configure(
|
||||||
|
include=[
|
||||||
|
g.code,
|
||||||
|
g.name,
|
||||||
|
],
|
||||||
|
readonly=True)
|
||||||
|
if self.request.has_perm(u'reportcodes.read'):
|
||||||
|
g.viewable = True
|
||||||
|
g.view_route_name = u'reportcode.read'
|
||||||
|
if self.request.has_perm(u'reportcodes.update'):
|
||||||
|
g.editable = True
|
||||||
|
g.edit_route_name = u'reportcode.update'
|
||||||
|
if self.request.has_perm(u'reportcodes.delete'):
|
||||||
|
g.deletable = True
|
||||||
|
g.delete_route_name = u'reportcode.delete'
|
||||||
|
return g
|
||||||
|
|
||||||
|
|
||||||
|
class ReportCodeCrud(CrudView):
|
||||||
|
|
||||||
|
mapped_class = model.ReportCode
|
||||||
|
home_route = u'reportcodes'
|
||||||
|
|
||||||
|
def fieldset(self, model):
|
||||||
|
fs = self.make_fieldset(model)
|
||||||
|
fs.configure(
|
||||||
|
include=[
|
||||||
|
fs.code,
|
||||||
|
fs.name,
|
||||||
|
])
|
||||||
|
return fs
|
||||||
|
|
||||||
|
|
||||||
|
def add_routes(config):
|
||||||
|
config.add_route(u'reportcodes', u'/reportcodes')
|
||||||
|
config.add_route(u'reportcode.create', u'/reportcodes/new')
|
||||||
|
config.add_route(u'reportcode.read', u'/reportcodes/{uuid}')
|
||||||
|
config.add_route(u'reportcode.update', u'/reportcodes/{uuid}/edit')
|
||||||
|
config.add_route(u'reportcode.delete', u'/reportcodes/{uuid}/delete')
|
||||||
|
|
||||||
|
|
||||||
|
def includeme(config):
|
||||||
|
add_routes(config)
|
||||||
|
|
||||||
|
config.add_view(ReportCodesGrid, route_name=u'reportcodes',
|
||||||
|
renderer=u'/reportcodes/index.mako',
|
||||||
|
permission=u'reportcodes.list')
|
||||||
|
|
||||||
|
config.add_view(ReportCodeCrud, attr=u'create', route_name=u'reportcode.create',
|
||||||
|
renderer=u'/reportcodes/crud.mako',
|
||||||
|
permission=u'reportcodes.create')
|
||||||
|
config.add_view(ReportCodeCrud, attr=u'read', route_name=u'reportcode.read',
|
||||||
|
renderer=u'/reportcodes/crud.mako',
|
||||||
|
permission=u'reportcodes.read')
|
||||||
|
config.add_view(ReportCodeCrud, attr=u'update', route_name=u'reportcode.update',
|
||||||
|
renderer=u'/reportcodes/crud.mako',
|
||||||
|
permission=u'reportcodes.update')
|
||||||
|
config.add_view(ReportCodeCrud, attr=u'delete', route_name=u'reportcode.delete',
|
||||||
|
permission=u'reportcodes.delete')
|
Loading…
Reference in a new issue