mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
View list respects view-table permission, refs #811
Also makes a small change to the /fixtures.json JSON:
"views": ["view_name"]
Is now:
"views": [{"name": "view_name", "private": true}]
This commit is contained in:
parent
9ac27f67fe
commit
dcec89270a
3 changed files with 24 additions and 7 deletions
|
|
@ -51,7 +51,7 @@
|
|||
<h2 id="views">Views</h2>
|
||||
<ul>
|
||||
{% for view in views %}
|
||||
<li><a href="{{ database_url(database) }}/{{ view|urlencode }}">{{ view }}</a></li>
|
||||
<li><a href="{{ database_url(database) }}/{{ view.name|urlencode }}">{{ view.name }}</a>{% if view.private %} 🔒{% endif %}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
|
|
|
|||
|
|
@ -37,10 +37,19 @@ class DatabaseView(DataView):
|
|||
db = self.ds.databases[database]
|
||||
|
||||
table_counts = await db.table_counts(5)
|
||||
views = await db.view_names()
|
||||
hidden_table_names = set(await db.hidden_table_names())
|
||||
all_foreign_keys = await db.get_all_foreign_keys()
|
||||
|
||||
views = []
|
||||
for view_name in await db.view_names():
|
||||
visible, private = await check_visibility(
|
||||
self.ds, request.actor, "view-table", "table", (database, view_name),
|
||||
)
|
||||
if visible:
|
||||
views.append(
|
||||
{"name": view_name, "private": private,}
|
||||
)
|
||||
|
||||
tables = []
|
||||
for table in table_counts:
|
||||
visible, private = await check_visibility(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue