{% extends 'creme_core/bricks/base/paginated-table.html' %} {% load i18n creme_bricks creme_ctype creme_perms creme_widgets %} {% load and_op url from creme_core_tags %} {% block brick_extra_class %}{{block.super}} documents-linked-brick{% endblock %} {% block brick_header_title %} {% brick_header_title title=_('{count} Linked document') plural=_('{count} Linked documents') empty=verbose_name icon='document' %} {% endblock %} {% block brick_header_actions %} {% if relation_type.enabled %} {% ctype_for_swappable 'DOCUMENTS_DOCUMENT_MODEL' as ct_doc %} {% with creation_perm=user|has_perm_to_create:ct_doc link_perm=user|has_perm_to_link:object doc_link_perm=user|has_perm_to_link:ct_doc %} {% brick_header_action id='add' url='documents__create_related_document'|url:object.id label=_('Create a document') enabled=creation_perm|and_op:link_perm|and_op:doc_link_perm %} {% brick_header_action id='add-relationships' label=_('Link to an existing document') icon='link' enabled=link_perm|and_op:doc_link_perm __subject_id=object.id __rtype_id=relation_type.id __ctype_id=ct_doc.id __multiple=True %} {% endwith %} {% endif %} {% endblock %} {% block brick_before_content %} {% if not relation_type.enabled %}
{% blocktranslate with predicate=relation_type.predicate %}Beware: the relationship type «{{predicate}}» is disabled. You should re-enable it if it's still useful, or remove this block{% endblocktranslate %}
{% endif %} {% endblock %} {% block brick_table_columns %} {% brick_table_column title=_('Name') primary=True %} {% brick_table_column title=_('Actions') status='action' colspan=2 %} {% endblock %} {% block brick_table_rows %} {% with unlink_perm=user|has_perm_to_unlink:object del_rel_url='creme_core__delete_relation'|url %} {% for relation in page.object_list %} {% with doc=relation.object_entity %} {% widget_entity_hyperlink doc user %} {% brick_table_action id='redirect' url=doc.get_download_absolute_url icon='download' label=_('Download') enabled=user|has_perm_to_view:doc %} {% with doc_unlink_perm=user|has_perm_to_unlink:doc %} {% brick_table_action id='delete' url=del_rel_url __id=relation.pk label=_('Unlink this document') icon='unlink' enabled=unlink_perm|and_op:doc_unlink_perm %} {% endwith %} {% endwith %} {% endfor %} {% endwith %} {% endblock %} {% block brick_table_empty %} {% translate 'No linked document' %} {% endblock %}