]> asedeno.scripts.mit.edu Git - bluechips.git/commitdiff
cleaned up some issues with validation errors being displayed improperly
authorScott Torborg <scott@crookedmedia.com>
Wed, 4 Nov 2009 02:52:08 +0000 (16:52 -1000)
committerScott Torborg <scott@crookedmedia.com>
Wed, 4 Nov 2009 02:52:08 +0000 (16:52 -1000)
bluechips/lib/helpers.py
bluechips/public/css/main.css
bluechips/public/icons/currency-small.png [new file with mode: 0644]
bluechips/templates/spend/index.mako
bluechips/templates/transfer/index.mako

index 1b8771bc790972d150b4db5b874a6d8a53604e8f..40c2251a60441f265e348ebfa1be6e54e211b35c 100644 (file)
@@ -14,4 +14,11 @@ from decimal import Decimal
 def bluechips():
     return '<span class="bluechips">BlueChips</span>'
 
+def currency(name, value, *args, **kwargs):
+    if 'class_' not in kwargs:
+        kwargs['class_'] = ''
+    kwargs['class_'] += 'currency'
+    value = "%0.2f" % (int(value) / 100.)
+    return text(name, value, *args, **kwargs)
+
 flash = _Flash()
index a63eb329546bc7c10fe551ec4ca166ac74232f04..35d5c1a4ac3347f8cd2c01a509fa7796e3ac104f 100644 (file)
@@ -94,3 +94,13 @@ div.flash {
 div.flash ul {
     margin-bottom: 0;
 }
+span.error-message {
+    font-weight: bold;
+    color: #f00;
+}
+input.currency {
+    padding-left: 10px;
+    background-image: url(/icons/currency-small.png);
+    background-repeat: no-repeat;
+    background-position: center left;
+}
diff --git a/bluechips/public/icons/currency-small.png b/bluechips/public/icons/currency-small.png
new file mode 100644 (file)
index 0000000..81ae0a6
Binary files /dev/null and b/bluechips/public/icons/currency-small.png differ
index e3195f2c367d5467a9158f5a61393669625fb03d..6198b0fe7531f973db62b8d5246dd95a13123834 100644 (file)
@@ -12,7 +12,7 @@
     </tr>
     <tr>
       <th><label for="amount">Amount</label></th>
-      <td>$${h.text('amount', "%0.2f" % (int(c.expenditure.amount) / 100.), size=8)}</td>
+      <td>${h.currency('amount', c.expenditure.amount, size=8)}</td>
     </tr>
     <tr>
       <th><label for="date">Date</label></th>
   <p>Change how an expenditure is split up. Enter a percentage, or something like a percentage, for each user. They don't have to add to 100.</p>
 
   <table class="form">
-    % for user_id, user in c.users:
+    % for ii, user_row in enumerate(c.users):
       <%
+        user_id, user = user_row
         try:
-            percent = c.values['shares-%d.amount' % user_id]
+            percent = c.values['shares-%d.amount' % ii]
         except TypeError:
             if c.id != '':
                 try:
       %>
       <tr>
         <th>
-          <label for="shares-${user_id}amount">${user.name}</label>
+          <label for="shares-${ii}amount">${user.name}</label>
         </th>
         <td>
-          ${h.text('shares-%d.amount' % user_id, percent)}
-          ${h.hidden('shares-%d.user_id' % user_id, user.id)}
+          ${h.text('shares-%d.amount' % ii, percent)}
+          ${h.hidden('shares-%d.user_id' % ii, user.id)}
         </td>
       </tr>
     % endfor
index 144cf91090120dbe4fba9d319862c6cf12ae6f4d..736c339c34a81fb6e4dc2ba272315842d2e3fb37 100644 (file)
@@ -12,7 +12,7 @@
     </tr>
     <tr>
       <th><label for="amount">Amount</label></th>
-      <td>$${h.text('amount', "%0.2f" % (int(c.transfer.amount) / 100.0), size=8)}</td>
+      <td>${h.currency('amount', c.transfer.amount, size=8)}</td>
     </tr>
     <tr>
       <th><label for="date">Date</label></th>