Skip to content
This repository has been archived by the owner on Oct 17, 2018. It is now read-only.

Commit

Permalink
Add some pretty questionable logic to include old transaction in email
Browse files Browse the repository at this point in the history
Make it easier to catch accidental screwups
  • Loading branch information
ebroder committed Jul 14, 2013
1 parent 9879f32 commit d0a1867
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
11 changes: 10 additions & 1 deletion bluechips/controllers/spend.py
Expand Up @@ -100,10 +100,18 @@ def update(self, id=None):
e = model.Expenditure()
meta.Session.add(e)
op = 'created'

old_expenditure = None
else:
e = meta.Session.query(model.Expenditure).get(id)
if e is None:
abort(404)

old_expenditure = render('/emails/expenditure.txt',
extra_vars={'expenditure': e,
'op': 'previously',
'old_expenditure': None})

# If a user gets removed from a transaction, they should
# still get an email
involved_users.update(sp.user for sp in e.splits if sp.share != 0)
Expand Down Expand Up @@ -132,7 +140,8 @@ def update(self, id=None):
involved_users.add(e.spender)
body = render('/emails/expenditure.txt',
extra_vars={'expenditure': e,
'op': op})
'op': op,
'old_expenditure': old_expenditure})
g.handle_notification(involved_users, show, body)

return h.redirect_to('/')
Expand Down
4 changes: 4 additions & 0 deletions bluechips/templates/emails/expenditure.txt
Expand Up @@ -10,5 +10,9 @@ The shares of this expenditure are:
${split.user|n,unicode}: ${split.share|n,unicode}
% endfor

% if old_expenditure is not None:
${old_expenditure}
% else
To view or edit this expenditure, visit:
${h.url_for(controller='spend', action='edit', id=expenditure.id, qualified=True)}
% endif

0 comments on commit d0a1867

Please sign in to comment.