{% extends "profiles/base.html" %}
{% load profile_tags %}

{% block title %}Join/Leave User Groups{% endblock %}

{% block extra_head %}
{{ block.super }}
<link rel="stylesheet" href="{{ STATIC_URL }}css/iconrow.css">
<link rel="stylesheet" href="{{ STATIC_URL }}css/profiles.css">
<link rel="stylesheet" href="{{ STATIC_URL }}css/admin/django-admin-widgets.css">
{% endblock %}

{% block body %}
    <div class="t">
        {% users_nav request.user user_this %}
        <h1>Join/Leave User Groups</h1>
        <h2>User: <a href="{{ user_this.get_absolute_url}}">
        {{ user_this.get_full_name }} ({{ user_this.username}})</a></h2>
        <div class="clear-right"></div>
        <div class="profile-wrap">
            <form method="post" action=".">{% csrf_token %}
                {% if form.non_field_errors %}
                    <div class="errors">
                        {{ form.non_field_errors|striptags }}
                    </div>
                {% endif %}
                <div class="profile-wrap" style="margin-top:1em;">
                    <div class="field-wrapper">
                        {% if form.groups.errors %}
                            <div class="errors">{{ form.groups.errors|striptags }}</div>
                        {% endif %}
                        <label for="id_groups" style="float:left; padding-right: 1em;">
                            <b>{{ form.groups.label }}:</b>
                        </label>
                        <br>
                        {{ form.groups }}
                    </div>
                    <div style="clear:left;"></div>
                </div>
                <div class="submit-row">
                    <input id='add_groups_submit' type="submit" value="Save" class="default" />
                </div>
            </form>
        </div>
    </div>
{% endblock %}

{% block extra_body %}
    {{ block.super }}
    <script type="text/javascript" src="{{ STATIC_URL }}js/jquery-1.4.2.min.js"></script>
    <script type="text/javascript" src="{{ STATIC_URL }}js/admin/django-admin.multiselect.js"></script>
    <script type="text/javascript">
        $(document).ready(function(){
            jQuery.each($("select[multiple]"), function () {
             SelectFilter2.init(this.id, "Groups", 0, "/media/");  
            });
            $("#add_groups_submit").click(function(){
                SelectBox.filter('id_groups_to', '');
                $("#id_groups_input2").val('');
            });
        });
    </script>
{% endblock %}
