diff --git a/pyalchemybiz/controllers/customer.py b/pyalchemybiz/controllers/customer.py index 37a5a01..b0de99a 100644 --- a/pyalchemybiz/controllers/customer.py +++ b/pyalchemybiz/controllers/customer.py @@ -1,12 +1,14 @@ # -*- coding: utf-8 -*- import logging -from pyalchemybiz.lib.base import BaseController, _, c, render, redirect_to +from pyalchemybiz.lib.base import BaseController, _, c, render, redirect_to, \ + request from pyalchemybiz.model import customer, meta, person from pylons.decorators import validate from pylons.decorators.rest import restrict import formencode from formencode import htmlfill +import webhelpers.paginate as paginate log = logging.getLogger(__name__) @@ -35,7 +37,12 @@ class CustomerController(BaseController): """ Show a customer list. """ - c.customers = meta.Session.query(customer.Customer).all() + records = meta.Session.query(customer.Customer) + c.paginator = paginate.Page( + records, + page = int(request.params.get('page', 1)), + items_per_page = 10, + ) return render('/derived/customer/list.mako') def view(self, id=None): diff --git a/pyalchemybiz/templates/derived/customer/list.mako b/pyalchemybiz/templates/derived/customer/list.mako index f3844fb..c773b88 100644 --- a/pyalchemybiz/templates/derived/customer/list.mako +++ b/pyalchemybiz/templates/derived/customer/list.mako @@ -1,9 +1,46 @@ <%inherit file="/base/customer.mako" /> -
${c.paginator.pager(_('$link_first $link_previous $first_item to $last_item of $item_count $link_next $link_last'))}
+${_('Customer ID')} | +${_('Customer')} | +
---|
${c.paginator.pager('~2~')}
+%else: ++ ${_('No customers have yet been created.')} + ${h.link_to(_('Add one'), h.url_for(controller='customer', action='new'))}. +
+%endif diff --git a/pyalchemybiz/templates/derived/customer/view.mako b/pyalchemybiz/templates/derived/customer/view.mako index d574909..ac8f6d2 100644 --- a/pyalchemybiz/templates/derived/customer/view.mako +++ b/pyalchemybiz/templates/derived/customer/view.mako @@ -1,5 +1,7 @@ <%inherit file="/base/customer.mako" /> +<%def name="heading()">+ ${h.link_to(_('All Customers'), h.url_for(controller='customer', action='list', id=None))} +| ${h.link_to(_('New Customer'), h.url_for(controller='customer', action='new', id=None))} +| ${h.link_to(_('Edit Customer'), h.url_for(controller='customer', action='edit'))} +| ${h.link_to(_('Delete Customer'), h.url_for(controller='customer', action='delete'))} +
+${parent.footer()} +%def>