{% extends 'generic/cid_group_base.html' %}
<!-- {% load static from static %} -->

{% block css %}
{% endblock %}
{% block js %}
<!--<script type="text/javascript" src="/admin/jsi18n/"></script>-->
    {{form.media}}

    <script type="text/javascript">
    </script>

<!-- {{ form.media }} -->
{% endblock %}
{% block content %}
    {% if form.instance.id %}
        <h2>Edit Group: {{cidusergroup.name}}</h2>
        Use this form to edit a CID user group.
    {% else %}
        <h2>Add New Group</h2>
        Use this form to create a CID user group.
    {% endif %}
    <form action="" method="post" enctype="multipart/form-data" id="condition-form">
        {% csrf_token %}

        <table>
            {{ form.as_table }}
        </table>
        <input type="submit" class="submit-button" value="Submit" name="submit">


        {% if cidusergroup %}
            <p>Users can be added to the group <a href="{% url 'generic:manage_cids' %}">here</a></p>

            <h3>Users</h3>

            <ul>
                {% for user in cidusergroup.ciduser_set.all %}
                    <li><a href="{% url 'generic:update_cid' user.pk %}">{{user.cid}}</a>: {{user.name}} [{{user.email}} {{user.last_name}}] {{user.userprofile.grade}}</li>

                {% empty %}
                    <li>Group currently has no users.</li>
                {% endfor %}
            </ul>
            Count: {{cidusergroup.ciduser_set.count}}
        {% endif %}


    </form>
{% endblock %}