]> asedeno.scripts.mit.edu Git - bluechips.git/commitdiff
added a 'My Share' column to lists of expenditures
authorScott Torborg <scott@crookedmedia.com>
Tue, 3 Nov 2009 01:36:10 +0000 (15:36 -1000)
committerScott Torborg <scott@crookedmedia.com>
Tue, 3 Nov 2009 01:36:10 +0000 (15:36 -1000)
bluechips/model/expenditure.py
bluechips/public/css/main.css
bluechips/templates/base.mako

index dda06c1e0a9c7bf837e3668eef7835dc5cf2ca70..296ecf04929aa2c3c66790d3f5a86a76cdcd88b9 100644 (file)
@@ -93,4 +93,14 @@ class Expenditure(object):
                 filter(Split.user == user).\
                 filter(Split.share != 0).first() is not None)
 
+    def share(self, user):
+        "Return the share corresponding to ``user``."
+        share = meta.Session.query(Split.share).\
+                filter(Split.expenditure == self).\
+                filter(Split.user == user).scalar()
+        if share is None:
+            return Currency(0)
+        else:
+            return share
+
 __all__ = ['Expenditure']
index 008d925aa211a1ebbb20ec5c6271d9207d6f724c..2be0d56c61b791ce86c2fdfb9a438651aaf03879 100644 (file)
@@ -59,6 +59,9 @@ table.list td.user {
 table.list td.amount {
     width: 90px;
 }
+table.list td.share {
+    width: 90px;
+}
 #totals {
     margin-bottom: 10px;
 }
index 23e32f1469ac123eaa7c0e4c5ab670bd3528b8b3..49476f16bbb8d8cda609071b3a298b24874e91fb 100644 (file)
@@ -76,6 +76,7 @@
       <th class="user">Spender</th>
       <th class="description">Description</th>
       <th class="amount">Amount</th>
+      <th class="share">My Share</th>
       <th class="editlink"></th>
     </tr>
     % for e in es:
@@ -90,6 +91,7 @@
         <td class="user">${formatUser(e.spender)}</td>
         <td class="description">${e.description}</td>
         <td class="amount">${e.amount}</td>
+        <td class="share">${e.share(request.environ['user'])}</td>
         <td class="editlink">${h.link_to('Edit', h.url_for(controller='spend', action='edit', id=e.id))}</td>
       </tr>
     % endfor