1 <%inherit file="/base.mako"/>
5 from decimal import Decimal
9 form_cycle = itertools.cycle(['even', 'odd'])
12 ## ToscaWidgets doesn't support dynamically generating the form fields
13 ## themselves, so I'm mimicing its style but generating the form by
16 <p>Change how an expenditure is split up. Enter a percentage, or
17 something like a percentage, for each user. They don't have to add to
20 <p>You're editing an expenditure of ${c.expenditure.amount} by
21 ${c.expenditure.spender.name} on ${c.expenditure.date}, described as
22 "${c.expenditure.description}"</p>
24 ${h.form('', method='post')}
27 % for user in c.users:
31 percent = c.values[name]
34 share = [s.share for s in c.expenditure.splits if s.user == user][0]
35 percent = (Decimal(100) * Decimal(int(share)) / Decimal(int(c.expenditure.amount))).quantize(Decimal("0.001"))
39 <tr class="${form_cycle.next()}" id="${name}.container">
41 <label id="${name}.label" for="${name}" class="fieldlabel">${user.name}</label>
44 ${h.text(name, value=percent, class_="textfield required", id=name)}
45 % if name in c.errors:
46 <span class="fielderror">${c.errors[name]}</span>
51 <tr class="${form_cycle.next()}" id="submit.container">
52 <td class="labelcol"></td>
54 ${h.submit(None, 'Submit', class_="submitbutton")}