Add views for deposit links, taxes; update product view.

This commit is contained in:
Lance Edgar 2015-02-26 19:06:20 -06:00
parent d30d6f84e6
commit d50aef4e49
8 changed files with 270 additions and 0 deletions

View file

@ -0,0 +1,13 @@
## -*- coding: utf-8 -*-
<%inherit file="/crud.mako" />
<%def name="context_menu_items()">
<li>${h.link_to("Back to Deposit Links", url('depositlinks'))}</li>
% if form.readonly:
<li>${h.link_to("Edit this Deposit Link", url('depositlink.edit', uuid=form.fieldset.model.uuid))}</li>
% elif form.updating:
<li>${h.link_to("View this Deposit Link", url('depositlink.view', uuid=form.fieldset.model.uuid))}</li>
% endif
</%def>
${parent.body()}

View file

@ -0,0 +1,12 @@
## -*- coding: utf-8 -*-
<%inherit file="/grid.mako" />
<%def name="title()">Deposit Links</%def>
<%def name="context_menu_items()">
% if request.has_perm('depositlinks.create'):
<li>${h.link_to("Create a new Deposit Link", url('depositlink.new'))}</li>
% endif
</%def>
${parent.body()}

View file

@ -0,0 +1,13 @@
## -*- coding: utf-8 -*-
<%inherit file="/crud.mako" />
<%def name="context_menu_items()">
<li>${h.link_to("Back to Taxes", url('taxes'))}</li>
% if form.readonly:
<li>${h.link_to("Edit this Tax", url('tax.edit', uuid=form.fieldset.model.uuid))}</li>
% elif form.updating:
<li>${h.link_to("View this Tax", url('tax.view', uuid=form.fieldset.model.uuid))}</li>
% endif
</%def>
${parent.body()}

View file

@ -0,0 +1,12 @@
## -*- coding: utf-8 -*-
<%inherit file="/grid.mako" />
<%def name="title()">Taxes</%def>
<%def name="context_menu_items()">
% if request.has_perm('taxes.create'):
<li>${h.link_to("Create a new Tax", url('tax.new'))}</li>
% endif
</%def>
${parent.body()}

View file

@ -56,6 +56,7 @@ def includeme(config):
config.include('tailbone.views.customergroups') config.include('tailbone.views.customergroups')
config.include('tailbone.views.customers') config.include('tailbone.views.customers')
config.include('tailbone.views.departments') config.include('tailbone.views.departments')
config.include('tailbone.views.depositlinks')
config.include('tailbone.views.employees') config.include('tailbone.views.employees')
config.include('tailbone.views.families') config.include('tailbone.views.families')
config.include('tailbone.views.labels') config.include('tailbone.views.labels')
@ -66,5 +67,6 @@ def includeme(config):
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')
config.include('tailbone.views.taxes')
config.include('tailbone.views.users') config.include('tailbone.views.users')
config.include('tailbone.views.vendors') config.include('tailbone.views.vendors')

View file

