{% extends 'cradmin_legacy/viewhelpers/listbuilder/base/itemvalue.django.html' %}

{% load devilry_group_tags %}
{% load devilry_core_tags %}
{% load devilry_account_tags %}
{% load cradmin_legacy_tags %}
{% load crispy_forms_tags %}
{% load tz %}
{% load i18n %}

{% block content %}
    <div class="devilry-group-feedbackfeed-comment-content">
        <p class="devilry-group-comment-meta">
            <span class="devilry-group-comment-created-by-role comment-created-by-role-text">
                ({% trans me.group_comment.user_role %})
            </span>
            <span class="devilry-group-comment-created-by comment-created-by-text">
                {% if me.group_comment.user == None %}
                    {% devilry_group_comment_user_is_none %}
                {% else %}
                    {% if me.group_comment.user_role == 'student'%}
                        {{ me.get_display_name_html }}
                    {% elif me.group_comment.user_role == 'examiner' %}
                        {{ me.get_display_name_html }}
                    {% else %}
                        {{ me.get_display_name_html }}
                    {% endif %}
                {% endif %}
            </span>

            {% if me.include_edit_links %}
                {% block edit-links %}{% endblock edit-links %}
            {% endif %}

            {% if me.include_published_last_edited_datetime %}
                {% if me.get_last_edited_datetime_history %}
                    {% block last-edited-datetime %}
                        <br>
                        <a href="{% cradmin_instance_url appname='commenthistory' viewname='INDEX' group_comment_id=me.group_comment.id %}"
                           class="devilry-group-comment-last-edited-date">
                            {% trans "Last edited" context "groupcomment last edited link" %} {{ me.get_last_edited_datetime_history|localtime|date:"DATETIME_FORMAT" }}
                        </a>
                    {% endblock last-edited-datetime %}
                {% else %}
                    {% if me.is_published %}
                        <span class="devilry-group-comment-published-date comment-published-date-text">
                            {{ me.group_comment|devilry_group_comment_published }}
                        </span>
                    {% endif %}
                {% endif %}
            {% endif %}
        </p>
        <div class="devilry-group-comment-text">
            {% if me.group_comment.v2_id == '' %}
                {{ me.group_comment.text|devilry_group_markdown|safe }}
            {% else %}
                {{ me.group_comment.text|safe }}
            {% endif %}
        </div>
        {% if me.include_files %}
            {% for commentfile in me.group_comment.commentfile_set.all %}
                <a href="{% cradmin_instance_url appname='download' viewname='file-download' commentfile_id=commentfile.id %}"
                        class="devilry-filedownload" tooltip="{{ commentfile.filename }}">
                    <span class="devilry-filedownload__content">
                        <span class="devilry-filedownload__label">
                            {{ commentfile.filename }}
                        </span>
                        <span class="devilry-filedownload__icon">
                            <span class="fa fa-download fa-2x"></span>
                        </span>
                    </span>
                </a>
            {% endfor %}
        {% endif %}
    </div>

    {% block details %}
    {% endblock details %}

{% endblock content %}

