{% extends "myhome_base.html" %}
{% load seahub_tags avatar_tags i18n %}
{% load url from future %}

{% block right_panel %}
{% if group_msgs %}
    <ul class="msg-list msg-panel">
    {% for msg in group_msgs %}
    <li class="msg w100 ovhd" data-id="{{msg.id}}">
        <div class="pic fleft">
            <a href="{% url 'user_profile' msg.from_email %}">{% avatar msg.from_email 48 %}</a>
        </div>
        <div class="txt">
            <div class="msg-main">
            <div class="msg-hd">
                <a href="{% url 'user_profile' msg.from_email %}" title="{{msg.from_email}}" class="author">{{ msg.from_email|email2nickname }}</a>
                <span class="time">{{ msg.timestamp|translate_seahub_time }}</span>
                <span class="group">{% trans "Group: " %}<a href="{% url 'group_info' msg.group_id %}">{{ msg.group_name }}</a></span>
            </div>
                <p class="msg-con">{{ msg.message|seahub_urlize|find_at|linebreaksbr }}</p>
                {% if msg.attachments %}
                <ul class="msg-attachment">
                {% for ma in msg.attachments %}
                    <li>
                    {% if ma.src == 'recommend' %}
                    {% if ma.attach_type == 'file' %}
                    <img src="{{ MEDIA_URL }}img/file/{{ ma.name|file_icon_filter }}" alt="{% trans "File"%}" height="18" class="vam" />
                    <a href="{% url 'view_lib_file' ma.repo_id ma.path|urlencode %}" target="_blank" class="vam">{{ ma.name }}</a>
                    {% else %}
                    <img src="{{ MEDIA_URL }}img/folder-icon-24.png" alt="{% trans "Directory icon"%}" height="20" class="vam" />
                    <a href="{% url 'repo' ma.repo_id %}?p={{ ma.path|urlencode }}" target="_blank" class="vam">{{ ma.name }}</a>
                    {% endif %}
                    {% endif %}

                    {% if ma.src == 'filecomment' %} {# compatible with comments already exist #}
                    <img src="{{ MEDIA_URL }}img/file/{{ ma.name|file_icon_filter }}" alt="{% trans "File"%}" height="18" class="vam" />
                    <a href="{% url 'view_lib_file' ma.repo_id ma.path|urlencode %}" target="_blank" class="vam">{{ ma.name }}</a>
                    {% endif %}
                    </li>
                {% endfor %}
                </ul>
                {% endif %}
                <span class="say"></span>
            </div>  
            <div class="msg-op">
                <div class="replies-op{% if msg.reply_cnt < 4 %} hide{% endif %}" data-rstatus="hide">
                    <span class="unfold-replies">{% blocktrans with amount=msg.reply_cnt %}{{ amount }} replies{% endblocktrans %}</span>
                    <span class="fold-replies hide">{% trans "Hide replies" %}</span>
                    <img src="{{MEDIA_URL}}img/loading-icon.gif" alt="" width="16" class="replies-loading-icon hide" />
                </div>
                <ul class="reply-list">
                    {% for r in msg.replies %}
                    <li class="reply w100 ovhd">
                    <a href="{% url 'user_profile' r.from_email %}" class="pic fleft">{% avatar r.from_email 28 %}</a>
                    <div class="txt">
                        <a href="{% url 'user_profile' r.from_email %}">{{ r.from_email|email2nickname }}</a>
                        <span class="time">{{ r.timestamp|translate_seahub_time }}</span>
                        <span class="reply-at op vh" data="{{ r.from_email|email2nickname }}">{% trans 'Reply' %}</span>
                        <p class="reply-con">{{ r.message|seahub_urlize|find_at|linebreaksbr }}</p>
                    </div>
                    </li>
                    {% endfor %}
                </ul>
                <form action="" method="post" class="reply-form">
                    <textarea placeholder="{% trans "Add a reply..." %}" name="message" class="reply-input"></textarea>
                    <p class="error hide">{% trans "It can not be blank and should be no more than 2048 characters." %}</p>
                    <button type="submit" class="reply-submit hide">{% trans "Submit" %}</button>
                    <button type="button" class="reply-cancel hide">{% trans "Cancel" %}</button>
                </form>
            </div>
        </div>
        </li>
    {% endfor %}
    </ul>
{% else %}
<p>{% trans 'None' %}</p>    
{% endif %}
{% endblock %}

{% block extra_script %}
<script type="text/javascript">
{% include 'group/msg_js.html' %}
</script>
{% endblock %}
