{% import "widgets/user.html" as widget_user %} {% import "widgets/attachments.html" as widget_attachments %} {# Post actions: this widget expands to a context menu with actions controlling a post, supporting different types of posts. #} {% macro post_actions(post) %} {# TODO (Guest edit): determine permissions in post_actions widget #} {% set auth = current_user.is_authenticated %} {% set can_edit = auth and current_user.can_edit_post(post) %} {% set can_delete = auth and current_user.can_delete_post(post) %} {% set can_punish = auth and current_user.can_punish_post(post) %} {% set can_topcomm = auth and current_user.can_set_topcomment(post) %} {% set can_move = auth and current_user.can_edit_post(post) and post.type == "comment" %} {% if post.type == "topic" %} {% set suffix = " le sujet" %} {% elif post.type == "program" %} {% set suffix = " le programme" %} {% endif %} {% if can_edit or can_move or can_delete or can_punish or can_topcomm %}
{% if can_edit %} Modifier{{ suffix }} {% endif %} {% if can_move %} Déplacer {% endif %} {% if can_punish %} Supprimer{{ suffix }} (normal) Supprimer{{ suffix }} (pénalité) {% elif can_delete %} Supprimer{{ suffix }} {% endif %} {% if can_topcomm %} Utiliser comme en-tête {% endif %}
{% endif %} {% endmacro %} {# Thread widget: this widget expands to a table that shows a list of comments from a thread, along with message controls. comments: List of comments to render top_comment: Thread's top comment (will be elided if encountered) #} {% macro thread(comments, top_comment, owner=None) %} {% for c in comments %} {% if c != top_comment %} {% elif loop.index0 != 0 %} {% endif %} {% endfor %}
{{ widget_user.profile(c.author) }}
{% if (c.date_modified - c.date_created).seconds > 120 %} {% endif %} {{ post_actions(c) }}
{{ c.text|md }} {{ widget_attachments.attachments(c) }} {% if c.author.signature %}
{{ c.author.signature|md }} {% endif %}
Le commentaire à cet endroit est actuellement utilisé comme en-tête.
{% endmacro %} {# Thread leader widget: this widget expands to a single-message thread which can show more text when called. This is intended for programs and similar objects which display metadata before description and comments. leader: Posts's top comment (actual rendering is delegated to caller) #} {% macro thread_leader(leader) %} {# Empty line to get normal background (instead of alternate one) #}
{{ widget_user.profile(leader.author) }} {{ caller() }}
{% endmacro %}