_comment_div.html 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. {# section commentaire. prends en parametre un objet Story ou Epic #}
  2. {# l'objet en parametre doit avoir une propriete 'comments' et une propriete 'uuid' #}
  3. {% load martortags %}
  4. <a class="anchor" id="a-comment-section"></a>
  5. <div id="comment-section">
  6. <ul class="comment-list">
  7. {% for comment, frm in com_pack.comments.items %}
  8. <li class="comment flex-col anchor" id="comment-{{ comment.id }}" data-id="{{ comment.id }}">
  9. <a class="anchor" id="a-comment-{{ comment.id }}"></a>
  10. <div class="flex-row">
  11. <span class="comment-header"><i class="fa fa-comment"></i> {{ comment.author }}, le {{ comment.created }}</span>
  12. {% if comment.author.id == request.user.id %}
  13. <a class="comment-edit-btn" href="" style="margin-left: 20px;"><i class="fa fa-pencil"></i></a>
  14. <a class="comment-del-btn" href="{% url 'comment_del' comment_id=comment.id %}" style="margin-left: 10px;"><i class="fa fa-trash"></i></a>
  15. {% endif %}
  16. </div>
  17. <div class="comment-display">
  18. {{ comment.content|safe_markdown }}
  19. </div>
  20. <div class="comment-edition" style="display: none;">
  21. <form action="{% url 'comment_edit' comment_id=comment.id %}" method="post" accept-charset="utf-8" enctype="multipart/form-data">
  22. {% csrf_token %}
  23. {{ frm.content }}
  24. <div class="flex-row flex-end" style="margin-top: 10px;">
  25. <a href="" class="comment-edition-cancel" style="margin-right: 20px;">Annuler</a>
  26. <input type="submit">
  27. </div>
  28. </form>
  29. </div>
  30. </li>
  31. {% endfor %}
  32. </ul>
  33. <form action="{% url 'comment_post' obj_uuid=com_pack.obj.uuid %}" method="post" accept-charset="utf-8" enctype="multipart/form-data">
  34. {% csrf_token %}
  35. {{ com_pack.empty_form.as_p }}
  36. <div class="flex-row flex-end" style="margin-top: 10px;">
  37. <input type="submit">
  38. </div>
  39. </form>
  40. </div>
  41. <script>
  42. $(".comment-edit-btn, .comment-edition-cancel").click(function (event) {
  43. event.preventDefault();
  44. var comment_li = $(this).closest('.comment');
  45. comment_li.find('.comment-edition').toggle();
  46. comment_li.find('.comment-display').toggle();
  47. });
  48. $(".comment-del-btn").click(function (event) {
  49. if (confirm('Êtes vous sûr de vouloir supprimer le commentaire?')) {
  50. return true;
  51. }
  52. });
  53. </script>