{% load djblets_utils i18n reviewtags %}

<div id="review_request_banners">

{% if review_request.status == 'S' %}
 <div class="banner" id="submitted-banner">
  <h1>{% trans "This change has been marked as submitted." %}</h1>
{%  if request.user.pk == review_request.submitter_id or perms.reviews.can_change_status %}
  <input type="submit" id="btn-review-request-reopen"
         value="{% trans "Reopen for Review" %}" />
  <p><label for="field_changedescription">{% trans "Describe the submission (optional):" %}</label></p>
  <pre id="field_changedescription" class="field field-text-area editable {% rich_text_classname close_description_rich_text %}" data-field-id="field_changedescription">{{close_description|render_markdown:close_description_rich_text}}</pre>
{%  elif close_description %}
  <pre id="field_changedescription" class="field field-text-area {% rich_text_classname close_description_rich_text %}" data-field-id="field_changedescription">{{close_description|render_markdown:close_description_rich_text}}</pre>
{%  endif %}
 </div>

{% elif review_request.status == 'D' %}
 <div class="banner" id="discard-banner">
  <h1>{% trans "This change has been discarded." %}</h1>
{%  if request.user.pk == review_request.submitter_id or perms.reviews.can_change_status %}
  <input type="submit" id="btn-review-request-reopen"
         value="{% trans "Reopen for Review" %}" />
  <p><label for="field_changedescription">{% trans "Describe the reason it's discarded (optional):" %}</label></p>
  <pre id="field_changedescription" class="field field-text-area editable {% rich_text_classname close_description_rich_text %}" data-field-id="field_changedescription">{{close_description|render_markdown:close_description_rich_text}}</pre>
{%  elif close_description %}
  <pre id="field_changedescription" class="field field-text-area {% rich_text_classname close_description_rich_text %}" data-field-id="field_changedescription">{{close_description|render_markdown:close_description_rich_text}}</pre>
{%  endif %}
 </div>

{% else %}{# pending review #}
{%  if request.user.pk == review_request.submitter_id or perms.reviews.can_edit_reviewrequest %}
 <div class="banner" id="draft-banner" style="display:none;">
{%   if review_request.public %}
  <h1>{% trans "This review request is a draft." %}</h1>
 {% trans "Be sure to publish when finished." %}
  <input type="button" id="btn-draft-publish"
         value="{% trans "Publish Changes" %}" />
  <input type="button" id="btn-draft-discard"
         value="{% trans "Discard Draft" %}" />
  <p><label for="field_changedescription">{% trans "Describe your changes (optional):" %}</label></p>
{%    if draft.changedesc %}
  <pre id="field_changedescription" class="field field-text-area editable {% rich_text_classname draft.changedesc.rich_text %}" data-field-id="field_changedescription">{{draft.changedesc.text|render_markdown:draft.changedesc.rich_text}}</pre>
{%    else %}
  <pre id="field_changedescription" class="field field-text-area editable" data-field-id="field_changedescription"></pre>
{%    endif %}
{%    if draft.diffset %}
  <p>{% trans "This draft adds a new diff." %} <a href="{% url 'view-interdiff' review_request.display_id draft.diffset.revision|add:"-1" draft.diffset.revision %}">{% trans "Show changes" %}</a></p>
{%    endif %}
{%   else %}
  <h1>{% trans "This review request is not yet public." %}</h1>
 {% trans "Be sure to publish when finished." %}
  <input type="button" id="btn-draft-publish"
         value="{% trans "Publish" %}" />
  <input type="button" id="btn-review-request-discard"
         value="{% trans "Discard Review Request" %}" />
{%   endif %}
 </div>
{%  endif %}
{% endif %}
</div>

{% if request.user.pk == review_request.submitter_id or perms.reviews.can_edit_reviewrequest and review_request.status == 'P'%}
{%  if draft or not review_request.public %}
<script type="text/javascript">
  $("#draft-banner").show();
</script>
{%  endif %}
{% endif %}
