]> asedeno.scripts.mit.edu Git - bluechips.git/commitdiff
Display user's transactions on home page
authorEvan Broder <broder@mit.edu>
Thu, 17 Jul 2008 17:46:59 +0000 (17:46 +0000)
committerEvan Broder <broder@mit.edu>
Thu, 17 Jul 2008 17:46:59 +0000 (17:46 +0000)
bluechips/controllers/status.py
bluechips/templates/status/index.mako

index 37992e59964d7b9d077644e56624b662c82c7bdc..cba63e394a09e039ea948659f4550f3b8ebc2670 100644 (file)
@@ -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):
index 9291b693069180c164d41c7343ed53b275338c93..060bd4e48471f8182da875020273e49f43700ffe 100644 (file)
     <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>
+
+<h2>Your History</h2>
+
+${h.link_to('See all history', h.url_for(controller='history',
+                                         action='index'))}
+
+<h3>Expenditures</h3>
+
+${self.listExpenditures(c.expenditures)}
+
+<h3>Transfers</h3>
+
+${self.listTransfers(c.transfers)}