{% load i18n %}
{% load lfc_tags %}

<h2 class="first-heading">
    {% trans 'Permissions' %}
</h2>

{% ifportalhasperm manage_portal %}
    <form action="{% url 'lfc_update_portal_permissions' %}"
          method="post">

        <table class="lfs-manage-table full">
            <tr>
                <th class="middle">{% trans "Permission" %}</th>
                {% for role in roles %}
                    <th class="middle">{% trans role.name %}</th>
                {% endfor %}
            </tr>
            {% for permission in permissions %}
                <tr>
                    <td>{% trans permission.name %}</td>
                    {% for role in permission.roles %}
                        <td><input type="checkbox" name="permission" value="{{ role.id }}|{{ permission.codename }}" {% if role.has_permission %}checked="checked"{% endif %}/></td>
                    {% endfor %}
                </tr>
            {% endfor %}
        </table>

        <input class="ajax-submit"
               type="submit" name="paste" value="{% trans 'Save permissions' %}" />
    </form>
{% else %}
    <table class="lfs-manage-table full">
        <tr>
            <th class="middle">{% trans "Permission" %}</th>
            {% for role in roles %}
                <th class="large">{% trans role.name %} </th>
            {% endfor %}
        </tr>
        {% for permission in permissions %}
            <tr {% if permission.is_wf_permission %}class="wf_permission"{% endif %}>
                <td class="permission emphasized">{% trans permission.name %}</td>
                {% for role in permission.roles %}
                    <td>
                        {% if role.has_permission %}
                            <img src="{{ STATIC_URL }}icons/tick.png" alt='{% trans "Yes" %}' title='{% trans "Yes" %}'/>
                        {# {% else %} #}
                        {#     <img src="{{ STATIC_URL }}icons/cross.png" alt='{% trans "No" %}'  title='{% trans "No" %}' /> #}
                        {% endif %}
                    </td>
                {% endfor %}
            </tr>
        {% endfor %}
    </table>
{% endifportalhasperm %}
