From: Evan Broder Date: Thu, 17 Jul 2008 17:46:46 +0000 (+0000) Subject: Add history controller to display old transactions X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=commitdiff_plain;h=a87834811aead8d14d349c2a0fa7af6a4d57001d;hp=7251a413002768b8544964c7d7197e0bb4748423;p=bluechips.git Add history controller to display old transactions --- 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...