X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=bluechips%2Ftemplates%2Fspend%2Findex.mako;h=dc2f606070dd8a4cd8164164092674fd23ab16d7;hb=c419902fc831dc8077c74a8e8a88da081dbe4cf0;hp=dea0a3c7feb446cf895c2672669a15ca13731fc4;hpb=887d9bf9f9f10c92eaa48ad18e96e1e87c5a3cc1;p=bluechips.git diff --git a/bluechips/templates/spend/index.mako b/bluechips/templates/spend/index.mako index dea0a3c..dc2f606 100644 --- a/bluechips/templates/spend/index.mako +++ b/bluechips/templates/spend/index.mako @@ -1,11 +1,58 @@ <%inherit file="/base.mako"/> <%! -import bluechips.widgets.spend as forms + from decimal import Decimal %> -% if c.id != '': -

Want to ${h.link_to('change how this expenditure is divided up', h.url_for(controller='spend', action='split', id=c.id))}?

-% endif +
+ + + + + + + + + + + + + + + + + +
${h.select('spender_id', c.expenditure.spender_id, c.users)}
${h.currency('amount', c.expenditure.amount, 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(c.expenditure, action=h.url_for(action='update'))} +

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 ii, user_row in enumerate(c.users): + <% + user_id, user = user_row + try: + percent = c.values['shares-%d.amount' % ii] + 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 = 0 + %> + + + + + % endfor + + + +
+ + + ${h.text('shares-%d.amount' % ii, percent)} + ${h.hidden('shares-%d.user_id' % ii, user.id)} +
+ ${h.submit(None, 'Submit', class_="submitbutton")} +
+