manager_view.html 3.94 KB
{% extends "base.html" %}

{% block extrahead %}
    <script type="text/javascript"
            src="{{ MEDIA_URL }}js/manager-view.js"></script>
{% endblock %}

{% block title %}Słowniki{% endblock %}

{% block content %}
    <h3>Słowniki</h3>
    <p>
        <input type="text" id="new-vocabulary"/>
        <button id="add-vocabulary">
            dodaj słownik
        </button>
    </p>
    <div id="vocab-accordion">
        {% for vocab, managed, viewers, editors, managers in vocabularies_info %}
            {% with forloop.counter as vocab_no %}
            <h3><a href="#">{{ vocab.id }}</a></h3>
            <div>
                <table class="user-privileges"
                       id="vocab-privileges_{{ vocab.pk }}">
                    <tr>
                        <th></th>
                        <th>ogląda</th>
                        <th>modyfikuje</th>
                        <th>zarządza</th>
                    </tr>
                    {% for u in users %}
                        <tr>
                            <td>{{ u.username }}</td>
                            <td>
                                {% if u.usersettings.views_lexeme %}
                                    <input
                                            type="checkbox"
                                            id="view-{{ u.pk }}-{{ vocab_no }}"
                                            class="checkbox-view"
                                            {% if u in viewers %}
                                            checked="checked"
                                            {% endif %}
                                            {% if u.usersettings.views_all_lexemes or not managed %}
                                            disabled="disabled"
                                            {% endif %}/>
                                {% else %}
                                    <input type="checkbox" disabled="disabled"/>
                                {% endif %}
                            </td>
                            <td>
                                {% if u.usersettings.changes_lexeme %}
                                    <input
                                            type="checkbox"
                                            id="change-{{ u.pk }}-{{ vocab_no }}"
                                            class="checkbox-change"
                                            {% if u in editors %}
                                            checked="checked"
                                            {% endif %}
                                            {% if not managed %}disabled="disabled"{% endif %}/>
                                {% else %}
                                    <input type="checkbox" disabled="disabled"/>
                                {% endif %}
                            </td>
                            <td>
                                {% if u.usersettings.manages_vocabulary %}
                                    <input
                                            type="checkbox"
                                            id="manage-{{ u.pk }}-{{ vocab_no }}"
                                            class="checkbox-manage"
                                            {% if u in managers %}
                                            checked="checked"
                                            {% endif %}
                                            {% if u == user or not managed or u.usersettings.manages_all_vocabs %}
                                            disabled="disabled"
                                            {% endif %}/>
                                {% else %}
                                    <input type="checkbox" disabled="disabled"/>
                                {% endif %}
                            </td>
                        </tr>
                    {% endfor %}
                </table>
            </div>
            {% endwith %}
        {% endfor %}
    </div>
{% endblock %}