[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [taler-bank] 05/05: fixing the back-and-forth arrows to nav
From: |
gnunet |
Subject: |
[GNUnet-SVN] [taler-bank] 05/05: fixing the back-and-forth arrows to navigate multiple pages /public-history results. |
Date: |
Mon, 15 Jan 2018 17:08:05 +0100 |
This is an automated email from the git hooks/post-receive script.
marcello pushed a commit to branch master
in repository bank.
commit beb62795be1b397887cd9e69f84211e7f0509201
Author: Marcello Stanisci <address@hidden>
AuthorDate: Mon Jan 15 17:03:44 2018 +0100
fixing the back-and-forth arrows to navigate multiple
pages /public-history results.
---
talerbank/app/static/bank.css | 12 +++++
talerbank/app/templates/public_accounts.html | 78 +++++++++++++++++-----------
talerbank/app/views.py | 8 ++-
3 files changed, 67 insertions(+), 31 deletions(-)
diff --git a/talerbank/app/static/bank.css b/talerbank/app/static/bank.css
index 20e7586..4c16e94 100644
--- a/talerbank/app/static/bank.css
+++ b/talerbank/app/static/bank.css
@@ -3,6 +3,18 @@ h1.nav {
display: inline-block;
}
+div.pages-list {
+ margin-top: 15px;
+}
+
+a.page-number {
+ color: blue;
+}
+
+a.current-page-number {
+ color: inherit;
+}
+
a.pure-button {
position: absolute;
right: 20px;
diff --git a/talerbank/app/templates/public_accounts.html
b/talerbank/app/templates/public_accounts.html
index edbfdbc..3ebe6ad 100644
--- a/talerbank/app/templates/public_accounts.html
+++ b/talerbank/app/templates/public_accounts.html
@@ -55,35 +55,55 @@
</ul>
</div>
- {% if selected_account.history %}
- <table class="pure-table pure-table-striped">
- <thead>
- <th>Date</th>
- <th>Amount</th>
- <th>Counterpart</th>
- <th>Subject</th>
- </thead>
- <tbody>
- {% for entry in selected_account.history %}
- <tr>
- <td>{{entry.date}}</td>
- <td>
- {{ entry.sign }} {{ entry.amount }}
- </td>
- <td>{% if entry.counterpart_username %} {{
entry.counterpart_username }} {% endif %} (account #{{ entry.counterpart
}})</td>
- <td {% if entry.cancelled %} class="cancelled" {% endif %}>
- {{ entry.subject }}
- </td>
- </tr>
- {% endfor %}
- </tbody>
- </table>
- {% for pagej in pages %}
- <a href="{{ url("public-accounts", name=selected_account.name,
page=pagej) }}">{{ pagej }}</a>
- {% endfor %}
- {% else %}
- <p>No history for account #{{ selected_account.number }} ({{
selected_account.name}}) yet</p>
- {% endif %}
+ <div class="results">
+ {% if selected_account.history %}
+ <table class="pure-table pure-table-striped">
+ <thead>
+ <th>Date</th>
+ <th>Amount</th>
+ <th>Counterpart</th>
+ <th>Subject</th>
+ </thead>
+ <tbody>
+ {% for entry in selected_account.history %}
+ <tr>
+ <td>{{entry.date}}</td>
+ <td>
+ {{ entry.sign }} {{ entry.amount }}
+ </td>
+ <td>{% if entry.counterpart_username %} {{
entry.counterpart_username }} {% endif %} (account #{{ entry.counterpart
}})</td>
+ <td {% if entry.cancelled %} class="cancelled" {% endif %}>
+ {{ entry.subject }}
+ </td>
+ </tr>
+ {% endfor %}
+ </tbody>
+ </table>
+ <div class="pages-list">
+ {% if back %}
+ <a
+ class="page-number"
+ href="{{ url("public-accounts", name=selected_account.name,
page=back) }}">‹...</a>
+ {% endif %}
+ {% for pagej in pages %}
+ <a
+ {% if pagej == current_page%}
+ class="current-page-number"
+ {% else %}
+ class="page-number"
+ {% endif %}
+ href="{{ url("public-accounts", name=selected_account.name,
page=pagej) }}">{{ pagej }}</a>
+ {% endfor %}
+ {% if forth %}
+ <a
+ class="page-number"
+ href="{{ url("public-accounts", name=selected_account.name,
page=forth) }}">...›</a>
+ {% endif %}
+ </div>
+ {% else %}
+ <p>No history for account #{{ selected_account.number }} ({{
selected_account.name}}) yet</p>
+ {% endif %}
+ </div>
</article>
</section>
{% endblock content %}
diff --git a/talerbank/app/views.py b/talerbank/app/views.py
index 81eeb6d..fa6efa4 100644
--- a/talerbank/app/views.py
+++ b/talerbank/app/views.py
@@ -18,6 +18,7 @@
# @author Florian Dold
from functools import wraps
+import math
import json
import logging
import hashlib
@@ -385,9 +386,12 @@ def serve_public_accounts(request, name=None, page=None):
num_pages = request.session["public_history_account"][0] / DELTA
pages = list(
- range(max(1, page - 3), min(page + 4, int(num_pages))))
- print(pages)
+ range(max(1, page - 3),
+ min(page + 4, math.ceil(num_pages))))
context = dict(
+ current_page=page,
+ back = page - 1 if pages[0] > 1 else None,
+ forth = page + 1 if pages[-1] < num_pages else None,
public_accounts=public_accounts,
selected_account=dict(
fail_message=fail_message,
--
To stop receiving notification emails like this one, please contact
address@hidden
- [GNUnet-SVN] [taler-bank] branch master updated (acdef0d -> beb6279), gnunet, 2018/01/15
- [GNUnet-SVN] [taler-bank] 01/05: history extracting logic goes in one point, and /history calls it now., gnunet, 2018/01/15
- [GNUnet-SVN] [taler-bank] 04/05: implement page numbers, gnunet, 2018/01/15
- [GNUnet-SVN] [taler-bank] 05/05: fixing the back-and-forth arrows to navigate multiple pages /public-history results.,
gnunet <=
- [GNUnet-SVN] [taler-bank] 02/05: set the state to implement the "see next page" feature useful when an account's history is too long., gnunet, 2018/01/15
- [GNUnet-SVN] [taler-bank] 03/05: make /<page_number> available, gnunet, 2018/01/15