mirror of
https://github.com/simonw/datasette.git
synced 2026-06-02 23:26:59 +02:00
top_canned_query is now top_stored_query, closes #2747
This commit is contained in:
parent
4bf1c4b065
commit
b1029acc68
6 changed files with 15 additions and 12 deletions
|
|
@ -228,7 +228,7 @@ def top_query(datasette, request, database, sql):
|
|||
|
||||
|
||||
@hookspec
|
||||
def top_canned_query(datasette, request, database, query_name):
|
||||
def top_stored_query(datasette, request, database, query_name):
|
||||
"""HTML to include at the top of the stored query page"""
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@
|
|||
{% set action_links, action_title = query_actions(), "Query actions" %}
|
||||
{% include "_action_menu.html" %}
|
||||
|
||||
{% if canned_query %}{{ top_canned_query() }}{% else %}{{ top_query() }}{% endif %}
|
||||
{% if canned_query %}{{ top_stored_query() }}{% else %}{{ top_query() }}{% endif %}
|
||||
|
||||
{% block description_source_license %}{% include "_description_source_license.html" %}{% endblock %}
|
||||
|
||||
|
|
|
|||
|
|
@ -339,8 +339,8 @@ class QueryContext(Context):
|
|||
top_query: callable = field(
|
||||
metadata={"help": "Callable to render the top_query slot"}
|
||||
)
|
||||
top_canned_query: callable = field(
|
||||
metadata={"help": "Callable to render the top_canned_query slot"}
|
||||
top_stored_query: callable = field(
|
||||
metadata={"help": "Callable to render the top_stored_query slot"}
|
||||
)
|
||||
query_actions: callable = field(
|
||||
metadata={
|
||||
|
|
@ -2095,8 +2095,8 @@ class QueryView(View):
|
|||
top_query=make_slot_function(
|
||||
"top_query", datasette, request, database=database, sql=sql
|
||||
),
|
||||
top_canned_query=make_slot_function(
|
||||
"top_canned_query",
|
||||
top_stored_query=make_slot_function(
|
||||
"top_stored_query",
|
||||
datasette,
|
||||
request,
|
||||
database=database,
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ Unreleased
|
|||
----------
|
||||
|
||||
- Fixed a bug where visiting ``/<database>/-/query`` without a ``?sql=`` parameter returned a 500 error. (:issue:`2743`)
|
||||
- The ``top_canned_query()`` plugin hook has been renamed to :ref:`top_stored_query() <plugin_hook_top_stored_query>`. (:issue:`2747`)
|
||||
|
||||
.. _v1_0_a30:
|
||||
|
||||
|
|
|
|||
|
|
@ -2279,9 +2279,9 @@ top_query(datasette, request, database, sql)
|
|||
|
||||
Returns HTML to be displayed at the top of the query results page.
|
||||
|
||||
.. _plugin_hook_top_canned_query:
|
||||
.. _plugin_hook_top_stored_query:
|
||||
|
||||
top_canned_query(datasette, request, database, query_name)
|
||||
top_stored_query(datasette, request, database, query_name)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
``datasette`` - :ref:`internals_datasette`
|
||||
|
|
|
|||
|
|
@ -1486,8 +1486,10 @@ class SlotPlugin:
|
|||
return "Xtop_query:{}:{}:{}".format(database, sql, request.args["z"])
|
||||
|
||||
@hookimpl
|
||||
def top_canned_query(self, request, database, query_name):
|
||||
return "Xtop_query:{}:{}:{}".format(database, query_name, request.args["z"])
|
||||
def top_stored_query(self, request, database, query_name):
|
||||
return "Xtop_stored_query:{}:{}:{}".format(
|
||||
database, query_name, request.args["z"]
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
|
|
@ -1548,12 +1550,12 @@ async def test_hook_top_query(ds_client):
|
|||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_hook_top_canned_query(ds_client):
|
||||
async def test_hook_top_stored_query(ds_client):
|
||||
try:
|
||||
pm.register(SlotPlugin(), name="SlotPlugin")
|
||||
response = await ds_client.get("/fixtures/magic_parameters?z=xyz")
|
||||
assert response.status_code == 200
|
||||
assert "Xtop_query:fixtures:magic_parameters:xyz" in response.text
|
||||
assert "Xtop_stored_query:fixtures:magic_parameters:xyz" in response.text
|
||||
finally:
|
||||
pm.unregister(name="SlotPlugin")
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue