{% extends cv_extends %} {% load i18n crud_views %} {% block cv_content %}
{% translate "Title" %}
{{ object.title }}
{% translate "Priority" %}
{{ object.get_priority_display }}
{% translate "Description" %}
{{ object.description|default:"—" }}

{% blocktranslate trimmed %} Every button below is placed by hand in this template. Log in as alice (may edit and delete) and as bob (may only view) to compare: a button the user may not use is hidden, except delete, which this demo renders disabled (greyed out). {% endblocktranslate %}

{# 1. cv_context_button: one complete button by key, rendered with that button's own template #}
1. {% verbatim %}{% cv_context_button %}{% endverbatim %}

{% translate "A toolbar of your own. edit_pill uses a template file, delete the default template." %}

{% cv_context_button "edit_pill" %} {% cv_context_button "delete" %}
{# 2. cv_context_url: only the permission-checked URL, for markup you write yourself #}
2. {% verbatim %}{% cv_context_url %}{% endverbatim %}
{% cv_context_url "update" as edit_url %} {% if edit_url %}
{% translate "Edit this ticket" %}
{% else %}

{% translate "No URL — you may not edit this ticket, so the tile is not rendered." %}

{% endif %} {# 3. cv_context_has_permission: show surrounding markup only when the user may use the key #}
3. cv_context_has_permission
{% if view|cv_context_has_permission:"delete" %}
{% translate "Danger zone" %}
{% cv_context_button "delete" %}
{% else %}

{% translate "The danger zone is only shown to users who may delete." %}

{% endif %} {# 4. a loop over the view's cv_context_actions: hidden buttons left out, disabled ones (delete for bob) included #}
4. view.cv_get_context_buttons + {% verbatim %}{% cv_render_context_button %}{% endverbatim %}
{% endblock cv_content %}