Skip to content

Commit

Permalink
Upload a CSV database action, closes #28
Browse files Browse the repository at this point in the history
  • Loading branch information
simonw committed Jan 30, 2024
1 parent b8e294d commit 3894121
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions datasette_upload_csvs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,27 @@ async def inner():
return inner


@hookimpl
def database_actions(datasette, actor, database):
async def inner():
db = datasette.get_database(database)
if (
await datasette.permission_allowed(actor, "upload-csvs", default=False)
and db.is_mutable
and db.name not in ("_memory", "_internal")
):
return [
{
"href": datasette.urls.path(
"/-/upload-csvs?database={}".format(quote_plus(db.name))
),
"label": "Upload a CSV",
}
]

return inner


async def upload_csvs(scope, receive, datasette, request):
if not await datasette.permission_allowed(
request.actor, "upload-csvs", default=False
Expand Down

0 comments on commit 3894121

Please sign in to comment.