Skip to content

Commit

Permalink
WIP: paginate the list of bills
Browse files Browse the repository at this point in the history
  • Loading branch information
Baptiste Jonglez committed Oct 1, 2019
1 parent 54ce277 commit 4ba099f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
19 changes: 17 additions & 2 deletions ihatemoney/templates/list_bills.html
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,13 @@ <h3 class="modal-title">{{ _('Add a bill') }}</h3>
</div>
</div>

{% if bills.count() > 0 %}
{% if bills.total > 0 %}
<div class="clearfix"></div>

<table id="bill_table" class="col table table-striped table-hover table-responsive-sm">
<thead><tr><th>{{ _("When?") }}</th><th>{{ _("Who paid?") }}</<th><th>{{ _("For what?") }}</th><th>{{ _("For whom?") }}</th><th>{{ _("How much?") }}</th><th>{{ _("Actions") }}</th></tr></thead>
<tbody>
{% for bill in bills %}
{% for bill in bills.items %}
<tr owers="{{bill.owers|join(',','id')}}" payer="{{bill.payer.id}}">
<td>
<span data-toggle="tooltip" data-placement="top"
Expand All @@ -140,6 +140,21 @@ <h3 class="modal-title">{{ _('Add a bill') }}</h3>
</tbody>
</table>

<div class=pagination>
{%- for page in bills.iter_pages() %}
&nbsp;
{% if page %}
{% if page != bills.page %}
<a href="{{ url_for('main.list_bills', page=page) }}">{{ page }}</a>
{% else %}
<strong>{{ page }}</strong>
{% endif %}
{% else %}
<span class=ellipsis></span>
{% endif %}
{%- endfor %}
</div>

{% else %}
<div class="py-3 d-flex justify-content-center empty-bill">
<div class="card d-inline-flex p-2">
Expand Down
2 changes: 1 addition & 1 deletion ihatemoney/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ 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=2, error_out=False)

return render_template("list_bills.html",
bills=bills, member_form=MemberForm(g.project),
Expand Down

0 comments on commit 4ba099f

Please sign in to comment.