diff options
| author | zorun <github@bitsofnetworks.org> | 2020-02-20 09:43:00 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-02-20 09:43:00 +0100 |
| commit | 9378694034d6e9040548b9e65ea65769fb8272b7 (patch) | |
| tree | aace02ca3c9a87acae84bd6f5fed5cfe3faefa42 /ihatemoney/web.py | |
| parent | 72653c0d3ac5ea5265479e7e53ff39cfe62a00ce (diff) | |
| download | ihatemoney-mirror-9378694034d6e9040548b9e65ea65769fb8272b7.zip ihatemoney-mirror-9378694034d6e9040548b9e65ea65769fb8272b7.tar.gz ihatemoney-mirror-9378694034d6e9040548b9e65ea65769fb8272b7.tar.bz2 | |
Paginate the list of bills (#480)
We display 100 bills on each page. We only show previous/next buttons (at
the top of the view) and the list of pages (at the bottom) if there are
more than one pages.
This uses built-in pagination support from Flask-SQLAlchemy:
https://flask-sqlalchemy.palletsprojects.com/en/2.x/api/#flask_sqlalchemy.BaseQuery.paginate
https://flask-sqlalchemy.palletsprojects.com/en/2.x/api/#flask_sqlalchemy.Pagination
Diffstat (limited to 'ihatemoney/web.py')
| -rw-r--r-- | ihatemoney/web.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/ihatemoney/web.py b/ihatemoney/web.py index d45190c..1b80ab6 100644 --- a/ihatemoney/web.py +++ b/ihatemoney/web.py @@ -586,7 +586,11 @@ def list_bills(): if "last_selected_payer" in session: bill_form.payer.data = session["last_selected_payer"] # Preload the "owers" relationship for all bills - bills = g.project.get_bills().options(orm.subqueryload(Bill.owers)) + bills = ( + g.project.get_bills() + .options(orm.subqueryload(Bill.owers)) + .paginate(per_page=100, error_out=True) + ) return render_template( "list_bills.html", |
