{% load dict_key_extras %}
<thead>
    {% if data.menu and not data.title %}
        <th> <input type="checkbox" id="select_all_{{group}}" onchange="selectAll(this, '{{group}}')"> </th>
    {% endif %}
    <th>Name</th>
    <th>Template</th>
    <th>Last Modification date</th>
    {% if data.usernames %}
        <th>User</th>
    {% endif %}
    {% if not data.title%}
        <th>Workspace</th>
    {% endif %}
    <th>Actions</th>
</thead>
<tbody>
    {% for data_loaded in objects %}
        <tr objectid="{{data_loaded.data.id}}">
            {% if data.menu and not data.title %}
            <td id="actionCheckbox">
                <input type="checkbox" id={{data_loaded.data.id}} name={{group}}>
            </td>
            {% endif %}
            <td>
                <script>
                    document.write('{{ data_loaded.data.title }}'.replace(/\.[^/.]+$/, ""));
                </script>
            </td>
            <td> {{ data_loaded.data.template.display_name }}
            </td>
            <td>
                {{ data_loaded.data.last_modification_date|date:"Y/m/d, g:i A " }}
            </td>
            {% if data.usernames %}
            <td>
                {% with key=data_loaded.data.user_id %}
                  {{ data.usernames|get:key }}
                {% endwith %}
            </td>
            {% endif %}
            {% if not data.title%}
            <td>
                {% if data_loaded.data.workspace %}
                    {{ data_loaded.data.workspace.title }}
                {% else %}
                    None
                {% endif %}
            </td>
            {% endif %}
            <td>
                {% if data_loaded.can_read %}
                    <a class="btn btn-default view-record-btn">
                        <i class="fa fa-file-text-o"></i> View
                    </a>
                {% endif %}
                {% if data_loaded.can_write %}
                    <a class="btn btn-default edit-record-btn">
                        <i class="fa fa-edit"></i> Edit
                    </a>

                    <a class="btn btn-default assign-workspace-record-btn">
                        <i class="fa fa-folder"></i> Change workspace
                    </a>
                {% endif %}
                {% if data_loaded.is_owner %}
                    <a class="btn btn-default delete-document-btn">
                        <i class="fa fa-trash"></i> Delete
                    </a>

                    <a class="btn btn-default change-owner-btn">
                        <i class="fa fa-user-circle-o"></i> Change Owner
                    </a>
                {% endif %}
            </td>
        </tr>
    {% endfor %}
</tbody>