+body {
+ font-family: "Lucida Grande", helvetica, arial, sans-serif;
+ font-size: 0.9em;
+ width: 700px;
+}
+strong {
+ font-weight: bold;
+}
+em {
+ font-style: italic;
+}
+a {
+ color: #068600;
+}
+h1.title {
+ font-size: 1.5em;
+ width: 140px;
+}
+a:link {
+ text-decoration: none;
+}
+a:visited {
+ text-decoration: none;
+}
.bluechips {
color: #00a;
}
+#nav {
+ text-align: center;
+}
+#nav td {
+ padding: 5px 20px;
+}
+div.block {
+ margin: 10px 0;
+ padding: 0 10px;
+ border-bottom: 1px solid #bbb;
+}
+table.list {
+ border-collapse: collapse;
+ width: 100%;
+ margin: 10px 0;
+}
+table.list th {
+ text-align: left;
+ padding: 2px 5px;
+ border-bottom: 1px solid #bbb;
+}
+table.list td {
+ padding: 2px 5px;
+ vertical-align: top;
+}
+table.list td.date {
+ width: 90px;
+}
+table.list td.user {
+ width: 110px;
+}
+table.list td.amount {
+ width: 90px;
+}
+#totals {
+ margin-bottom: 10px;
+}
+#totals th {
+ text-align: right;
+}
+td.labelcol {
+ text-align: right;
+ font-weight: bold;
+}
${h.stylesheet_link('/css/main.css')}
</head>
<body>
- <h1>${self.title()}</h1>
<% messages = h.flash.pop_messages() %>
% if messages:
<ul id="flash-messages">
% endfor
</ul>
% endif
- <div id="nav">
- <ul>
- <li>${h.link_to('Dashboard', h.url_for(controller='status',
- action='index',
- id=None))}</li>
- <li>${h.link_to('Expense', h.url_for(controller='spend',
- action='index',
- id=None))}</li>
- <li>${h.link_to('Transfer', h.url_for(controller='transfer',
- action='index',
- id=None))}</li>
- <li>${h.link_to('History', h.url_for(controller='history',
- action='index',
- id=None))}</li>
- </ul>
+ <div id="nav" class="block">
+ <table>
+ <tr>
+ <td>
+ <h1 class="title">
+ % if c.title:
+ ${c.title}
+ % else:
+ BlueChips
+ % endif
+ </h1>
+ </td>
+ <td>
+ <a href="${h.url_for(controller='status', action='index', id=None)}">
+ <img src="/icons/dashboard.png" alt="">
+ <span>Dashboard</span>
+ </a>
+ </td>
+ <td>
+ <a href="${h.url_for(controller='spend', action='index', id=None)}">
+ <img src="/icons/spend.png" alt="">
+ <span>Expense</span>
+ </a>
+ </td>
+ <td>
+ <a href="${h.url_for(controller='transfer', action='index', id=None)}">
+ <img src="/icons/transfer.png" alt="">
+ <span>Transfer</span>
+ </a>
+ </td>
+ <td>
+ <a href="${h.url_for(controller='history', action='index', id=None)}">
+ <img src="/icons/history.png" alt="">
+ <span>History</span>
+ </a>
+ </td>
+ </tr>
+ </table>
</div>
<div id="content">
${next.body()}
% endif
</%def>
+<%def name="formatUser(user)">
+ % if user.username == request.environ['REMOTE_USER']:
+ <strong>${user.name}</strong>
+ % else:
+ ${user.name}
+ % endif
+</%def>
+
<%def name="listExpenditures(es)">
-<table>
+ <table class="list">
<tr>
- <th>Date</th>
- <th>Spender</th>
- <th>Description</th>
- <th>Amount</th>
- <th></th>
+ <th class="date">Date</th>
+ <th class="user">Spender</th>
+ <th class="description">Description</th>
+ <th class="amount">Amount</th>
+ <th class="editlink"></th>
</tr>
% for e in es:
- <tr>
- <td>${e.date}</td>
- <td>${e.spender.name}</td>
- <td>${e.description}</td>
- <td>${e.amount}</td>
- <td>${h.link_to('Edit', h.url_for(controller='spend',
- action='edit',
- id=e.id))}</td>
- </tr>
+ <tr>
+ <td class="date">${e.date}</td>
+ <td class="user">${formatUser(e.spender)}</td>
+ <td class="description">${e.description}</td>
+ <td class="amount">${e.amount}</td>
+ <td class="editlink">${h.link_to('Edit', h.url_for(controller='spend', action='edit', id=e.id))}</td>
+ </tr>
% endfor
-</table>
+ </table>
</%def>
<%def name="listTransfers(ts)">
-<table>
+ <table class="list">
<tr>
- <th>Date</th>
- <th>From</th>
- <th>To</th>
- <th>Description</th>
- <th>Amount</th>
- <th></th>
+ <th class="date">Date</th>
+ <th class="user">From</th>
+ <th class="user">To</th>
+ <th class="description">Description</th>
+ <th class="amount">Amount</th>
+ <th class="editlink"></th>
</tr>
% for t in ts:
- <tr>
- <td>${t.date}</td>
- <td>${t.debtor.name}</td>
- <td>${t.creditor.name}</td>
- <td>${t.description}</td>
- <td>${t.amount}</td>
- <td>${h.link_to('Edit', h.url_for(controller='transfer',
- action='edit',
- id=t.id))}</td>
- </tr>
+ <tr>
+ <td class="date">${t.date}</td>
+ <td class="user">${formatUser(t.debtor)}</td>
+ <td class="user">${formatUser(t.creditor)}</td>
+ <td class="description">${t.description}</td>
+ <td class="amount">${t.amount}</td>
+ <td class="editlink">${h.link_to('Edit', h.url_for(controller='transfer', action='edit', id=t.id))}</td>
+ </tr>
% endfor
-</table>
+ </table>
+</%def>
+
+<%def name="expenditureIcon()">
+←<span class="dollarsign">→
+</%def>
+
+<%def name="transferIcon()">
+<span class="dollarsign">$</span>→<span class="dollarsign">$</span>
</%def>
${h.form('', method='post')}
<form>
- <ul class="field_list">
+ <table>
% for user in c.users:
- <%
- name = user.username
- try:
- percent = c.values[name]
- except TypeError:
+ <%
+ name = user.username
try:
- share = [s.share for s in c.expenditure.splits if s.user == user][0]
- percent = (Decimal(100) * Decimal(int(share)) / Decimal(int(c.expenditure.amount))).quantize(Decimal("0.001"))
- except IndexError:
- percent = Decimal(0)
- %>\
- <li class="${form_cycle.next()}" id="${name}.container">
- <label id="${name}.label" for="${name}" class="fieldlabel">${user.name}</label>
- ${h.text(name, value=percent, class_="textfield required", id=name)}
- % if name in c.errors:
- <span class="fielderror">${c.errors[name]}</span>
- % endif
- </li>
+ percent = c.values[name]
+ except TypeError:
+ try:
+ share = [s.share for s in c.expenditure.splits if s.user == user][0]
+ percent = (Decimal(100) * Decimal(int(share)) / Decimal(int(c.expenditure.amount))).quantize(Decimal("0.001"))
+ except IndexError:
+ percent = Decimal(0)
+ %>\
+ <tr class="${form_cycle.next()}" id="${name}.container">
+ <td class="labelcol">
+ <label id="${name}.label" for="${name}" class="fieldlabel">${user.name}</label>
+ </td>
+ <td class="fieldcol">
+ ${h.text(name, value=percent, class_="textfield required", id=name)}
+ % if name in c.errors:
+ <span class="fielderror">${c.errors[name]}</span>
+ % endif
+ </td>
+ </tr>
% endfor
- <li class="${form_cycle.next()}" id="submit.container">
- ${h.submit(None, 'Submit', class_="submitbutton")}
- </li>
+ <tr class="${form_cycle.next()}" id="submit.container">
+ <td class="labelcol"></td>
+ <td class="fieldcol">
+ ${h.submit(None, 'Submit', class_="submitbutton")}
+ </td>
+ </tr>
</ul>
</form>
<%inherit file="/base.mako"/>
-<h2>Settling Transfers</h2>
+<div class="block">
+ <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>
+ % 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>
+ <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>${transfer[2]}</td>
- </tr>
- % endfor
-</table>
-% endif
+ </tr>
+ % for transfer in c.settle:
+ <tr>
+ <td>${transfer[0].username}</td>
+ <td>${transfer[1].username}</td>
+ <td>${transfer[2]}</td>
+ </tr>
+ % endfor
+ </table>
+ % endif
+</div>
-<h2>Totals</h2>
+<div class="block">
+ <h2>Totals</h2>
-<table>
+ <table id="totals">
<tr>
- <td>Total</td>
- <td>${c.total}</td>
+ <th>Total</th>
+ <td>${c.total}</td>
</tr>
<tr>
- <td>Past year</td>
- <td>${c.year_total}</td>
+ <th>Past year</th>
+ <td>${c.year_total}</td>
</tr>
<tr>
- <td>Year to date</td>
- <td>${c.this_year_total}</td>
+ <th>Year to date</th>
+ <td>${c.this_year_total}</td>
</tr>
<tr>
- <td>Month to date</td>
- <td>${c.this_month_total}</td>
+ <th>Month to date</th>
+ <td>${c.this_month_total}</td>
</tr>
<tr>
- <td>Last month</td>
- <td>${c.last_month_total}</td>
+ <th>Last month</th>
+ <td>${c.last_month_total}</td>
</tr>
-</table>
+ </table>
+</div>
-<h2>Add a new transaction</h2>
+<div class="block">
+ <h2>Add a new transaction</h2>
-<ul>
+ <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>
+ </ul>
+</div>
-<h2>Your History</h2>
+<div class="block">
+ <h2>Your History</h2>
-${h.link_to('See all history', h.url_for(controller='history',
- action='index'))}
+ ${h.link_to('See all history', h.url_for(controller='history', action='index'))}
-<h3>Expenditures</h3>
+ <h3>Expenditures</h3>
-${self.listExpenditures(c.expenditures)}
+ ${self.listExpenditures(c.expenditures)}
-<h3>Transfers</h3>
+ <h3>Transfers</h3>
-${self.listTransfers(c.transfers)}
+ ${self.listTransfers(c.transfers)}
+</div>
from bluechips.widgets import *
-class NewSpendForm(forms.ListForm):
+class NewSpendForm(forms.TableForm):
class fields(WidgetsList):
spender = UserSelect()
amount = AmountField()
from bluechips.widgets import *
-class NewTransferForm(forms.ListForm):
+class NewTransferForm(forms.TableForm):
class fields(WidgetsList):
debtor = UserSelect()
creditor = UserSelect()