_comment_card.html 5.08 KB
Newer Older
1
2
{% load static i18n activity_tags core_tags crispy_forms_tags mptt_tags humanize tz %}

3

4
    <div class="row smallskip comment-card" id="comment-{{ comment.uuid }}">
5
6
        <div class="col-md-10">
            <div class="row">
7

8
9
10
11
12
13
14
                <div class="col-md-1">
                    {% include 'ddusers/_user-image.html' with user_uuid=comment.owner.uuid user_photo=comment.owner.photo %}
                    <span class="badge badge-{{ comment.get_comment_type_display }}">{{ comment.get_comment_type_display }}</span>
                </div>
                <div class="col-md-11">
                    <span class="comment-name"> {{ comment.owner.get_academic_name }}</span> <span class="comment-naturaltime">{{ comment.date_added | naturaltime }}</span> {% if comment.deleted %}<span class="badge badge-deleted">{% trans "Deleted" %}</span>{% endif %}

15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
                    {% with parent=comment|get_parent_comment %}
                        {% if comment.is_public or request.user == comment.owner or request.user == parent.owner %}
                            <div class="comment-text" id="comment-text-{{ comment.uuid }}">
                                {{ comment.text|linebreaks |urlize | safe }}
                            </div>

                            <span class="comment-date">
                                {# date comparison without format filter takes even milliseconds into account, which leads to false results #}
                                {% trans "Created at" %}: {{ comment.date_added|date:"d.m.Y, H:m:s" }}{% if comment.date_edited|date:"d M Y h i s" != comment.date_added|date:"d M Y h i s" %}<br>{% trans "Edited at" %}: {{ comment.date_edited|date:"d.m.Y, H:m:s" }}{% endif %}
                            </span>

                            <div id="comment-text-{{ comment.uuid }}-reply">
                                <div id="comment-text-{{ comment.uuid }}-buttons">
                                    {% if request.user == comment.owner %}
                                        {% if not comment.deleted %}
                                        {# edit button #}
                                        <button class="btn btn-link" ic-target="#comment-text-{{ comment.uuid }}" ic-get-from="{% url add_url ds.uuid comment.uuid %}">
                                            {% trans "Edit" %}
                                        </button>

                                        {# delete button #}
                                        <button type="button" class="btn btn-link" data-toggle="modal" data-target="#confirmModal{{ comment.uuid }}" title="{% trans 'Delete' %}" ic-get-from="{% url 'core:polling_stop' %}" ic-target="#pollstatus">
                                            {% trans "Delete" %}
                                        </button>
                                        {% endif%}
                                    {% endif %}
                                    {# reply button #}
                                    {% with parent=comment|get_parent_comment %}
                                        {% if parent %}
                                        <button class="btn btn-link" ic-target="#comment-text-{{ comment.uuid }}-reply" ic-get-from="{% url reply_url ds.uuid parent.uuid %}">
                                            {% if parent == comment %}{% trans "Reply to comment" %}{% else %}{% trans "Reply to thread" %}{% endif %}
                                        </button>
                                        {% endif %}
                                    {% endwith %}
                                </div>
                            </div>
                        {% else %}
                            <div class="comment-text" id="comment-text-{{ comment.uuid }}">
                                <p><i>{% trans "This comment is private." %}</i></p>
                            </div>
                        {% endif%}
                    {% endwith %}

58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81

                    {% comment %}
                    {% with prepared_form=comment|prepare_comment_form:request.user %}
                        {% if prepared_form %}
                            {% include 'ddcomments/_comment_add.html' with form=prepared_form add_url=add_url ictarget="#ds-content" btn_text="Reply" %}
                        {% endif %}
                    {% endwith %}
                    {% endcomment %}
                    <div class="smallskip"></div>
                    {% if not is_child %}
                        <div class="children">
                        {% for child in comment.get_children %}
                            {% include 'ddcomments/_comment_card.html' with comment=child form=form ds=ds is_child=True %}
                        {% endfor %}
                        </div>
                    {% endif %}
                </div>
            </div>
        </div>
    </div>
    {# Modal to confirm project delete #}
    {% include "core/_confirm_modal.html" with objecttype="comment" objectid=comment.uuid dsid=ds.uuid objectname=comment delete_url=add_url edit_url=add_url target=target ictarget="#comments-list" pollstatusid="#pollstatus" %}

<span id="pollstatus"></span>