Skip to content

Commit

Permalink
Fixed bug with table title element, closes #1560
Browse files Browse the repository at this point in the history
  • Loading branch information
simonw committed Jan 13, 2022
1 parent 5698e2a commit 3658e57
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
3 changes: 1 addition & 2 deletions datasette/templates/table.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{% extends "base.html" %}

{% block title %}{{ database }}: {{ table }}: {% if filtered_table_rows_count or filtered_table_rows_count == 0 %}{{ "{:,}".format(filtered_table_rows_count) }} row{% if filtered_table_rows_count == 1 %}{% else %}s{% endif %}{% endif %}
{% if human_description_en %}where {{ human_description_en }}{% endif %}{% endblock %}
{% block title %}{{ database }}: {{ table }}: {% if filtered_table_rows_count or filtered_table_rows_count == 0 %}{{ "{:,}".format(filtered_table_rows_count) }} row{% if filtered_table_rows_count == 1 %}{% else %}s{% endif %}{% endif %}{% if human_description_en %} {{ human_description_en }}{% endif %}{% endblock %}

{% block extra_head %}
{{ super() }}
Expand Down
19 changes: 19 additions & 0 deletions tests/test_table_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -1038,3 +1038,22 @@ def test_sort_rowid_with_next(app_client):

def assert_querystring_equal(expected, actual):
assert sorted(expected.split("&")) == sorted(actual.split("&"))


@pytest.mark.parametrize(
"path,expected",
(
(
"/fixtures/facetable",
"fixtures: facetable: 15 rows",
),
(
"/fixtures/facetable?on_earth__exact=1",
"fixtures: facetable: 14 rows where on_earth = 1",
),
),
)
def test_table_page_title(app_client, path, expected):
response = app_client.get(path)
title = Soup(response.text, "html.parser").find("title").text
assert title == expected

0 comments on commit 3658e57

Please sign in to comment.