mirror of
https://github.com/spiral-project/ihatemoney.git
synced 2025-05-05 12:41:49 +02:00
add comments
This commit is contained in:
parent
65aa4b0fea
commit
c04b24c051
2 changed files with 11 additions and 2 deletions
|
@ -256,6 +256,12 @@ class Project(db.Model):
|
|||
)
|
||||
|
||||
def get_bill_weights(self):
|
||||
"""
|
||||
Return all bills for this project, along with the sum of weight for each bill.
|
||||
Each line is a (float, Bill) tuple.
|
||||
|
||||
Result is unordered.
|
||||
"""
|
||||
return (
|
||||
db.session.query(func.sum(Person.weight), Bill)
|
||||
.options(orm.subqueryload(Bill.owers))
|
||||
|
@ -267,6 +273,7 @@ class Project(db.Model):
|
|||
)
|
||||
|
||||
def get_bill_weights_ordered(self):
|
||||
"""Ordered version of get_bill_weights"""
|
||||
return self.ordered_bills(self.get_bill_weights())
|
||||
|
||||
def get_member_bills(self, member_id):
|
||||
|
|
|
@ -653,11 +653,13 @@ def list_bills():
|
|||
# set the last selected payer as default choice if exists
|
||||
if "last_selected_payer" in session:
|
||||
bill_form.payer.data = session["last_selected_payer"]
|
||||
bills = g.project.get_bill_weights_ordered().paginate(per_page=100, error_out=True)
|
||||
|
||||
# Each item will be (weight_sum, Bill) tuple
|
||||
weights_bills = g.project.get_bill_weights_ordered().paginate(per_page=100, error_out=True)
|
||||
|
||||
return render_template(
|
||||
"list_bills.html",
|
||||
bills=bills,
|
||||
bills=weights_bills,
|
||||
member_form=MemberForm(g.project),
|
||||
bill_form=bill_form,
|
||||
csrf_form=csrf_form,
|
||||
|
|
Loading…
Reference in a new issue