{% extends "projects/project_menu.html" %}
{% load i18n %}
{% load pagination_tags %}
{% load txcommontags %}
{% load permissions %}
{% load txpermissions %}

{% block title %}{{ block.super }} | {{ project.name }} | {% trans "Access Control" %}{% endblock %}

{% block breadcrumb %}{{ block.super }} &raquo; {{ project.name }}{% endblock %}

{% block content_main %}

<div class="obj_bigdetails">
<h2 class="name">{% trans "Access Control" %}</h2>

{% get_permission "project_perm.submit_file" for request.user and project as "can_submit_file" %}
{% get_permission "project_perm.maintain" for request.user and project as "is_maintainer" %}
{% get_permission_request "project_perm.submit_file" for request.user and project as "can_submit_file_request" %}

<div class="project_create generic_form">

{% if not project.anyone_submit and not project.outsource %}
<div class="separate">

<p class="description">{% trans "Give write access to a translator to send translations to your project independent of a translation team." %}</p>

{% if form and not can_submit_file_request %}
    {% include "txpermissions/permission_form.html" %}
{% else %}
    {% txpermission_form for project using "project_perm.submit_file" %}
{% endif %}
</div>


{% get_permission_requests project as "all_permission_requests" %}
{% if all_permission_requests %}
<div class="list separate ">
<h4>{% trans "Pending requests:" %}</h4>
<ul>
{% for perm in all_permission_requests|dictsort:"user.username" %}
    <li class="i16 user">
        <a class="name" href="{% url profile_public perm.user.username %}">{{ perm.user }}</a>
        {% if can_submit_file %}
          <span>- {{perm.user.email|mungify}}</span>
        {% endif %}
        {% txpermission_request_approve_form project perm %} 
        {% txpermission_request_delete_form project perm %}
    </li>
{% endfor %}
</ul>
</div>
{% endif %}

{% get_permissions project as "all_permissions" %}
{% if all_permissions %}
{% autopaginate all_permissions 20 %}
<div class="list separate">
<h4>{% trans "Users with access to submit files:" %}</h4>
<ul>
{% for perm in all_permissions|dictsort:"user.username" %}
    <li>
        <a class="name" href="{% url profile_public perm.user.username %}">{{ perm.user }}</a> 
        {% if can_submit_file %}
          <span>- {{perm.user.email|mungify}}</span>
        {% endif %}
        {% txpermission_delete_form project perm %}
    </li>
{% endfor %}
</ul>
<div class="pagination bottom">{% paginate %}</div>
</div>
{% endif %}

{% endif %}

</div>
{% endblock %}