@ -0,0 +1,108 @@
# -*- coding: utf-8 -*-
################################################################################
#
# Rattail -- Retail Software Framework
# Copyright © 2010-2015 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/>.
#
################################################################################
"""
Deposit Link Views
"""
from __future__ import unicode_literals
from rattail.db import model
from tailbone.views import SearchableAlchemyGridView, CrudView
class DepositLinksGrid(SearchableAlchemyGridView):
mapped_class = model.DepositLink
config_prefix = 'depositlinks'
sort = 'code'
def filter_map(self):
return self.make_filter_map(exact=['code', 'amount'],
ilike=['description'])
def filter_config(self):
return self.make_filter_config(include_filter_description=True,
filter_type_description='lk')
def grid(self):
g = self.make_grid()
g.configure(
include=[
g.code,
g.description,
g.amount,
],
readonly=True)
if self.request.has_perm('depositlinks.view'):
g.viewable = True
g.view_route_name = 'depositlink.view'
if self.request.has_perm('depositlinks.edit'):
g.editable = True
g.edit_route_name = 'depositlink.edit'
if self.request.has_perm('depositlinks.delete'):
g.deletable = True
g.delete_route_name = 'depositlink.delete'
return g
class DepositLinkCrud(CrudView):
mapped_class = model.DepositLink
home_route = 'depositlinks'
def fieldset(self, model):
fs = self.make_fieldset(model)
fs.configure(
include=[
fs.code,
fs.description,
fs.amount,
])
return fs
def add_routes(config):
config.add_route('depositlinks', '/depositlinks')
config.add_route('depositlink.new', '/depositlinks/new')
config.add_route('depositlink.view', '/depositlinks/{uuid}')
config.add_route('depositlink.edit', '/depositlinks/{uuid}/edit')
config.add_route('depositlink.delete', '/depositlinks/{uuid}/delete')
def includeme(config):
add_routes(config)
# list deposit links
config.add_view(DepositLinksGrid, route_name='depositlinks',
renderer='/depositlinks/index.mako', permission='depositlinks.view')
# deposit link crud
config.add_view(DepositLinkCrud, attr='create', route_name='depositlink.new',
renderer='/depositlinks/crud.mako', permission='depositlinks.create')
config.add_view(DepositLinkCrud, attr='read', route_name='depositlink.view',
renderer='/depositlinks/crud.mako', permission='depositlinks.view')
config.add_view(DepositLinkCrud, attr='update', route_name='depositlink.edit',
renderer='/depositlinks/crud.mako', permission='depositlinks.edit')
config.add_view(DepositLinkCrud, attr='delete', route_name='depositlink.delete',
permission='depositlinks.delete')

View file

@ -285,6 +285,9 @@ class ProductCrud(CrudView):
fs.report_code, fs.report_code,
fs.regular_price, fs.regular_price,
fs.current_price, fs.current_price,
fs.deposit_link,
fs.tax,
fs.organic,
fs.not_for_sale, fs.not_for_sale,
fs.deleted, fs.deleted,
]) ])

107
tailbone/views/taxes.py Normal file
View file

@ -0,0 +1,107 @@
# -*- coding: utf-8 -*-
################################################################################
#
# Rattail -- Retail Software Framework
# Copyright © 2010-2015 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/>.
#
################################################################################
"""
Tax Views
"""
from __future__ import unicode_literals
from rattail.db import model
from tailbone.views import SearchableAlchemyGridView, CrudView
class TaxesGrid(SearchableAlchemyGridView):
mapped_class = model.Tax
config_prefix = 'taxes'
sort = 'code'
def filter_map(self):
return self.make_filter_map(exact=['code'], ilike=['description'])
def filter_config(self):
return self.make_filter_config(include_filter_description=True,
filter_type_description='lk')
def grid(self):
g = self.make_grid()
g.configure(
include=[
g.code,
g.description,
g.rate,
],
readonly=True)
if self.request.has_perm('taxes.view'):
g.viewable = True
g.view_route_name = 'tax.view'
if self.request.has_perm('taxes.edit'):
g.editable = True
g.edit_route_name = 'tax.edit'
if self.request.has_perm('taxes.delete'):
g.deletable = True
g.delete_route_name = 'tax.delete'
return g
class TaxCrud(CrudView):
mapped_class = model.Tax
home_route = 'taxes'
def fieldset(self, model):
fs = self.make_fieldset(model)
fs.configure(
include=[
fs.code,
fs.description,
fs.rate,
])
return fs
def add_routes(config):
config.add_route('taxes', '/taxes')
config.add_route('tax.new', '/taxes/new')
config.add_route('tax.view', '/taxes/{uuid}')
config.add_route('tax.edit', '/taxes/{uuid}/edit')
config.add_route('tax.delete', '/taxes/{uuid}/delete')
def includeme(config):
add_routes(config)
# list taxes
config.add_view(TaxesGrid, route_name='taxes',
renderer='/taxes/index.mako', permission='taxes.view')
# tax crud
config.add_view(TaxCrud, attr='create', route_name='tax.new',
renderer='/taxes/crud.mako', permission='taxes.create')
config.add_view(TaxCrud, attr='read', route_name='tax.view',
renderer='/taxes/crud.mako', permission='taxes.view')
config.add_view(TaxCrud, attr='update', route_name='tax.edit',
renderer='/taxes/crud.mako', permission='taxes.edit')
config.add_view(TaxCrud, attr='delete', route_name='tax.delete',
permission='taxes.delete')