{% load url from future %}
{% load translations %}
{% load i18n %}
{% load crispy_forms_tags %}

<div class="row">
<div class="col-lg-6">
<table class="table table-condensed table-striped">
<thead>
<tr>
<th>{% trans "Language" %}</th>
<th>{% trans "Status" %}</th>
<th>{% trans "Checks" %}</th>
<th>{% trans "Edit" %}</th>
</tr>
</thead>
<tbody>
{% for unit in units %}
<tr>
<th>{{ unit.translation.language }}</th>
<td>{% get_state_flags unit %}</td>
<td>{% show_checks unit.checks user %}</td>
<td><a href="{{ unit.get_absolute_url }}" class="button small-button">{% trans "Edit" %}</a></td>
</tr>
{% endfor %}
</tbody>
</table>
</div>

<div class="col-lg-6">
<table class="table table-condensed">
{% if perms.edit_check_flags %}
<tr>
<td>
<div class="btn-group pull-right flip">
  <button type="button" class="btn btn-default btn-xs dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
    {% trans "Add" %} <span class="caret"></span>
  </button>
  <ul class="dropdown-menu" role="menu">
    {% for flag in extra_flags %}
    <li><a href="#" data-flag="{{ flag.0 }}">{{ flag.1 }}</a></li>
    {% endfor %}
    <li class="divider"></li>
    {% for flag in check_flags %}
    <li><a href="#" data-flag="{{ flag.0 }}">{% blocktrans with flag.1 as check %}Ignore: {{ check }}{% endblocktrans %}</a></li>
    {% endfor %}
  </ul>
</div>
<form method="POST" action="{% url 'edit_check_flags' pk=source.pk %}">
{% csrf_token %}
<input type="hidden" name="next" value="{{ next }}" />
{{ check_flags_form|crispy }}

<input type="submit" value="{% trans "Save" %}" class="btn btn-default" />
</form>
</td>
</tr>
{% endif %}
{% if perms.edit_priority %}
<tr>
<td>
<form method="POST" action="{% url 'edit_priority' pk=source.pk %}">
{% csrf_token %}
<input type="hidden" name="next" value="{{ next }}" />
{{ priority_form|crispy }}
<input type="submit" value="{% trans "Save" %}" class="btn btn-default" />
</form>
</td>
</tr>
{% endif %}
{% with units.0 as unit %}
{% include "unit-details.html" %}
{% with unit.get_source_comments as comments %}
{% if comments %}
<tr>
<th>{% trans "User comments" %}</th>
</tr>
<tr>
<td>
{% include "list-comments.html" %}
</td>
</tr>
{% endif %}
{% endwith %}
{% endwith %}
</table>
</div>

</div>
