{% extends "projects/project_detail_childs.html" %}
{% load i18n %}
{% load permissions %}
{% load txcommontags %}
{% load addons %}
{% block extra_head %}
  <script type="text/javascript" src="{{ STATIC_URL }}js/tablesorted.js"></script>
  <script type="text/javascript" src="{{ STATIC_URL }}js/jquery.qtip-1.0.0-rc2.min.js"></script>
  <link media="screen" href="{{ STATIC_URL }}css/tablesorter.css" type="text/css" rel="stylesheet" />
  <script type="text/javascript">
  $(document).ready(function() { 
      $(".tablesorter").tablesorter(); 
  }); 
  </script>
  <script type="text/javascript" src="{{ STATIC_URL }}js/houdini.js"></script>
  <link media="screen" href="{{ STATIC_URL }}css/houdini.css" type="text/css" rel="stylesheet" />

{% endblock %}

{% block title %}{% with component.project as project %}{{ block.super }} | {{ component.name }} | {% trans "Reviews" %}{% endwith %}{% endblock %}

{% block breadcrumb %}{% with component.project as project %}{{ block.super }} &raquo; <a href="{% url component_detail component.project.slug component.slug %}">{{ component.name }}</a> &raquo; {% trans "Reviews" %}{% endwith %}{% endblock %}


{% block content_title %}
<h2 class="pagetitle">{% trans "Translation Review Requests" %}</h2>
{% endblock %}

{% block content_main %}
  <h2>{% trans "Open Requests" %}</h2>

{% for review in component.reviews.open_reviews.all %}
<div id="review-{{review.id}}" class="separate">
{% with review.id as review_id %}

{% get_permission "project_perm.submit_file" for request.user and review.team as "can_submit_file" %}

<h3>{% blocktrans %}Review Request #{{ review_id }} {% endblocktrans %}</h3>    
 <table class="definition">
  <tbody>
    <tr>
      <th class="i16 filter">{% trans "Description" %}</th>
      <td>{{ review.description }}</td>
    </tr>
    <tr>
      <th class="i16 release">{% trans "Who and when" %}</th>
      <td>
      <a href="{% url profile_public review.author %}" title="{% trans "See profile" %}">{{ review.author }}</a>,
      {% blocktrans with review.created_on|timesince as time_since %}
        {{ time_since }} ago
      {% endblocktrans %}
      </td>
    </tr>
    <tr>
      <th class="i16 team">{% trans "Translation Language" %}</th>
      <td>
        {% if review.language %}
            <a href="{% url language_detail review.language.code %}" title="{% trans "Go to language page" %}" >{{ review.language }}</a>
        {% else %}
            {{ review.lang_code }}
        {% endif %}
      </td>
    </tr>
    <tr>
      <th class="i16 submit_file">{% trans "File target" %}</th>
      <td><a href="{{ review.file_url }}" title="{% trans "Download the version sent for review" %}" >{{ review.target_filename }}</a></td>
    </tr>
    <tr>
      <th class="i16 star">{% trans "Score" %}</th>
      <td>
        <span>{{ review.score }}</span>
        {% if perms.reviews.add_poreviewrequest or perms.reviews.change_poreviewrequest or can_submit_file %}
        <form action="{% url review_like review.id %}" method="post" style="diplay:inline;float:right">
            <input type="image" src="{{ STATIC_URL }}images/icons/thumb_down.png" name="dislike" value="dislike" style="border:0">
        </form>
        <form action="{% url review_like review.id %}" method="post" style="diplay:inline;float:right">
            <input type="image" src="{{ STATIC_URL }}images/icons/thumb_up.png" name="like" value="like" style="border:0">
        </form>
        {% endif %}
      </td>
    </tr>
    <tr>
      <th class="i16 status">{% trans "Status" %}</th>
      <td>
        {{ review.get_status_display }}
        {% ifnotequal review.resolution 'N' %}({{ review.get_resolution_display }}){% endifnotequal %}
      </td>
    </tr>
{% if review.is_open %}
 {% if perms.reviews.change_poreviewrequest or can_submit_file %}
    {% url review_modify review.component.project.slug review.component.slug review.id as modify_url %}
    <tr>
      <th class="i16 reviews">{% trans "Close Review" %}</th>
      <td>
        <form action="{{ modify_url }}" class="microform" method='post'>
          <input class="i16 tick" title="{% trans "Accept and submit translation" %}"  value="{% trans "Accept" %}" type="submit" name="accept">
          <input class="i16 delete" title="{% trans "Reject translation" %}"  value="{% trans "Reject" %}" type="submit" name="reject">
        </form>
      </td>
    </tr>
 {% endif %}
{% endif %}
  </tbody>
</table>

{% hook "review.html" listitem_extra %}

{% endwith %}
</div>
{% endfor %}

{% if not component.reviews.open_reviews %}
  <p>{% trans "No open requests!" %}</p>
{% endif %}


<h2>{% trans "Closed Requests" %}</h2>

{% if component.reviews.closed_reviews.all %}
<table class="tablesorter">
  <thead>
    <tr>
      <th>{% trans "ID" %}</th>
      <th>{% trans "Author" %}</th>
      <th>{% trans "Language" %}</th>
      <th>{% trans "Time Since" %}</th>
      <th>{% trans "Resolution" %}</th>
      <th>{% trans "Attachment" %}</th>
      <th>{% trans "Actions" %}</th>
    </tr>
  </thead>
  <tbody>
{% for review in component.reviews.closed_reviews.all %}
{% with review.id as review_id %}
  <tr>
    <td{% if review.is_closed %} style="text-decoration: line-through;"{% endif %}>{{ review_id }}</td>
    <td>{{ review.author }}</td>
    <td> &nbsp;
        {% if review.language %}
            {{ review.language }}
        {% else %}
            {{ review.lang_code }}
        {% endif %} &nbsp;
    </td>
    <td>&nbsp; {{ review.created_on|timesince }} &nbsp;&nbsp;</td>
    <td> {{ review.get_resolution_display }} </td>
    <td><a href="{{ review.file_url }}">{{ review.full_review_filename }}</a></td>
    <td>
     {% get_permission "project_perm.submit_file" for request.user and review.team as "can_submit_file" %}
     {% if perms.reviews.change_poreviewrequest or can_submit_file %}
      {% url review_modify review.component.project.slug review.component.slug review.id as modify_url %}
      <form class="microform" action="{{ modify_url }}" method='post'>
       <input class="i16 redo" title="{% trans "Reopen review request" %}"  value="Reopen" type="submit" name="reopen" type="image">
      </form>
     {% endif %}
    </td>
  </tr>
{% endwith %}
{% endfor %}
</tbody>
</table>
{% endif %}

{% if not component.reviews.closed_reviews.all %}
  <p>{% trans "No closed requests!" %}</p>
{% endif %}

{% endblock %}
