From a87834811aead8d14d349c2a0fa7af6a4d57001d Mon Sep 17 00:00:00 2001 From: Evan Broder Date: Thu, 17 Jul 2008 17:46:46 +0000 Subject: [PATCH] Add history controller to display old transactions --- bluechips/controllers/history.py | 19 ++++++++++ bluechips/templates/base.mako | 40 ++++++++++++++++++++++ bluechips/templates/history/index.mako | 11 ++++++ bluechips/tests/functional/test_history.py | 7 ++++ 4 files changed, 77 insertions(+) create mode 100644 bluechips/controllers/history.py create mode 100644 bluechips/templates/history/index.mako create mode 100644 bluechips/tests/functional/test_history.py diff --git a/bluechips/controllers/history.py b/bluechips/controllers/history.py new file mode 100644 index 0000000..986d063 --- /dev/null +++ b/bluechips/controllers/history.py @@ -0,0 +1,19 @@ +""" +Display old transactions +""" + +import logging + +from bluechips.lib.base import * +from bluechips.lib.totals import * + +import sqlalchemy + +log = logging.getLogger(__name__) + +class HistoryController(BaseController): + def index(self): + c.expenditures = meta.Session.query(model.Expenditure).all() + c.transfers = meta.Session.query(model.Transfer).all() + + return render('/history/index.mako') diff --git a/bluechips/templates/base.mako b/bluechips/templates/base.mako index 5d4bda5..956a4ee 100644 --- a/bluechips/templates/base.mako +++ b/bluechips/templates/base.mako @@ -23,3 +23,43 @@ <%def name="title()">BlueChips + +<%def name="listExpenditures(es)"> + + + + + + + + % for e in es: + + + + + + + % endfor +
DateSpenderDescriptionAmount
${e.date}${e.spender.name}${e.description}$${h.round_currency(e.amount)}
+ + +<%def name="listTransfers(ts)"> + + + + + + + + + % for t in ts: + + + + + + + + % endfor +
DateFromToDescriptionAmount
${t.date}${t.debtor.name}${t.creditor.name}${t.description}$${h.round_currency(t.amount)}
+ diff --git a/bluechips/templates/history/index.mako b/bluechips/templates/history/index.mako new file mode 100644 index 0000000..41547ca --- /dev/null +++ b/bluechips/templates/history/index.mako @@ -0,0 +1,11 @@ +<%inherit file="/base.mako"/> + +<%def name="title()">${parent.title()} :: History + +

Group Expenditures

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

Transfers

+ +${self.listTransfers(c.transfers)} diff --git a/bluechips/tests/functional/test_history.py b/bluechips/tests/functional/test_history.py new file mode 100644 index 0000000..eeec416 --- /dev/null +++ b/bluechips/tests/functional/test_history.py @@ -0,0 +1,7 @@ +from bluechips.tests import * + +class TestHistoryController(TestController): + + def test_index(self): + response = self.app.get(url_for(controller='history')) + # Test response... -- 2.45.2