mirror of
https://github.com/YunoHost-Apps/ihatemoney_ynh.git
synced 2024-09-03 19:26:15 +02:00
commit
8615fde00a
2 changed files with 4 additions and 2 deletions
|
@ -37,7 +37,7 @@ class Project(db.Model):
|
||||||
# for each person
|
# for each person
|
||||||
for person in self.members:
|
for person in self.members:
|
||||||
# get the list of bills he has to pay
|
# get the list of bills he has to pay
|
||||||
bills = Bill.query.filter(Bill.owers.contains(person))
|
bills = Bill.query.options(orm.subqueryload(Bill.owers)).filter(Bill.owers.contains(person))
|
||||||
for bill in bills.all():
|
for bill in bills.all():
|
||||||
if person != bill.payer:
|
if person != bill.payer:
|
||||||
share = bill.pay_each() * person.weight
|
share = bill.pay_each() * person.weight
|
||||||
|
|
|
@ -15,6 +15,7 @@ from flask.ext.mail import Mail, Message
|
||||||
from flask.ext.babel import get_locale, gettext as _
|
from flask.ext.babel import get_locale, gettext as _
|
||||||
from smtplib import SMTPRecipientsRefused
|
from smtplib import SMTPRecipientsRefused
|
||||||
import werkzeug
|
import werkzeug
|
||||||
|
from sqlalchemy import orm
|
||||||
|
|
||||||
# local modules
|
# local modules
|
||||||
from models import db, Project, Person, Bill
|
from models import db, Project, Person, Bill
|
||||||
|
@ -277,7 +278,8 @@ def list_bills():
|
||||||
# set the last selected payer as default choice if exists
|
# set the last selected payer as default choice if exists
|
||||||
if 'last_selected_payer' in session:
|
if 'last_selected_payer' in session:
|
||||||
bill_form.payer.data = session['last_selected_payer']
|
bill_form.payer.data = session['last_selected_payer']
|
||||||
bills = g.project.get_bills()
|
# Preload the "owers" relationship for all bills
|
||||||
|
bills = g.project.get_bills().options(orm.subqueryload(Bill.owers))
|
||||||
|
|
||||||
return render_template("list_bills.html",
|
return render_template("list_bills.html",
|
||||||
bills=bills, member_form=MemberForm(g.project),
|
bills=bills, member_form=MemberForm(g.project),
|
||||||
|
|
Loading…
Reference in a new issue