{% macro get_attachment_icon(attachment) -%} {%- if attachment.type.name == 'link' -%} icon-link {%- else -%} {{ icon_from_mimetype(attachment.file.content_type, 'icon-file-filled') }} {%- endif -%} {%- endmacro %} {% macro render_attachment(attachment, has_label=false, classes='') %} {% set previewable = (attachment.file.is_previewable and not g.static_site) or false %} {%- if not has_label -%} {{ attachment.title }} {%- endif -%} {% endmacro %} {% macro _attachment_row(attachment, management=true) %} {{ render_attachment(attachment) }} {%- if attachment.is_self_protected %} {% endif %} {% if management -%} {{ attachment.modified_dt|format_datetime('short') }} {%- endif %} {% endmacro %} {% macro _folder_row(folder, management=true) -%} {{ folder.title }} {%- if folder.is_self_protected %} {% endif %} {% if management -%} {%- endif %} {# Div to have a smooth slide up and down of the sub-tree #}
{{- _render_tree(folder.attachments, false, management=management) -}}
{%- endmacro %} {% macro _render_tree(nodes, is_folder, management=true) -%} {%- for sub_node in nodes -%} {% if is_folder %} {{ _folder_row(sub_node, management=management) }} {% else %} {{ _attachment_row(sub_node, management=management) }} {% endif %} {%- else -%} {% trans %}empty folder{% endtrans %} {%- endfor -%} {%- endmacro %} {% macro render_attachments(attachments, linked_object=None, management=true) -%} {%- if attachments -%} {%- if attachments.files -%} {{ _render_tree(attachments.files, false, management=management) }} {%- endif -%} {%- if attachments.folders -%} {{ _render_tree(attachments.folders, true, management=management) }} {%- endif -%}
{%- else -%} {% trans %}There are no materials yet.{% endtrans %} {%- endif -%} {% if management %} {% endif %} {%- endmacro %} {% macro attachments_page(linked_object, linked_object_type, attachments) %}
{% if linked_object_type == 'category' %} {% trans %}Add materials to the category.{% endtrans %} {% elif linked_object_type == 'event' %} {% trans %}Add materials to the event.{% endtrans %} {% elif linked_object_type == 'session' %} {% trans %}Add materials to the session.{% endtrans %} {% elif linked_object_type == 'contribution' %} {% trans %}Add materials to the contribution.{% endtrans %} {% elif linked_object_type == 'subcontribution' %} {% trans %}Add materials to the subcontribution.{% endtrans %} {% endif %}
{% trans %}You can attach files or links using the buttons on the right.{% endtrans %}
{% if linked_object_type == 'event' and not request.is_xhr and linked_object.can_manage(session.user) %}
{% trans %}Generate a material package.{% endtrans %}
{% trans %}You can generate a ZIP file containing materials from the event.{% endtrans %}
{% endif %}
{{ render_attachments(attachments, linked_object) }}
{% endmacro %}