]> asedeno.scripts.mit.edu Git - bluechips.git/blob - bluechips/templates/base.mako
emphasize transactions that the logged-in user is part of, deemphasize others
[bluechips.git] / bluechips / templates / base.mako
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2           "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4   <head>
5     <meta http-equiv="content-type" content="text/html; charset=utf-8" />
6     <title>${self.title()}</title>
7     ${h.stylesheet_link('/css/main.css')}
8   </head>
9   <body>
10     <% messages = h.flash.pop_messages() %>
11     % if messages:
12     <ul id="flash-messages">
13     % for message in messages:
14         <li>${message}</li>
15     % endfor
16     </ul>
17     % endif
18     <div id="nav" class="block">
19       <table>
20         <tr>
21           <td>
22             <h1 class="title">
23               % if c.title:
24                 ${c.title}
25               % else:
26                 BlueChips
27               % endif
28             </h1>
29           </td>
30           <td>
31             <a href="${h.url_for(controller='status', action='index', id=None)}">
32               <img src="/icons/dashboard.png" alt="">
33               <span>Dashboard</span>
34             </a>
35           </td>
36           <td>
37             <a href="${h.url_for(controller='spend', action='index', id=None)}">
38               <img src="/icons/spend.png" alt="">
39               <span>Expense</span>
40             </a>
41           </td>
42           <td>
43             <a href="${h.url_for(controller='transfer', action='index', id=None)}">
44               <img src="/icons/transfer.png" alt="">
45               <span>Transfer</span>
46             </a>
47           </td>
48           <td>
49             <a href="${h.url_for(controller='history', action='index', id=None)}">
50               <img src="/icons/history.png" alt="">
51               <span>History</span>
52             </a>
53           </td>
54         </tr>
55       </table>
56     </div>
57     <div id="content">
58       ${next.body()}
59     </div>
60   </body>
61 </html>
62
63 <%def name="title()">BlueChips
64 % if c.title != '':
65   :: ${c.title}
66 % endif
67 </%def>
68
69 <%def name="formatUser(user)">
70   % if user == c.user:
71     <strong>Me</strong>
72   % else:
73     ${user.name}
74   % endif
75 </%def>
76
77 <%def name="listExpenditures(es)">
78   <table class="list">
79     <tr>
80       <th class="date">Date</th>
81       <th class="user">Spender</th>
82       <th class="description">Description</th>
83       <th class="amount">Amount</th>
84       <th class="editlink"></th>
85     </tr>
86     % for e in es:
87       <%
88         if e.involves(c.user):
89           klass = 'user-involved'
90         else:
91           klass = 'user-not-involved'
92       %>
93       <tr class="${klass}">
94         <td class="date">${e.date}</td>
95         <td class="user">${formatUser(e.spender)}</td>
96         <td class="description">${e.description}</td>
97         <td class="amount">${e.amount}</td>
98         <td class="editlink">${h.link_to('Edit', h.url_for(controller='spend', action='edit', id=e.id))}</td>
99       </tr>
100     % endfor
101   </table>
102 </%def>
103
104 <%def name="listTransfers(ts)">
105   <table class="list">
106     <tr>
107       <th class="date">Date</th>
108       <th class="user">From</th>
109       <th class="user">To</th>
110       <th class="description">Description</th>
111       <th class="amount">Amount</th>
112       <th class="editlink"></th>
113     </tr>
114     % for t in ts:
115       <%
116         if t.involves(c.user):
117           klass = 'user-involved'
118         else:
119           klass = 'user-not-involved'
120       %>
121       <tr class="${klass}">
122         <td class="date">${t.date}</td>
123         <td class="user">${formatUser(t.debtor)}</td>
124         <td class="user">${formatUser(t.creditor)}</td>
125         <td class="description">${t.description}</td>
126         <td class="amount">${t.amount}</td>
127         <td class="editlink">${h.link_to('Edit', h.url_for(controller='transfer', action='edit', id=t.id))}</td>
128       </tr>
129     % endfor
130   </table>
131 </%def>
132
133 <%def name="expenditureIcon()">
134 &larr;<span class="dollarsign">&rarr;
135 </%def>
136
137 <%def name="transferIcon()">
138 <span class="dollarsign">$</span>&rarr;<span class="dollarsign">$</span>
139 </%def>