Skip to content

Commit

Permalink
Set view_name correctly in a few more places
Browse files Browse the repository at this point in the history
  • Loading branch information
simonw committed Aug 8, 2023
1 parent 7532feb commit b45965b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
11 changes: 8 additions & 3 deletions datasette/views/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,12 @@ async def database_actions():
],
}
return Response.html(
await datasette.render_template(templates, context, request=request),
await datasette.render_template(
templates,
context,
request=request,
view_name="database",
),
headers={
"Link": '{}; rel="alternate"; type="application/json+datasette"'.format(
alternate_url_json
Expand Down Expand Up @@ -470,8 +475,7 @@ async def fetch_data_for_csv(request, _next=None):
database=database,
table=data.get("table"),
request=request,
# TODO: Fix this
view_name=None,
view_name="database",
)
it_can_render = await await_me_maybe(it_can_render)
if it_can_render:
Expand Down Expand Up @@ -543,6 +547,7 @@ async def fetch_data_for_csv(request, _next=None):
alternate_url_json=alternate_url_json,
),
request=request,
view_name="database",
),
headers=headers,
)
Expand Down
5 changes: 2 additions & 3 deletions tests/test_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,8 @@ async def test_hook_extra_css_urls(ds_client, path, expected_decoded_object):
][0]["href"]
# This link has a base64-encoded JSON blob in it
encoded = special_href.split("/")[3]
assert expected_decoded_object == json.loads(
base64.b64decode(encoded).decode("utf8")
)
actual_decoded_object = json.loads(base64.b64decode(encoded).decode("utf8"))
assert expected_decoded_object == actual_decoded_object


@pytest.mark.asyncio
Expand Down

0 comments on commit b45965b

Please sign in to comment.