{% extends "notifications/email_base.html" %}
{% load djblets_email djblets_utils markdown_email reviewtags %}

{% block content %}
{%  if changes and changes.status and review_request.status in "SD" %}
<table bgcolor="#e0e0e0" width="100%" cellpadding="12" style="border: 1px gray solid; border-radius: 6px; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
 <tr>
  <td>
   <h1 style="margin: 0; padding: 0; font-size: 10pt;">{% if review_request.status == 'S' %}This change has been marked as submitted.{% elif review_request.status == 'D' %}This change has been discarded.{% endif %}</h1>
  </td>
 </tr>
</table>
<br />
{%  endif %}

<table bgcolor="#fefadf" width="100%" cellspacing="0" cellpadding="12" style="border: 1px #888a85 solid; border-radius: 6px; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
 <tr>
  <td>

<div>Review request for {% reviewer_list review_request %}.</div>
<div>By {{review_request.submitter|realname}}.</div>

{%  if review_request.email_message_id %}
<p style="color: grey;"><em>Updated {{review_request.time_emailed}}</em></p>
{%  endif %}

{%  if change_text %}
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Changes</h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
 <tr>
  <td>
   <pre style="margin: 0; padding: 0; {{precss}}">{{change_text|markdown_email_html:change_rich_text}}</pre>
  </td>
 </tr>
</table>
{%  endif %}

{%  if changes %}{% if changes.summary %}
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Summary (updated)</h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
 <tr>
  <td>
   <pre style="margin: 0; padding: 0; {{precss}}">{{review_request.summary}}</pre>
  </td>
 </tr>
</table>
{%  endif %}{% endif %}

{%  if review_request.bugs_closed %}
<div style="margin-top: 1.5em;">
 <strong style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Bugs: </strong>
{%   if review_request.repository and review_request.repository.bug_tracker %}
{%    for bug in review_request.get_bug_list %}
 <a href="{{bug|bug_url:review_request}}">{{bug}}</a>{% if not forloop.last %}, {% endif %}
{%    endfor %}
{%   else %}
{{review_request.get_bug_list|join:", "}}
{%   endif %}
</div>
{%  endif %}

{%  if review_request.repository %}
<div style="margin-top: 1.5em;">
 <strong style="color: #575012; font-size: 10pt;">Repository: </strong>
{{review_request.repository.name}}
</div>
{%  endif %}

<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Description {% if changes %}{% if changes.description %} (updated){% endif %}{% endif %}</h1>
 <table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
 <tr>
  <td>
   <pre style="margin: 0; padding: 0; {{precss}}">{{review_request.description|markdown_email_html:review_request.description_rich_text}}</pre>
  </td>
 </tr>
</table>

{%  if review_request.testing_done != "" %}
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Testing {% if changes and changes.testing_done %}(updated){% endif %}</h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
 <tr>
  <td>
   <pre style="margin: 0; padding: 0; {{precss}}">{{review_request.testing_done|markdown_email_html:review_request.testing_done_rich_text}}</pre>
  </td>
 </tr>
</table>
{%  endif %}

{%  with review_request.get_latest_diffset as latest_diffset %}
{%   if latest_diffset %}
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Diffs</b> {% if changes and changes.diff %}(updated){% endif %}</h1>
<ul style="margin-left: 3em; padding-left: 0;">
{%    for filediff in latest_diffset.files.all %}
 <li>{{filediff.source_file_display}} <span style="color: grey">({{filediff.source_revision}})</span></li>
{%    endfor %}
</ul>

{%    with latest_diffset.revision as rev %}
<p><a href="{{domain_method}}://{{domain}}{% url 'view-diff-revision' review_request.display_id rev %}" style="margin-left: 3em;">View Diff</a></p>
{%     if rev > 1 and changes and changes.diff %}
<p><a href="{{domain_method}}://{{domain}}{% url 'view-interdiff' review_request.display_id rev|add:"-1" rev %}" style="margin-left: 3em;">Show Changes</a></p>
{%     endif %}
{%    endwith %}
{%   endif %}
{%  endwith %}


{%  if review_request.file_attachments.count %}
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">File Attachments {% if changes and changes.files %}(updated){% endif %}</h1>

{%   for file in review_request.file_attachments.all %}
 <li><a href="{{file.get_absolute_url}}">{{file.caption|default:file.filename}}</a></li>
{%   endfor %}
</ul>
{%  endif %}

{%  if review_request.screenshots.count %}
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Screenshots {% if changes and changes.screenshots %}(updated){% endif %}</h1>

<div>
{%   for screenshot in review_request.screenshots.all %}
 <a href="{{domain_method}}://{{domain}}{{screenshot.get_absolute_url}}"><img src="{{domain_method}}://{{domain}}{{screenshot.get_thumbnail_url}}" style="border: 1px black solid;" alt="{{screenshot.caption}}" /></a>
{%   endfor %}
</div>
{%  endif %}

  </td>
 </tr>
</table>
{% endblock content %}
