Hide next links to future.
This commit is contained in:
parent
920fb81377
commit
a15aa9eade
@ -207,9 +207,10 @@ def qute_history(url):
|
|||||||
html = jinja.render('history.html',
|
html = jinja.render('history.html',
|
||||||
title='History',
|
title='History',
|
||||||
history=history,
|
history=history,
|
||||||
curr_date=curr_date.strftime("%a, %d %B %Y"),
|
curr_date=curr_date,
|
||||||
next_date=next_date.strftime("%Y-%m-%d"),
|
next_date=next_date,
|
||||||
prev_date=prev_date.strftime("%Y-%m-%d"))
|
prev_date=prev_date,
|
||||||
|
today=datetime.date.today())
|
||||||
return 'text/html', html
|
return 'text/html', html
|
||||||
|
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ tr:nth-child(odd) {
|
|||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
<h1>Browsing history <span class="date">{{curr_date}}</span></h1>
|
<h1>Browsing history <span class="date">{{curr_date.strftime("%a, %d %B %Y")}}</span></h1>
|
||||||
|
|
||||||
<table>
|
<table>
|
||||||
<tbody>
|
<tbody>
|
||||||
@ -83,7 +83,9 @@ tr:nth-child(odd) {
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<span class="pagination-link"><a href="qute://history/?date={{prev_date}}">Previous</a></span>
|
<span class="pagination-link"><a href="qute://history/?date={{prev_date.strftime("%Y-%m-%d")}}">Previous</a></span>
|
||||||
<span class="pagination-link"><a href="qute://history/?date={{next_date}}">Next</a></span>
|
{% if today >= next_date %}
|
||||||
|
<span class="pagination-link"><a href="qute://history/?date={{next_date.strftime("%Y-%m-%d")}}">Next</a></span>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@ -99,3 +99,13 @@ class TestHistoryHandler:
|
|||||||
assert "today" not in data
|
assert "today" not in data
|
||||||
assert "tomorrow" in data
|
assert "tomorrow" in data
|
||||||
assert "yesterday" not in data
|
assert "yesterday" not in data
|
||||||
|
|
||||||
|
def test_no_next_link_to_future(self):
|
||||||
|
"""Ensure there's no next link pointing to the future."""
|
||||||
|
url = QUrl("qute://history")
|
||||||
|
_mimetype, data = qutescheme.qute_history(url)
|
||||||
|
assert "Next" not in data
|
||||||
|
|
||||||
|
url = QUrl("qute://history?date=" + self.next_date.strftime("%Y-%m-%d"))
|
||||||
|
_mimetype, data = qutescheme.qute_history(url)
|
||||||
|
assert "Next" not in data
|
||||||
|
Loading…
Reference in New Issue
Block a user