{% extends "submit/submit_base.html" %}
{% load submit_tags %}
{% block title %}Submission status{% endblock %}

{% block morecss %}
{{ block.super }}
div.metadata-errors { border: 1px solid red; background-color: #ffeebb; padding: 5px 10px; margin: 1em 0px; }
div.info-message-error { border: 1px solid red; background-color: #ffeebb; padding: 5px 10px; margin: 1em 0px; color: red; }
div.info-message-success { border: 1px solid green; background-color: #eeffbb; padding: 5px 10px; margin: 1em 0px; color: green; }
table.metadata-table th { white-space: nowrap; font-weight: bold; }
table.metadata-table #id_first_name, table.metadata-table #id_last_name { width: 200px; }
table.metadata-table #id_email { width: 400px; }
table.metadata-table th, table.metadata-table td { text-align: left; background: #ddddff; padding: 5px 10px; }
table.metadata-table th.author { text-align: right; }
table.metadata-table tr { vertical-align: top; }
table.metadata-table tr.warning td, table.metadata-table tr.warning th { background-color: #ffaaaa; }
table.metadata-table div.warn_message { color: red; }
table.metadata-table ul.errorlist { color: red; padding: 0px; margin: 0px; list-style-type: none; }
pre.twopages { margin: 0px; }
{% endblock morecss %}

{% block pagehead %}
<script type="text/javascript" src="/js/lib/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="/js/draft-submit.js"></script>
{% if can_cancel %}
<script type="text/javascript">
function confirmCancelation(){
  {% if is_valid %}if (!confirm("Cancel this submission?")) return false;{% endif %}
  return true;
}
</script>
{% endif %}

<script type="text/javascript">
(function ($) {

    $(document).ready(function () {
        var handleClose = function() {
            idnitsDialog.hide();
        };
    
        var buttons = [{text:"Close", handler:handleClose, isDefault:true}];
        var kl = [new YAHOO.util.KeyListener(document, {keys:27}, handleClose)]
        var idnitsDialog = new YAHOO.widget.Dialog("idnits_results", {
            visible:false, draggable:false, close:true, modal:true,
            width:"860px", fixedcenter:true, constraintoviewport:true,
            buttons: buttons, keylisteners:kl});
        idnitsDialog.render();
    
        var showIdnits = function() {
            $('#idnits_results').show();
            $('#idnits_title').show();
            $('#twopages_title').hide();
            $('pre.idnits_message').show();
            $('pre.twopages').hide();
            idnitsDialog.show();
            return false;
        }
    
        var showTwoPages = function() {
            $('#idnits_results').show();
            $('#idnits_title').hide();
            $('#twopages_title').show();
            $('pre.idnits_message').hide();
            $('pre.twopages').show();
            idnitsDialog.show();
            return false;
        }

        $('a.idnits_trigger').click(showIdnits);
        $('a.twopages_trigger').click(showTwoPages);
    });

})(jQuery);
</script>
{% endblock %}

{% block submit_content %}

{% if status %} 
<h2>Status of the submission: {{ status.status_value }}</h2> 
{% endif %} 

{% if message %} 
<div class="info-message-{{ message.0 }}">{{ message.1 }}</div> 
{% endif %}

{% if auto_post_form.errors %}
<div class="info-message-error">Please fix errors in the form below</div> 
{% endif %}

<h2>Check Page</h2>
<p>
{% if validation.passes_idnits %}
Your draft has been verified to meet IDNITS requirements.
{% else %}
Your draft has NOT been verified to meet IDNITS requirements.
{% endif %}
<a class="idnits_trigger" href="#">(View IDNITS Results)</a>
</p>
<div id="idnits_results" style="visibility:hidden; display: none;">
  <div class="hd">
    <span style="display: none;" id="idnits_title">Idnits results</span>
    <span style="display: none;" id="twopages_title">First two pages</span>
  </div>
  <div class="bd"> 
    <div id="stream_dialog_body" style="padding: 0em 5em; height: 400px; overflow: auto;">
      <pre class="idnits_message" style="display: none;">{{ detail.idnits_message }}</pre>
      {{ detail|two_pages_decorated_with_validation:validation }}
    </div>
  </div>
</div>


<h2>Meta-Data from the Draft</h2>
{% if validation.warnings %}
<div class="metadata-errors">
<h3>Meta-Data errors found</h3>
<p>
Please make sure that your Internet-Draft includes all of the required meta-data in the proper format.
</p>
<p>
If your Internet-Draft *does* include all of the required meta-data in the proper format, and if
the error(s) identified above are due to the failure of the tool to extract the meta-data correctly,
then please use the 'Adjust Meta-Data' button below, which will take you to the 'Adjust Screen' where
you can correct the improperly extracted meta-data. You will then be able to submit your Internet-Draft
to the Secretariat for manual posting.
</p>
<p>
If your Internet-Draft *does not* include all of the required meta-data in the proper format, then
please cancel this submission, update your Internet-Draft, and resubmit it.
</p>
<p>
<strong>NOTE:</strong> The Secretariat will NOT add any meta-data to your Internet-Draft or edit the meta-data. An
Internet-Draft that does not include all of the required meta-data in the proper format WILL be
returned to the submitter.
</p>
</div>
{% endif %}

<table class="metadata-table">
<tr{% if validation.warnings.document_files %} class="warning"{% endif %}>
   <th>Document</th>
   <td>
      {% ifequal status.status_value "Posted" %}<a href="http://www.ietf.org/id/{{ detail.filename }}-{{detail.revision}}.txt">{{ detail.filename }}</a>{% else %}{{ detail.filename }}{% endifequal %}
      <br/><a class="twopages_trigger" href="#">[View first two pages]</a>
      {% show_submission_files detail %}
      <div class="warn_message">{{ validation.warnings.document_files|safe }}</div>
   </td>
</tr>
<tr{% if validation.warnings.revision %} class="warning"{% endif %}><th>Revision</th><td>{{ detail.revision }}<div class="warn_message">{{ validation.warnings.revision }}{% if validation.warnings.revision %}<br /><a class="twopages_trigger" href="#">[View error]</a>{% endif %}</div></td></tr>
<tr{% if validation.warnings.group %} class="warning"{% endif %}><th>WG</th><td>{{ validation.wg|default:"Individual Submission" }}<div class="warn_message">{{ validation.warnings.group }}</div></td></tr>
<tr{% if validation.warnings.creation_date %} class="warning"{% endif %}><th>Document date</th><td>{{ detail.creation_date }}<div class="warn_message">{{ validation.warnings.creation_date }}</div></td></tr>
<tr><th>Submission date</th><td>{{ detail.submission_date }}</td></tr>
<tr{% if validation.warnings.title %} class="warning"{% endif %}><th>Title</th><td>{{ detail.id_document_name|default:"" }}<div class="warn_message">{{ validation.warnings.title }}</div></td></tr>
<tr{% if validation.warnings.authors %} class="warning"{% endif %}><th colspan="2">Author information</th></tr>
{% if validation.warnings.authors %}
<tr class="warning"><td colspan="2"><div class="warn_message">{{ validation.warnings.authors|safe }}</div></td></tr>
{% endif %}
{% if validation.authors %}
{% for author in validation.authors %}
<tr{% if validation.warnings.authors %} class="warning"{% endif %}><th class="author">Author {{ forloop.counter }}</th><td>{{ author.get_full_name }} {% if author.email.1 %}&lt;{{ author.email.1 }}&gt;{% endif %}</td></tr>
{% endfor %}
{% endif %}
<tr{% if validation.warnings.abstract %} class="warning"{% endif %}><th>Abstract</th><td>{{ detail.abstract|linebreaksbr }}<div class="warn_message">{{ validation.warnings.abstract }}</div></td></tr>
<tr{% if validation.warnings.pages %} class="warning"{% endif %}><th>Pages</th><td>{{ detail.txt_page_count }}<div class="warn_message">{{ validation.warnings.pages }}</div></td></tr>
<tr><th>File size</th><td>{{ detail.filesize|filesizeformat }}</td></tr>
</table>

{% if allow_edit %} 
  <form method="post" action="">
  <input type="submit" value="Adjust Meta-Data" value="adjust" /> (Leads to manual post by the Secretariat) 
  </form>

  {% if is_valid %} 
    <h2>Please edit the following meta-data before proceeding to Auto-Post</h2> 
    <p> 
    If you are one of the authors of this document, then please click the button with your name on it to automatically fill in the submitter information as requested below. Otherwise, please manually enter your information. 
    </p> 
    <form method="post" action=""> 
    {{ auto_post_form.get_author_buttons|safe }} 
    <table class="metadata-table"> 
    {{ auto_post_form }} 
    </table> 
    <input type="submit" value="Post" name="autopost" /> 
    </form> 
  {% endif %} 


{% else %}
  {% if validation.submitter %} 
    <h3>Submitter information</h3> 
    <table class="metadata-table"> 
    <tr><th>First name</th><td>{{ validation.submitter.first_name }}</td></tr> 
    <tr><th>Last name</th><td>{{ validation.submitter.last_name }}</td></tr> 
    <tr><th>Email address</th><td>{{ validation.submitter.email_address|default:validation.submitter.email.1 }}</td></tr> 
    </table> 
  {% endif %} 
{% endif %}

{% if can_cancel %}
  <h2>Cancel submission</h2>
  <p>
    <form method="post" onsubmit="return confirmCancelation();" action="{% url draft_cancel_by_hash detail.submission_id submission_hash %}">
      <input type="submit" value="Cancel Submission" /><br>
    </form>
     This submission will be canceled, and its uploaded document(s) permanently deleted.
  </p>
{% endif %}

{% if can_approve %}
<p>
  <form method="post" action="/submit/status/{{ detail.submission_id }}/approve/">
    <input type="submit" value="Approve this submission" />
  </form>
</p>
{% endif %}
 
{% if can_force_post %}
<p>
  <form method="post" action="/submit/status/{{ detail.submission_id }}/force/">
    <input type="submit" value="Force post" />
  </form>
</p>
{% endif %}
 
{% if show_notify_button %}
<div class="metadata-errors">
<p>
You are not allowed to modify or cancel this submission. You only can modify or cancel this submission from the same URL you were redirected to after the submission.
</p>
<p>
If you are the submitter check your browser history to find this url. You can share it with any person you need.
</p>
<p>
If you are one of the authors you can request the URL from wich you can modify or cancel this submission by clicking the next button. An email will be sent to the draft authors and to the submitter (if the submitter's email is available).
</p>
<form method="post" action="{% url full_url_request detail.submission_id %}">
<input type="submit" value="Request full access URL" />
</form>
</div>
{% endif %}
<p>
The IETF is an organized activity of the <a href="http://www.isoc.org">Internet Society</a>
<br>Please send problem reports to <a href="mailto:ietf-action@ietf.org">ietf-action@ietf.org</a>.
</p>
{% endblock %}
