{% extends 'creme_core/bricks/base/paginated-list.html' %} {% load i18n creme_bricks creme_cells creme_ctype creme_widgets %} {% load and_op has_perm_to inner_edition_uri is_plural templatize url from creme_core_tags %} {% block brick_extra_class %}{{block.super}} creme_core-specific-relations-brick{% endblock %} {% block brick_menu_actions %} {{block.super}} {% if relation_type.enabled %}
{% 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 %} {% 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 %} {% if relation_type.is_internal %} {% brick_header_action id='link' label=_('New relationships') help_text=_('This relation type is internal, so you cannot create a relationship with this generic block') enabled=False %} {% elif relation_type.enabled %} {% 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 %} {% 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_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 %} {% if relation_type.is_internal %} {% brick_table_column title=_('Action') status='action' %} {% else %} {% brick_table_column title=_('Action') status='action' colspan=2 %} {% endif %} {% 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 %} {# {% if not relation_type.is_internal %} {% endif %} {% endfor %} {% else %} {% for entity_obj in entities %} {% endfor %} {% endif %}
{% cell_render cell=cell instance=entity_obj user=user 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}}{% inner_edition_uri instance=entity_obj cells=cells callback_url=request.get_full_path as edition_uri %}{% has_perm_to change entity_obj as obj_edition_perm %} #} {% inner_edition_uri instance=entity_obj cells=cells callback_url=object.get_absolute_url as edition_uri %}{% has_perm_to change entity_obj as obj_edition_perm %} {% blocktranslate with object=entity_obj asvar edition_label %}Edit «{{object}}»{% endblocktranslate %} {% brick_table_action id='edit' url=edition_uri label=edition_label enabled=obj_edition_perm %} {% 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 %} {% if not relation_type.is_internal %}{% 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 %}
{% endif %} {% endwith %} {% endfor %} {% endblock %} {% block brick_list_empty %} {% translate 'No related entity for the moment' %} {% endblock %}