- c.last_month_total = self._total(sqlalchemy.and_(
- model.expenditures.c.date >= last_month,
- model.expenditures.c.date < this_month))
+ for scope in ('all', 'mine'):
+ meth = getattr(self, '_total_%s' % scope)
+ c.totals[period][scope] = meth(conds)
+
+ c.expenditures = meta.Session.query(model.Expenditure).\
+ filter(sqlalchemy.or_(
+ model.Expenditure.spender == request.environ['user'],
+ model.Expenditure.splits.any(
+ sqlalchemy.and_(
+ model.Split.user == request.environ['user'],
+ model.Split.share != 0)))).\
+ options(orm.eagerload('splits')).\
+ limit(10).all()
+ c.transfers = meta.Session.query(model.Transfer).\
+ filter(sqlalchemy.or_(
+ model.Transfer.debtor==request.environ['user'],
+ model.Transfer.creditor==request.environ['user'])).\
+ limit(10).all()
+ c.users = meta.Session.query(model.User.id, model.User)