X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=bluechips%2Ftemplates%2Fspend%2Findex.mako;h=e3195f2c367d5467a9158f5a61393669625fb03d;hb=acccaf1c26b247e15d6fe5e10658548cc4718295;hp=390199d80c5d37e997524cd6464557192002cc4f;hpb=9c702e4826bdb9e540f8768e8d96c3b874b84eae;p=bluechips.git diff --git a/bluechips/templates/spend/index.mako b/bluechips/templates/spend/index.mako index 390199d..e3195f2 100644 --- a/bluechips/templates/spend/index.mako +++ b/bluechips/templates/spend/index.mako @@ -1,7 +1,63 @@ <%inherit file="/base.mako"/> -<%def name="title()">${parent.title()} :: Add a New Expenditure +<%! + from decimal import Decimal +%> -<%namespace name="forms" module="bluechips.widgets.spend" /> +
+ + + + + + + + + + + + + + + + + +
${h.select('spender_id', c.expenditure.spender_id, c.users)}
$${h.text('amount', "%0.2f" % (int(c.expenditure.amount) / 100.), size=8)}
${h.text('date', c.expenditure.date.strftime('%m/%d/%Y'), size=16, class_='datepicker')}
${h.text('description', c.expenditure.description, size=64)}
-${forms.new_spend_form(action=h.url_for(action='new'))} +

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.

+ + + % for user_id, user in c.users: + <% + try: + percent = c.values['shares-%d.amount' % user_id] + except TypeError: + if c.id != '': + 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 = 0 + else: + if user == request.environ['user']: + percent = 1 + else: + percent = 0 + %> + + + + + % endfor + + + +
+ + + ${h.text('shares-%d.amount' % user_id, percent)} + ${h.hidden('shares-%d.user_id' % user_id, user.id)} +
+ ${h.submit(None, 'Submit', class_="submitbutton")} +
+