Hide next links to future.

This commit is contained in:
Imran Sobir 2017-02-09 17:18:57 +05:00
parent 920fb81377
commit a15aa9eade
3 changed files with 19 additions and 6 deletions

View File

@ -207,9 +207,10 @@ def qute_history(url):
html = jinja.render('history.html',
title='History',
history=history,
curr_date=curr_date.strftime("%a, %d %B %Y"),
next_date=next_date.strftime("%Y-%m-%d"),
prev_date=prev_date.strftime("%Y-%m-%d"))
curr_date=curr_date,
next_date=next_date,
prev_date=prev_date,
today=datetime.date.today())
return 'text/html', html

View File

@ -70,7 +70,7 @@ tr:nth-child(odd) {
{% 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>
<tbody>
@ -83,7 +83,9 @@ tr:nth-child(odd) {
</tbody>
</table>
<span class="pagination-link"><a href="qute://history/?date={{prev_date}}">Previous</a></span>
<span class="pagination-link"><a href="qute://history/?date={{next_date}}">Next</a></span>
<span class="pagination-link"><a href="qute://history/?date={{prev_date.strftime("%Y-%m-%d")}}">Previous</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 %}

View File

@ -99,3 +99,13 @@ class TestHistoryHandler:
assert "today" not in data
assert "tomorrow" 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