{% extends "projects/project_detail_childs.html" %}
{% load cache %}
{% load markup %}
{% load i18n %}
{% load truncate %}
{% load statistics_resources %}
{% load permissions %}
{% load txpermissions %}

{% block extra_head %}
  <link rel="alternate" type="application/rss+xml" title="RSS" href="{% url release_feed release.project.slug release.slug %}" />
  <script type="text/javascript" src="{{ STATIC_URL }}js/tablesorted.js"></script>
  <link media="screen" href="{{ STATIC_URL }}css/tablesorter.css" type="text/css" rel="stylesheet" />
  <script type="text/javascript">
    $(function(){
        // Enable tooltip
        $(".tipsy_enable").tipsy({'html':true, 'gravity':'s'});

        // Stats table sorter
        $(".tablesorter_release_list").tablesorter({
            sortList: [[1,1]],
            widgets: ['zebra'],
            textExtraction: { // Take value inside an object for the columns
              0: function(node) {
                  return $("a", node).text();
              },
              1: function(node) {
                  return $(".origin_format", node).text();
              }
            }
        });

        // Toggle to resources list
        $("#resource-list-toggler").click(function () {
            $("#resource-list").slideToggle("slow");
        });
    });
  </script>
{% endblock %}

{% block body_class %}{{ block.super }} release_detail{% endblock %}

{% block title %}{{ block.super }} | Release '{{ release.name }}'{% endblock %}

{% block breadcrumb %}{{ block.super }} &raquo; Release '{{ release.name }}'{% endblock %}

{% block content_sec %}
  <a class="simlink" href="{% url release_feed release.project.slug release.slug %}" title="Statistics feed for this release"><img border="0" src="{{ STATIC_URL }}images/icons/feed.png" /></a>
{% endblock %}

{% block content_main %}
  <div class="obj_bigdetails">
  <h2 class="pagetitle">{{ release.project.name }}</h2>
  <h3 class="pagesubtitle">Release '{{ release }}'</h3>

  {% if release.description %}<p class="description">{{ release.description }}</p>{% endif %}

  {% with release.long_description_html as long_desc %}
  {% if long_desc %}
  <div class="long_description">
    {{ long_desc|truncatewords:"100"|safe }}
  </div>
  {% endif %}
  {% endwith %}

  {% get_permission "project_perm.maintain" for request.user and release.project as "is_maintainer" %}
  {% if perms.projects.add_release or is_maintainer %}
    <div class="editlinks">
      <p><a class="i16 edit buttonized" href="{% url release_edit project_slug=release.project.slug release_slug=release.slug %}">{% trans "Edit" %}</a></p>
    </div>
  {% endif %}

  <div class="details">

  {% if release.homepage or release.release_date %}
  <h4>{% blocktrans %}Details{% endblocktrans %}</h4>
  {% endif %}
  <table class="definition">
    <tr {% if not release.homepage %}class="empty {% if not request.user.is_authenticated %}nodisplay{% endif %}"{% endif %}>
      <th class="homepage i16">{% trans "Homepage:" %}</th>
      <td><a href="{{ release.homepage }}">{{ release.homepage }}</a></td>
    </tr>
    <tr class="separator"></tr>
    <tr class="{% if not release.release_date %}empty {% if not request.user.is_authenticated %}nodisplay{% endif %}{% endif %}">
      <th class="release_date i16">{% trans "Release date:" %}</th>
      <td>{{ release.release_date|date:"D d M Y" }}</td>
    </tr>
    <tr {% if not release.stringfreeze_date %}class="empty {% if not request.user.is_authenticated %}nodisplay{% endif %}"{% endif %}>
      <th class="freeze i16">{% trans "String freeze:" %}</th>
      <td>{{ release.stringfreeze_date|date:"D d M Y" }}</td>
    </tr>
    <tr {% if not release.develfreeze_date %}class="empty {% if not request.user.is_authenticated %}nodisplay{% endif %}"{% endif %}>
      <th class="freeze i16">{% trans "Devel freeze:" %}</th>
      <td>{{ release.develfreeze_date|date:"D d M Y" }}</td>
    </tr>
    <tr class="separator"></tr>
    <tr>
      <th class="resource i16">{% trans "Resources:" %}</th>
      <td>
        {% with release.resources.all|dictsort:"project.slug"|dictsort:"slug" as resource_list %}
        {% with resource_list|length as resources_number %}
        <span id="resource-list-toggler" class="buttonized_simple" title="{% trans "Click here to show or hide the resource list" %}">
        {% blocktrans %}This release has {{ resources_number }} resources.{% endblocktrans %}
        </span>
        <ul id="resource-list" class="simple links" style="display:none;">
          {% for r in resource_list %}
            <li><a title="{% firstof r.description|escape r.name|escape %}" href="{{ r.get_absolute_url }}">{{ r }}</a></li>
          {% endfor %}
        </ul>
        {% endwith %}
        {% endwith %}
      </td>
    </tr>
  </table>
</div>

<div id="projects" class="projects">

<h3>{% trans "Translation Statistics" %}</h3>

<div class="list separate clear">
<table class="stat_table_font stats_table highlighted tablesorter_resource tablesorter_release_list" style="clear:both;margin-top:0.5em;width:100%">
  <thead>
  <tr>
    <th><span class="i16 comment">{% trans "Language" %}</span></th>
    <th style="width:320px"><span class="i16 stats">{% trans "Completion" %}</span></th>
    <th><span class="i16 clock">{% trans "Last Translation" %}</span></th>
   </tr>
  </thead>
  <tbody>
{% for stat in statslist.language_stats %}
    <tr id="stat_row_{{forloop.counter}}" class="nocursor">

      {% cache 604799 release_details release.id stat.language.id LANGUAGE_CODE%}
        <td>
          {{ stat.language.name }} 
          <span class="locale">(<a href="{% url release_language_detail release.project.slug release.slug stat.language.code %}">{{ stat.language.code }}</a>)</span>
          </td>
        <td>
          {% with 200 as barwidth %}
            <div class="stats tipsy_enable" style='width:{{ barwidth|add:"40" }}px;' title="{% trans "Translated: " %}{{ stat.num_translated }}<br />{% trans "Untranslated: " %}{{ stat.num_untranslated }}">
                <div class="stats_string_resource" >
                    {{ stat.trans_percent }}% 
                </div> 
                {% stats_bar_simple stat barwidth %}
            </div>
          {% endwith %}
        </td>

        <td>
        <span style="border:0">
          {% with stat.last_update as last_update %}
          {% with stat.last_committer as last_committer %}
          {% if last_update %}
              <span class="origin_format" style="display:none">{{ last_update|date:"M d,Y h:i A" }}</span>
              {{ last_update|date:"M d, h:ia" }}
              {% if last_committer %}
              by {{ last_committer }}
              {% endif %}
          {% else %}
              {% trans "no translations yet" %}
          {% endif %}
          {% endwith %}
          {% endwith %}
        </span>
        </td>
	  {% endcache %}
    </tr>
{% endfor %}
  </tbody>
</table>
</div>

</div>
</div>
{% endblock %}{# body_main #}

{% block content_footer %}
  <div id="content_footer_center">
    {% if request.user.is_authenticated and perms.projects.delete_release %}
    <div class="deletelink">
      <a class="i16 delete buttonized" href="{% url release_delete release.project.slug release.slug %}">{% trans "Delete release" %}</a>
    </div>
    {% endif %}
  </div>
{% endblock %}
