{% extends 'creme_core/bricks/base/paginated-table.html' %} {% load i18n creme_bricks creme_perms creme_widgets %}{% load and_op url url_join from creme_core_tags %} {% block brick_extra_class %}{{block.super}} creme_core-relations-brick{% endblock %} {% block brick_header_title %} {% brick_header_title title=_('{count} Relationship') plural=_('{count} Relationships') empty=verbose_name icon='relations' %} {% endblock %} {% block brick_header_actions %} {% url_join 'creme_core__create_relations'|url:object.id exclude=excluded_rtype_ids as create_uri %} {% brick_header_action id='link' url=create_uri label=_('New relationships') enabled=user|has_perm_to_link:object %} {% endblock %} {% block brick_table_columns %} {% brick_table_column title=_('Name') status='primary' colspan=2 %} {# {% brick_table_column_for_field ... field='type' .. %} #} {% brick_table_column title=_('Action') status='action' %} {% endblock %} {% block brick_table_rows %} {% with subject_unlink_perm=user|has_perm_to_unlink:object delete_url='creme_core__delete_relation'|url %} {% regroup page.object_list by type as relations_by_rtype %} {% for rtype, relations in relations_by_rtype %} {% for relation in relations %}{% with entity_obj=relation.real_object %} {% if forloop.first %}{{rtype.predicate}}{% else %} {% endif %} {% widget_entity_hyperlink entity_obj user %} {% if rtype.is_internal %} {% brick_table_action id='delete' label=_('Cannot delete this relationship (internal type)') icon='unlink' enabled=False %} {% else %} {% with object_unlink_perm=user|has_perm_to_unlink:entity_obj %} {% brick_table_action id='delete' url=delete_url __id=relation.pk label=_('Delete this relationship') icon='unlink' enabled=subject_unlink_perm|and_op:object_unlink_perm %} {% endwith %} {% endif %} {% endwith %}{% endfor %} {% endfor %} {% endwith %} {% endblock %} {% block brick_table_empty %} {% translate 'No relationship for the moment' %} {% endblock %}