{% load i18n %}
{% load statistics %}
{% load permissions %}
{% url component_toggle_lock_file pofile.object.project.slug pofile.object.slug pofile.filename as toggle_lock_url %}
{% with pofile.locks.get.owner as owner %}
{% get_permission "project_perm.maintain" for request.user and pofile.object.project as "is_maintainer" %}
{% if pofile.locked %}
  {% ifequal request.user.username owner.username %}
    <form action="{{ toggle_lock_url }}" method="POST" class="microform">
        <input id="po-{{pofile.id}}" class="i16 lock_break nodecoration_icon image_submit_type" value="" type="image">
    </form>
    <span class="stat_message">(you)</span>
    <script type="text/javascript">
      tooltip("#po-{{pofile.id}}",
              "{% trans 'Unlock this file when you are finished working with it.' %}<br /><span class=\"i16 actionlog\">Date locked:</span> {{pofile.locks.get.created|date:"d M Y H:i:s"}}");
    </script>
  {% else %}
    <span id="po-{{pofile.id}}" class="i16 lock nodecoration_icon" href="{{ toggle_lock_url }}"></span>
    <script type="text/javascript">
      tooltip("#po-{{pofile.id}}",
              "{% blocktrans %}User '{{ owner }}' has locked this file indicating he's working on it.{% endblocktrans %}<br /><span class=\"i16 actionlog\">Date locked:</span> {{pofile.locks.get.created|date:"d M Y H:i:s"}}");
    </script>
  {% endifequal %}
{% else %}
  {% if perms.translations.add_pofilelock or can_submit_file or is_maintainer %}
   <form action="{{ toggle_lock_url }}" method="POST" class="microform">
        <input title="{% trans "Lock this file to notify others you're working with it." %}" class="i16 lock_none nodecoration_icon image_submit_type" value="" type="image">
    </form>
  {% else %}
    <span class="i16 lock_none nodecoration_icon" title="{% trans "This file is unlocked. Most likely no one is working with it right now." %}" href="{{ toggle_lock_url }}"></span>
  {% endif %}
{% endif %}
{% endwith %}
