{% extends "base.html" %}
{% load i18n %}
{% load dateconv %}

{% block content %}
<div class="container">

        <ul class="breadcrumb">
            <li><a href="{% url "containerview" %}">Containers</a></li> 
            <li><span class="divider">/</span>Add ACL to container {{container}}</li>
       </ul> 
        
    {% include "messages.html" %}
    {% include "addacl_modal.html" %}

    {% if public %}
    <div class="alert alert-info">
        <strong>URL for this public readable container: <u>
            <a href="{{ base_url }}{% url "public_objectview" account=account container=container %}" target="new">
                {{ base_url }}{% url "public_objectview" account=account container=container %}
            </a>
        </strong>
    </div>
    {% endif %}


    <table class="table table-striped">

    <thead>
   
    <tr>
        <th style="width: 1em;" class="hidden-phone"></th>
        <th>Name</th>
        <th style="width: 7.5em;"></th>
        <th style="width: 1em;">


            <div class="dropdown pull-right">
                        <a class="dropdown-toggle btn btn-mini btn-danger" data-toggle="dropdown"><i class="icon-chevron-down icon-white"></i></a>
                        <ul class="dropdown-menu">
                            <li>
                            {% if not public %}
                                <form method="POST" action="{% url "edit_acl" container=container %}" id="mkpublic"> 
                                    {% csrf_token %}
                                    <input name="username" type="hidden" value=".r:*,.rlistings">
                                    <input name="read" type="hidden" value="On">
                                </form>
                                <a href="#" onclick="mkpublic.submit()"><i class="icon-eye-open"></i> Make public</a>
                            {% else %}
                                <a href="{% url "edit_acl" container=container%}?delete=.r:*,.rlistings"><i class="icon-eye-close"></i> Make private</a>
                            {% endif %}
                            </li>
                            <li class="divider" />
                            <li><a href="#addacl_modal" data-toggle="modal"><i class="icon-user"></i> Add ACL</a></li>
                        </ul>
                    </div>

        </th>
    </tr>
    </thead>
 
    <tbody>
    {% for user, permission in acls.items %}
            <tr>
                <td class="hidden-phone"><i class="icon-user"></i></td>
                <td>
                {% if user == ".rlistings" %}
                    {{user}} <a href="#" data-toggle="tooltip" title="This entry allows the listing of objects and is required for public readable containers."><i class=" icon-question-sign"></i></a>
                {% elif user == ".r:*" %}
                    {{user}} <a href="#" data-toggle="tooltip" title="This entry allows the download of objects and is required for public readable containers."><i class=" icon-question-sign"></i></a>
                {% else %}
                {{user}}
                {% endif %}
                
                </td>
        
                <td style="text-align:right;">
                    {% if permission.read %}
                        <a class="btn btn-mini btn-success">Read</a> 
            {% endif %}
            {% if permission.write %}
                <a class="btn btn-mini btn-danger">Write</a> 
            {% endif %}
        </td>

         <td>
            <a class="btn btn-mini btn-danger" href="{% url "edit_acl" container=container%}?delete={{ user }}"><i class="icon-trash icon-white"></i></a>
        </td>
        </tr> 
    
    {% empty %}
        <tr>
            <td colspan="5">
            <strong><center>There are no ACLs for this container yet. Add a new ACL by clicking the red button.<center></strong>
            </td>
        </tr> 
    {% endfor %}
    </tbody> 
    </table>
    </div>
    </div>
{% endblock %}

    {% block jsadd %} 
<script type="text/javascript">
    $(document).ready(function () {
        $("a").tooltip({
        'selector': '',
        'placement': 'bottom'
        });
    });
</script>

{% endblock %}
