{% load djblets_deco djblets_extensions djblets_utils i18n rb_extensions %}
{% load reviewtags tz %}

<a name="review{{entry.review.id}}"></a>
<div id="review{{entry.review.id}}" class="review" data-review-id="{{entry.review.id}}" data-ship-it="{{entry.review.ship_it|yesno:'true,false'}}">
{% if forloop.last %}
 <a name="last-review"></a>
{% endif %}
{% box entry.class %}
 <div class="box-main">

  <div class="header">
{%  template_hook_point "review-summary-header-pre" %}
{%  if entry.review.ship_it %}
{%   if entry.issue_open_count > 0 %}
   <div class="shipit with-issues">{% trans "Fix it, then Ship it!" %}</div>
{%   else %}
   <div class="shipit">{% trans "Ship it!" %}</div>
{%   endif %}
{%  endif %}
   <div class="collapse-button btn"><div class="rb-icon {% if entry.collapsed %}rb-icon-expand-review{% else %}rb-icon-collapse-review{% endif %}"></div></div>
   <div class="reviewer"><a href="{% url 'user' entry.review.user %}" class="user">{{entry.review.user|user_displayname}}</a></div>
   <div class="posted_time">{% localtime on %}{% blocktrans with entry.review.timestamp as timestamp and entry.review.timestamp|date:"c" as timestamp_raw %}Posted <time class="timesince" datetime="{{timestamp_raw}}">{{timestamp}}</time> ({{timestamp}}){% endblocktrans %}{% endlocaltime %}</div>
{%  template_hook_point "review-summary-header-post" %}
  </div>

  <div class="banners"></div>

  <div class="body">
   <pre class="body_top reviewtext {% rich_text_classname entry.review.body_top_rich_text %}">{{entry.review.body_top|render_markdown:entry.review.body_top_rich_text}}</pre>
{%  reply_section entry "" "body_top" "rcbt" %}

{%  if entry.comments.diff_comments or entry.comments.screenshot_comments or entry.comments.file_attachment_comments %}
   <dl class="review-comments">

{%   for comment in entry.comments.screenshot_comments %}
    <dt>
     <a class="comment-anchor" name="{{comment.anchor_prefix}}{{comment.id}}"></a>
     <div class="screenshot">
      <span class="filename">
       <a href="{{comment.screenshot.get_absolute_url}}">{% spaceless %}
{% if draft and comment.screenshot.draft_caption %}
{{comment.screenshot.draft_caption}}
{% else %}
{{comment.screenshot.caption|default_if_none:comment.screenshot.image.name|basename}}
{% endif %}
{% endspaceless %}</a>
      </span>
      {{comment.image|safe}}
     </div>
    </dt>
    <dd>
{%    comment_detail_display_hook comment "review" %}
     <pre class="reviewtext comment-text {% rich_text_classname comment.rich_text %}" id="{{comment.anchor_prefix}}{{comment.id}}">{{comment.text|render_markdown:comment.rich_text}}</pre>
{%    if comment.issue_opened %}
     <div class="issue-indicator">
       {% comment_issue review_request_details comment "screenshot_comments" %}
     </div>
{%    endif %}
{%    reply_section entry comment "screenshot_comments" "rc" %}
    </dd>
{%   endfor %}

{%   for comment in entry.comments.file_attachment_comments %}
    <dt>
     <a class="comment-anchor" name="{{comment.anchor_prefix}}{{comment.id}}"></a>
     <div class="file-attachment">
      <div class="file-attachment-comment-header">
       <a href="{{comment.get_absolute_url}}">
        <img src="{{comment.file_attachment.icon_url}}" />
        <span class="filename">{{comment.get_link_text}}</span>
       </a>
{%    if draft and comment.file_attachment.draft_caption %}
       <p class="caption">{{comment.file_attachment.draft_caption}}</p>
{%    elif comment.file_attachment.caption %}
       <p class="caption">{{comment.file_attachment.caption}}</p>
{%    endif %}
      </div>
{%    with comment.thumbnail as thumbnail %}
{%     if thumbnail %}
      <div class="thumbnail">{{thumbnail|default:''|safe}}</div>
{%     endif %}
{%    endwith %}
     </div>
    </dt>
    <dd>
{%    comment_detail_display_hook comment "review" %}
     <pre class="reviewtext comment-text {% rich_text_classname comment.rich_text %}" id="{{comment.anchor_prefix}}{{comment.id}}">{{comment.text|render_markdown:comment.rich_text}}</pre>
{%    if comment.issue_opened %}
     <div class="issue-indicator">
{%     comment_issue review_request_details comment "file_attachment_comments" %}
     </div>
{%    endif %}
{%    reply_section entry comment "file_attachment_comments" "rc" %}
    </dd>
{%   endfor %}

{%   for comment in entry.comments.diff_comments %}
    <dt>
     <a class="comment-anchor" name="{{comment.anchor_prefix}}{{comment.id}}"></a>
     <div id="comment_container_{{comment.id}}">
      <table class="sidebyside loading">
       <thead>
        <tr class="filename-row">
         <th class="filename">
          <a name="{{comment.get_absolute_url}}">{{comment.filediff.dest_file_display}}</a>
          <span class="diffrevision">
{%    if comment.interfilediff %}
           (Diff revisions {{comment.filediff.diffset.revision}} - {{comment.interfilediff.diffset.revision}})
{%    else %}
           (Diff revision {{comment.filediff.diffset.revision}})
{%    endif %}
          </span>
         </th>
        </tr>
       </thead>
       <tbody>
        <tr><td><pre>&nbsp;</pre></td></tr>{# header entry #}
{%    for i in comment.num_lines|default_if_none:1|range %}
        <tr><td><pre>&nbsp;</pre></td></tr>
{%    endfor %}
       </tbody>
      </table>
     </div>
    </dt>
    <dd>
{%    comment_detail_display_hook comment "review" %}
     <pre class="reviewtext comment-text {% rich_text_classname comment.rich_text %}" id="{{comment.anchor_prefix}}{{comment.id}}">{{comment.text|render_markdown:comment.rich_text}}</pre>
{%    if comment.issue_opened %}
     <div class="issue-indicator">
{%     comment_issue review_request_details comment "diff_comments" %}
     </div>
{%    endif %}
{%    reply_section entry comment "diff_comments" "rc" %}
    </dd>
{%   endfor %}
   </dl>
{%  endif %}
{%  if entry.review.body_bottom %}
   <pre class="body_bottom reviewtext {% rich_text_classname entry.review.body_bottom_rich_text %}">{{entry.review.body_bottom|render_markdown:entry.review.body_bottom_rich_text}}</pre>
{%   reply_section entry "" "body_bottom" "rcbb" %}
{%  endif %}
  </div>
 </div>
{% endbox %}
</div>
