Paginate statement lines view
This commit is contained in:
parent
7a5a8ac881
commit
89791a8ba0
@ -25,11 +25,13 @@ from .models import StatementLine, StatementLineReconciliation
|
|||||||
@app.route('/statement-lines')
|
@app.route('/statement-lines')
|
||||||
def statement_lines():
|
def statement_lines():
|
||||||
if 'account' in request.args:
|
if 'account' in request.args:
|
||||||
statement_lines = StatementLine.query.filter_by(source_account=request.args['account']).all()
|
statement_lines = db.select(StatementLine).where(StatementLine.source_account == request.args['account']).order_by(StatementLine.dt)
|
||||||
else:
|
else:
|
||||||
statement_lines = StatementLine.query.all()
|
statement_lines = db.select(StatementLine).order_by(StatementLine.dt)
|
||||||
|
|
||||||
return render_template('statements/statement_lines.html', statement_lines=sorted(statement_lines, key=lambda l: l.dt))
|
page = db.paginate(statement_lines, per_page=request.args.get('per_page', 100))
|
||||||
|
|
||||||
|
return render_template('statements/statement_lines.html', page=page)
|
||||||
|
|
||||||
@app.route('/statement-lines/charge', methods=['POST'])
|
@app.route('/statement-lines/charge', methods=['POST'])
|
||||||
def statement_line_charge():
|
def statement_line_charge():
|
||||||
|
@ -22,10 +22,25 @@
|
|||||||
<h1 class="h2 my-4">Statement lines</h1>
|
<h1 class="h2 my-4">Statement lines</h1>
|
||||||
|
|
||||||
<form method="POST">
|
<form method="POST">
|
||||||
<div class="mb-2">
|
<div class="mb-2 d-flex">
|
||||||
{#<button type="submit" class="btn btn-outline-secondary" formaction="/statement-lines/reconcile-transfer">Reconcile selected as transfer</button>#}
|
{#<button type="submit" class="btn btn-outline-secondary" formaction="/statement-lines/reconcile-transfer">Reconcile selected as transfer</button>#}
|
||||||
|
<div class="flex-grow-1">
|
||||||
<a href="/statement-lines/import" class="btn btn-outline-secondary">Import statement</a>
|
<a href="/statement-lines/import" class="btn btn-outline-secondary">Import statement</a>
|
||||||
</div>
|
</div>
|
||||||
|
<nav class="flex-end">
|
||||||
|
<ul class="pagination">
|
||||||
|
{% if page.prev_num %}<li class="page-item"><a class="page-link" href="?page={{ page.prev_num }}">‹</a></li>{% endif %}
|
||||||
|
{% for pageno in page.iter_pages() %}
|
||||||
|
{% if pageno %}
|
||||||
|
<li class="page-item{% if pageno == page.page %} active{% endif %}"><a class="page-link" href="?page={{ pageno }}">{{ pageno }}</a></li>
|
||||||
|
{% else %}
|
||||||
|
<li class="page-item disabled"><a class="page-link">…</a></li>
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
{% if page.next_num %}<li class="page-item"><a class="page-link" href="?page={{ page.next_num }}">›</a></li>{% endif %}
|
||||||
|
</ul>
|
||||||
|
</nav>
|
||||||
|
</div>
|
||||||
|
|
||||||
<table class="table">
|
<table class="table">
|
||||||
<thead>
|
<thead>
|
||||||
@ -41,7 +56,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{% for line in statement_lines %}
|
{% for line in page.items %}
|
||||||
<tr data-line-id="{{ line.id }}">
|
<tr data-line-id="{{ line.id }}">
|
||||||
<td><input type="checkbox" name="sel-line-id" value="{{ line.id }}"></td>
|
<td><input type="checkbox" name="sel-line-id" value="{{ line.id }}"></td>
|
||||||
<td>{{ line.source_account }}</td>
|
<td>{{ line.source_account }}</td>
|
||||||
|
Loading…
Reference in New Issue
Block a user