]> asedeno.scripts.mit.edu Git - bluechips.git/commitdiff
And output the outstanding debts on the home page
authorEvan Broder <broder@mit.edu>
Wed, 16 Jul 2008 07:04:56 +0000 (07:04 +0000)
committerEvan Broder <broder@mit.edu>
Wed, 16 Jul 2008 07:04:56 +0000 (07:04 +0000)
bluechips/controllers/status.py
bluechips/templates/status/index.mako [new file with mode: 0644]

index 491493e1ec48cda16d8434bb28181411af4d22ed..fa084481011f62fbb8d0289c5ce9a7904064ac9d 100644 (file)
@@ -5,9 +5,13 @@ Calculate the current state of the books
 import logging
 
 from bluechips.lib.base import *
+from bluechips.lib.totals import *
 
 log = logging.getLogger(__name__)
 
 class StatusController(BaseController):
     def index(self):
-        return 'Hello World'
+        c.debts = debts()
+        c.settle = settle(c.debts)
+        
+        return render('/status/index.mako')
diff --git a/bluechips/templates/status/index.mako b/bluechips/templates/status/index.mako
new file mode 100644 (file)
index 0000000..777d09f
--- /dev/null
@@ -0,0 +1,31 @@
+<%inherit file="/base.mako"/>
+
+<h2>Settling Transfers</h2>
+
+% if len(c.settle) == 0:
+<p>No need! The books are balanced!</p>
+% else:
+<p>To balance the books, the following transfers need to be made:</p>
+
+<table>
+    <tr>
+        <th>From</th>
+        <th>To</th>
+        <th>Amount</th>
+    </tr>
+    % for transfer in c.settle:
+    <tr>
+        <td>${transfer[0].username}</td>
+        <td>${transfer[1].username}</td>
+        <td>$${h.round_currency(transfer[2])}</td>
+    </tr>
+    % endfor
+</table>
+% endif
+
+<h2>Add a new transaction</h2>
+
+<ul>
+    <li>${h.link_to('Expenditure for the group', h.url_for(controller='spend', action='index'))}</li>
+    <li>${h.link_to('Transfer between two people', h.url_for(controller='transfer', action='index'))}</li>
+</ul>