{% extends 'creme_core/bricks/base/paginated-list.html' %} {% load i18n creme_core_tags creme_bricks creme_cells creme_ctype creme_widgets %} {% block brick_extra_class %}{{block.super}} creme_core-specific-relations-brick{% endblock %} {% block brick_menu_actions %} {{block.super}}
{% has_perm_to admin 'creme_core' as config_perm %} {% for ctype, cells in config_item.iter_cells %}{% url 'creme_config__edit_cells_of_rtype_brick' config_item.id ctype.id as edit_cells_url %}{% blocktranslate asvar edit_label %}Configure the fields for «{{ctype}}»'{% endblocktranslate %} {% brick_menu_action id='edit' url=edit_cells_url icon='config' label=edit_label enabled=config_perm %} {% endfor %} {% if not config_item.all_ctypes_configured %} {% brick_menu_action id='edit' url='creme_config__add_cells_to_rtype_brick'|url:config_item.id label=_('Configure the fields of a new type') enabled=config_perm %} {% endif %} {% endblock %} {% block brick_header_title %} {% with predicate=relation_type.predicate %} {% if page.paginator.count|is_plural %}{% translate '{count} Entities' as first_part %}{% else %}{% translate '{count} Entity' as first_part %}{% endif %} {% templatize '{{first_part}} — {{predicate}}' as title_fmt %} {% brick_header_title title=title_fmt empty=predicate icon='relations' %} {% endwith %} {% endblock %} {% block brick_header_actions %} {% has_perm_to link object as subject_link_perm %}{% url 'creme_core__create_relations' object.id relation_type.id as create_url %} {% brick_header_action id='link' url=create_url label=_('New relationships') enabled=subject_link_perm %} {% endblock %} {% block brick_list_content %} {% has_perm_to unlink object as subject_unlink_perm %}{% url 'creme_core__delete_relation' as delete_url %} {% for entities, cells in groups %} {% with counter=entities|length %} {% if counter %}
{% if cells %}
{% ctype_counted_instances_label entities.0.entity_type counter as label %}{{label}}
{% elif groups|length > 1 %}
{% blocktranslate count count=counter %}{{count}} Entity{% plural %}{{count}} Entities{% endblocktranslate %}
{% endif %}
{% if cells %} {% for cell in cells %} {% if forloop.first %} {% brick_table_column title=cell.title status='primary' %} {% else %} {% brick_table_column title=cell.title %} {% endif %} {% endfor %} {% brick_table_column title=_('Action') status='action' %} {% for entity_obj in entities %} {% has_perm_to view entity_obj as object_view_perm %} {% if object_view_perm %} {% for cell in cells %} {% if forloop.first %} {% endfor %} {% else %} {% for cell in cells %} {% endfor %} {% endif %} {% endfor %} {% else %} {% for entity_obj in entities %} {% endfor %} {% endif %}
{% cell_render cell=cell instance=entity_obj user=user output='csv' as cell_content %} {% if cell_content %}{{cell_content}}{% else %}{% translate '(empty)' %}{% endif %} {% else %} {% cell_render cell=cell instance=entity_obj user=user as cell_content %} {% if cell_content %}{{cell_content}}{% else %}{% endif %} {% endif %} {{HIDDEN_VALUE}}{% has_perm_to unlink entity_obj as object_unlink_perm %} {% brick_table_action id='delete' url=delete_url __id=entity_obj.srb_relation_cache.id label=_('Delete this relationship') icon='unlink' enabled=subject_unlink_perm|and_op:object_unlink_perm %}
{% widget_entity_hyperlink entity_obj user %} {% has_perm_to unlink entity_obj as object_unlink_perm %} {% brick_table_action id='delete' url=delete_url __id=entity_obj.srb_relation_cache.id label=_('Delete this relationship') icon='unlink' enabled=subject_unlink_perm|and_op:object_unlink_perm %}
{% endif %} {% endwith %} {% endfor %} {% endblock %} {% block brick_list_empty %} {% translate 'No related entity for the moment' %} {% endblock %}