diff --git a/tailbone/templates/depositlinks/crud.mako b/tailbone/templates/depositlinks/crud.mako new file mode 100644 index 00000000..d060d295 --- /dev/null +++ b/tailbone/templates/depositlinks/crud.mako @@ -0,0 +1,13 @@ +## -*- coding: utf-8 -*- +<%inherit file="/crud.mako" /> + +<%def name="context_menu_items()"> +
  • ${h.link_to("Back to Deposit Links", url('depositlinks'))}
  • + % if form.readonly: +
  • ${h.link_to("Edit this Deposit Link", url('depositlink.edit', uuid=form.fieldset.model.uuid))}
  • + % elif form.updating: +
  • ${h.link_to("View this Deposit Link", url('depositlink.view', uuid=form.fieldset.model.uuid))}
  • + % endif + + +${parent.body()} diff --git a/tailbone/templates/depositlinks/index.mako b/tailbone/templates/depositlinks/index.mako new file mode 100644 index 00000000..96dd7cd9 --- /dev/null +++ b/tailbone/templates/depositlinks/index.mako @@ -0,0 +1,12 @@ +## -*- coding: utf-8 -*- +<%inherit file="/grid.mako" /> + +<%def name="title()">Deposit Links + +<%def name="context_menu_items()"> + % if request.has_perm('depositlinks.create'): +
  • ${h.link_to("Create a new Deposit Link", url('depositlink.new'))}
  • + % endif + + +${parent.body()} diff --git a/tailbone/templates/taxes/crud.mako b/tailbone/templates/taxes/crud.mako new file mode 100644 index 00000000..471a1397 --- /dev/null +++ b/tailbone/templates/taxes/crud.mako @@ -0,0 +1,13 @@ +## -*- coding: utf-8 -*- +<%inherit file="/crud.mako" /> + +<%def name="context_menu_items()"> +
  • ${h.link_to("Back to Taxes", url('taxes'))}
  • + % if form.readonly: +
  • ${h.link_to("Edit this Tax", url('tax.edit', uuid=form.fieldset.model.uuid))}
  • + % elif form.updating: +
  • ${h.link_to("View this Tax", url('tax.view', uuid=form.fieldset.model.uuid))}
  • + % endif + + +${parent.body()} diff --git a/tailbone/templates/taxes/index.mako b/tailbone/templates/taxes/index.mako new file mode 100644 index 00000000..45ccc728 --- /dev/null +++ b/tailbone/templates/taxes/index.mako @@ -0,0 +1,12 @@ +## -*- coding: utf-8 -*- +<%inherit file="/grid.mako" /> + +<%def name="title()">Taxes + +<%def name="context_menu_items()"> + % if request.has_perm('taxes.create'): +
  • ${h.link_to("Create a new Tax", url('tax.new'))}
  • + % endif + + +${parent.body()} diff --git a/tailbone/views/__init__.py b/tailbone/views/__init__.py index 6a8ae08b..73514093 100644 --- a/tailbone/views/__init__.py +++ b/tailbone/views/__init__.py @@ -56,6 +56,7 @@ def includeme(config): config.include('tailbone.views.customergroups') config.include('tailbone.views.customers') config.include('tailbone.views.departments') + config.include('tailbone.views.depositlinks') config.include('tailbone.views.employees') config.include('tailbone.views.families') config.include('tailbone.views.labels') @@ -66,5 +67,6 @@ def includeme(config): config.include('tailbone.views.roles') config.include('tailbone.views.stores') config.include('tailbone.views.subdepartments') + config.include('tailbone.views.taxes') config.include('tailbone.views.users') config.include('tailbone.views.vendors') diff --git a/tailbone/views/depositlinks.py b/tailbone/views/depositlinks.py new file mode 100644 index 00000000..b7a038ea --- /dev/null +++ b/tailbone/views/depositlinks.py @@ -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 . +# +################################################################################ +""" +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') diff --git a/tailbone/views/products.py b/tailbone/views/products.py index ef6bf258..c270d307 100644 --- a/tailbone/views/products.py +++ b/tailbone/views/products.py @@ -285,6 +285,9 @@ class ProductCrud(CrudView): fs.report_code, fs.regular_price, fs.current_price, + fs.deposit_link, + fs.tax, + fs.organic, fs.not_for_sale, fs.deleted, ]) diff --git a/tailbone/views/taxes.py b/tailbone/views/taxes.py new file mode 100644 index 00000000..5696cc19 --- /dev/null +++ b/tailbone/views/taxes.py @@ -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 . +# +################################################################################ +""" +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')