-
-
Notifications
You must be signed in to change notification settings - Fork 690
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
If user can see table but NOT database/instance nav links should not display #1831
Comments
Here are all the places that display that navigation bar at the moment: datasette/datasette/templates/row.html Lines 18 to 25 in b7fec7f
datasette/datasette/templates/table.html Lines 19 to 25 in b7fec7f
datasette/datasette/templates/query.html Lines 21 to 27 in b7fec7f
datasette/datasette/templates/error.html Lines 5 to 10 in b7fec7f
datasette/datasette/templates/database.html Lines 12 to 17 in b7fec7f
datasette/datasette/templates/show_json.html Lines 7 to 12 in b7fec7f
datasette/datasette/templates/permissions_debug.html Lines 25 to 30 in b7fec7f
Interesting to note that failing to include that datasette/datasette/templates/base.html Lines 20 to 49 in b7fec7f
|
The fact that this code is inconsistent already ( |
Related issue: I'd like a code design for this that helps solve both these issues at once. |
Maybe new template functions: Or just |
Made some notes on the Jinja documentation while thinking about the best way to do this: |
As part of this I think I want |
It's important that, however this works, it supports custom templates changing how the breadcrumbs are displayed. Probably needs a |
This patch to |
This has turned into a full refactor of how breadcrumbs work. I'm using my first ever Jinja macro for this - I import that at the top of {% import "_crumbs.html" as crumbs with context %}<!DOCTYPE html> The Here's the full content of {% macro nav(request, database=None, table=None) -%}
{% set items=crumb_items(request=request, database=database, table=table) %}
{% if items %}
<p class="crumbs">
{% for item in items %}
<a href="{{ item.href }}">{{ item.label }}</a>
{% if not loop.last %}
/
{% endif %}
{% endfor %}
</p>
{% endif %}
{%- endmacro %} This means custom template authors can use their own In the actual templates I display breadcrumbs like this: {% block crumbs %}
{{ crumbs.nav(request=request, database=database) }}
{% endblock %} Pass I've also made the default base template show the |
I'm going to commit the code now, but then I need to add some extra tests to ensure the breadcrumb permission display logic works correctly. |
Spotted this bug while building this plugin:
This is a public table, but the two links in the nav go to forbidden pages:
Those nav links shouldn't be shown at all.
The text was updated successfully, but these errors were encountered: