Skip to content

Commit

Permalink
Persist sort order for future searches, closes #23
Browse files Browse the repository at this point in the history
  • Loading branch information
simonw committed Sep 18, 2020
1 parent 847378d commit e191694
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions dogsheep_beta/templates/beta.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ <h1>Dogsheep Beta{% if q %}: {{ q }}{% endif %}</h1>

<form action="/-/beta" method="get"><div>
<input type="search" name="q" value="{{ q }}" id="q">
{% if sorted_by != "relevance" %}
<input type="hidden" name="sort" value="{{ sorted_by }}">
{% endif %}
<input type="submit" value="Search">
{% for hidden in hiddens %}
<input type="hidden" name="{{ hidden.name }}" value="{{ hidden.value }}">
Expand Down
5 changes: 5 additions & 0 deletions tests/test_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,11 @@ async def test_search_order(ds, sort, expected):
# Check that sort links exist and are correct
sort_label = sort or "relevance"
assert "<strong>{}</strong>".format(sort_label) in response.text
if sort_label != "relevance":
assert (
'<input type="hidden" name="sort" value="{}">'.format(sort_label)
in response.text
)
for sort_order in ("relevance", "newest", "oldest"):
if sort_order != sort_label:
assert ">{}</a>".format(sort_order) in response.text
Expand Down

0 comments on commit e191694

Please sign in to comment.