kopia lustrzana https://github.com/simonw/datasette
Move queries to top of database page, refs #1612
rodzic
d194db4204
commit
68cc1e2dbb
|
@ -67,10 +67,23 @@
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
{% if queries %}
|
||||||
|
<h2 id="queries">Queries</h2>
|
||||||
|
<ul class="bullets">
|
||||||
|
{% for query in queries %}
|
||||||
|
<li><a href="{{ urls.query(database, query.name) }}{% if query.fragment %}#{{ query.fragment }}{% endif %}" title="{{ query.description or query.sql }}">{{ query.title or query.name }}</a>{% if query.private %} 🔒{% endif %}</li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if tables %}
|
||||||
|
<h2 id="tables">Tables</h2>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% for table in tables %}
|
{% for table in tables %}
|
||||||
{% if show_hidden or not table.hidden %}
|
{% if show_hidden or not table.hidden %}
|
||||||
<div class="db-table">
|
<div class="db-table">
|
||||||
<h2><a href="{{ urls.table(database, table.name) }}">{{ table.name }}</a>{% if table.private %} 🔒{% endif %}{% if table.hidden %}<em> (hidden)</em>{% endif %}</h2>
|
<h3><a href="{{ urls.table(database, table.name) }}">{{ table.name }}</a>{% if table.private %} 🔒{% endif %}{% if table.hidden %}<em> (hidden)</em>{% endif %}</h3>
|
||||||
<p><em>{% for column in table.columns %}{{ column }}{% if not loop.last %}, {% endif %}{% endfor %}</em></p>
|
<p><em>{% for column in table.columns %}{{ column }}{% if not loop.last %}, {% endif %}{% endfor %}</em></p>
|
||||||
<p>{% if table.count is none %}Many rows{% else %}{{ "{:,}".format(table.count) }} row{% if table.count == 1 %}{% else %}s{% endif %}{% endif %}</p>
|
<p>{% if table.count is none %}Many rows{% else %}{{ "{:,}".format(table.count) }} row{% if table.count == 1 %}{% else %}s{% endif %}{% endif %}</p>
|
||||||
</div>
|
</div>
|
||||||
|
@ -90,15 +103,6 @@
|
||||||
</ul>
|
</ul>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if queries %}
|
|
||||||
<h2 id="queries">Queries</h2>
|
|
||||||
<ul class="bullets">
|
|
||||||
{% for query in queries %}
|
|
||||||
<li><a href="{{ urls.query(database, query.name) }}{% if query.fragment %}#{{ query.fragment }}{% endif %}" title="{{ query.description or query.sql }}">{{ query.title or query.name }}</a>{% if query.private %} 🔒{% endif %}</li>
|
|
||||||
{% endfor %}
|
|
||||||
</ul>
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{% if allow_download %}
|
{% if allow_download %}
|
||||||
<p class="download-sqlite">Download SQLite DB: <a href="{{ urls.database(database) }}.db">{{ database }}.db</a> <em>{{ format_bytes(size) }}</em></p>
|
<p class="download-sqlite">Download SQLite DB: <a href="{{ urls.database(database) }}.db">{{ database }}.db</a> <em>{{ format_bytes(size) }}</em></p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
@ -110,12 +110,32 @@ def test_database_page_redirects_with_url_hash(app_client_with_hash):
|
||||||
|
|
||||||
def test_database_page(app_client):
|
def test_database_page(app_client):
|
||||||
response = app_client.get("/fixtures")
|
response = app_client.get("/fixtures")
|
||||||
assert (
|
|
||||||
b"<p><em>pk, foreign_key_with_label, foreign_key_with_blank_label, "
|
|
||||||
b"foreign_key_with_no_label, foreign_key_compound_pk1, "
|
|
||||||
b"foreign_key_compound_pk2</em></p>"
|
|
||||||
) in response.body
|
|
||||||
soup = Soup(response.body, "html.parser")
|
soup = Soup(response.body, "html.parser")
|
||||||
|
# Should have a <textarea> for executing SQL
|
||||||
|
assert "<textarea" in response.text
|
||||||
|
|
||||||
|
# And a list of tables
|
||||||
|
for fragment in (
|
||||||
|
'<h2 id="tables">Tables</h2>',
|
||||||
|
'<h3><a href="/fixtures/sortable">sortable</a></h3>',
|
||||||
|
"<p><em>pk, foreign_key_with_label, foreign_key_with_blank_label, ",
|
||||||
|
):
|
||||||
|
assert fragment in response.text
|
||||||
|
|
||||||
|
# And views
|
||||||
|
views_ul = soup.find("h2", text="Views").find_next_sibling("ul")
|
||||||
|
assert views_ul is not None
|
||||||
|
assert [
|
||||||
|
("/fixtures/paginated_view", "paginated_view"),
|
||||||
|
("/fixtures/searchable_view", "searchable_view"),
|
||||||
|
(
|
||||||
|
"/fixtures/searchable_view_configured_by_metadata",
|
||||||
|
"searchable_view_configured_by_metadata",
|
||||||
|
),
|
||||||
|
("/fixtures/simple_view", "simple_view"),
|
||||||
|
] == sorted([(a["href"], a.text) for a in views_ul.find_all("a")])
|
||||||
|
|
||||||
|
# And a list of canned queries
|
||||||
queries_ul = soup.find("h2", text="Queries").find_next_sibling("ul")
|
queries_ul = soup.find("h2", text="Queries").find_next_sibling("ul")
|
||||||
assert queries_ul is not None
|
assert queries_ul is not None
|
||||||
assert [
|
assert [
|
||||||
|
|
Ładowanie…
Reference in New Issue