PCv5/app/templates/widgets/thread.html

56 lines
2.7 KiB
HTML

{% import "widgets/user.html" as widget_user %}
{% import "widgets/attachments.html" as widget_attachments %}
{% macro thread(comments, top_comment) %}
<table class="thread {{ 'topcomment' if top_comment == None else ''}} ">
{% for c in comments %}
<tr id="{{ c.id }}">
{% if c != top_comment %}
<td class="author">{{ widget_user.profile(c.author) }}</td>
<td class="message">
<div class="info">
<div>Posté le <a href="{{ request.path }}#{{ c.id }}">{{ c.date_created | dyndate }}</a></div>
{% if c.date_created != c.date_modified %}
<div>Modifié le <a href="{{ request.path }}#{{ c.id }}">{{ c.date_modified | dyndate }}</a></div>
{% endif %}
{# TODO: Let guests edit their posts #}
{% set can_edit = current_user.is_authenticated and current_user.can_edit_post(c) %}
{% set can_delete = current_user.is_authenticated and current_user.can_delete_post(c) %}
{% set can_punish = current_user.is_authenticated and current_user.priv("delete.posts") %}
{% if can_edit or can_delete or can_punish %}
<details>
<summary><b></b></summary>
<div class='context-menu'>
{% if can_edit %}
<a href="{{ url_for('edit_post', postid=c.id, r=request.path) }}">Modifier</a>
{% endif %}
{% if can_punish %}
<a href="{{ url_for('delete_post', postid=c.id, penalty=False, csrf_token=csrf_token()) }}" onclick="return confirm('Le message sera supprimé.')">Supprimer (normal)</a>
<a href="{{ url_for('delete_post', postid=c.id, penalty=True, csrf_token=csrf_token()) }}" onclick="return confirm('Le message sera supprimé avec pénalité d\'XP.')">Supprimer (pénalité)</a>
{% elif can_delete %}
<a href="{{ url_for('delete_post', postid=c.id, penalty=False, csrf_token=csrf_token()) }}" onclick="return confirm('Le message sera supprimé !')">Supprimer</a>
{% endif %}
</div>
</details>
{% endif %}
</div>
{{ c.text|md }}
{{ widget_attachments.attachments(c) }}
{% if c.author.signature %}
<hr class="signature">
{{ c.author.signature|md }}
{% endif %}
</td>
{% elif loop.index0 != 0 %}
<div>Ce message est le top comment</div>
{% endif %}
</tr>
{% endfor %}
</table>
{% endmacro %}