]> asedeno.scripts.mit.edu Git - bluechips.git/commitdiff
Add history controller to display old transactions
authorEvan Broder <broder@mit.edu>
Thu, 17 Jul 2008 17:46:46 +0000 (17:46 +0000)
committerEvan Broder <broder@mit.edu>
Thu, 17 Jul 2008 17:46:46 +0000 (17:46 +0000)
bluechips/controllers/history.py [new file with mode: 0644]
bluechips/templates/base.mako
bluechips/templates/history/index.mako [new file with mode: 0644]
bluechips/tests/functional/test_history.py [new file with mode: 0644]

diff --git a/bluechips/controllers/history.py b/bluechips/controllers/history.py
new file mode 100644 (file)
index 0000000..986d063
--- /dev/null
@@ -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')
index 5d4bda53b31f5351ae16683d68366b4bbb0dc40a..956a4eeb073c8f7618bacccbd3a9b5885d136b18 100644 (file)
 </html>
 
 <%def name="title()">BlueChips</%def>
+
+<%def name="listExpenditures(es)">
+<table>
+    <tr>
+        <th>Date</th>
+        <th>Spender</th>
+        <th>Description</th>
+        <th>Amount</th>
+    </tr>
+    % for e in es:
+    <tr>
+        <td>${e.date}</td>
+        <td>${e.spender.name}</td>
+        <td>${e.description}</td>
+        <td>$${h.round_currency(e.amount)}</td>
+    </tr>
+    % endfor
+</table>
+</%def>
+
+<%def name="listTransfers(ts)">
+<table>
+    <tr>
+        <th>Date</th>
+        <th>From</th>
+        <th>To</th>
+        <th>Description</th>
+        <th>Amount</th>
+    </tr>
+    % for t in ts:
+    <tr>
+        <td>${t.date}</td>
+        <td>${t.debtor.name}</td>
+        <td>${t.creditor.name}</td>
+        <td>${t.description}</td>
+        <td>$${h.round_currency(t.amount)}</td>
+    </tr>
+    % endfor
+</table>
+</%def>
diff --git a/bluechips/templates/history/index.mako b/bluechips/templates/history/index.mako
new file mode 100644 (file)
index 0000000..41547ca
--- /dev/null
@@ -0,0 +1,11 @@
+<%inherit file="/base.mako"/>
+
+<%def name="title()">${parent.title()} :: History</%def>
+
+<h2>Group Expenditures</h2>
+
+${self.listExpenditures(c.expenditures)}
+
+<h2>Transfers</h2>
+
+${self.listTransfers(c.transfers)}
diff --git a/bluechips/tests/functional/test_history.py b/bluechips/tests/functional/test_history.py
new file mode 100644 (file)
index 0000000..eeec416
--- /dev/null
@@ -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...