From 46b297349fdb6313d34a4128caf6e5b64b57bfa8 Mon Sep 17 00:00:00 2001 From: Evan Broder Date: Thu, 17 Jul 2008 17:46:59 +0000 Subject: [PATCH] Display user's transactions on home page --- bluechips/controllers/status.py | 10 +++++++++- bluechips/templates/status/index.mako | 13 +++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/bluechips/controllers/status.py b/bluechips/controllers/status.py index 37992e5..cba63e3 100644 --- a/bluechips/controllers/status.py +++ b/bluechips/controllers/status.py @@ -12,6 +12,8 @@ import sqlalchemy from datetime import date, timedelta from decimal import Decimal +from pylons import request + log = logging.getLogger(__name__) class StatusController(BaseController): @@ -19,7 +21,6 @@ class StatusController(BaseController): c.debts = debts() c.settle = settle(c.debts) - c.total = self._total(True) year = date.today() - timedelta(days=365) @@ -36,6 +37,13 @@ class StatusController(BaseController): model.expenditures.c.date >= last_month, model.expenditures.c.date < this_month)) + c.expenditures = meta.Session.query(model.Expenditure).\ + filter(model.Expenditure.spender==request.environ['user']).all() + c.transfers = meta.Session.query(model.Transfer).\ + filter(sqlalchemy.or_( + model.Transfer.debtor==request.environ['user'], + model.Transfer.creditor==request.environ['user'])).all() + return render('/status/index.mako') def _total(self, where): diff --git a/bluechips/templates/status/index.mako b/bluechips/templates/status/index.mako index 9291b69..060bd4e 100644 --- a/bluechips/templates/status/index.mako +++ b/bluechips/templates/status/index.mako @@ -54,3 +54,16 @@
  • ${h.link_to('Expenditure for the group', h.url_for(controller='spend', action='index'))}
  • ${h.link_to('Transfer between two people', h.url_for(controller='transfer', action='index'))}
  • + +

    Your History

    + +${h.link_to('See all history', h.url_for(controller='history', + action='index'))} + +

    Expenditures

    + +${self.listExpenditures(c.expenditures)} + +

    Transfers

    + +${self.listTransfers(c.transfers)} -- 2.45.2